diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-10 13:18:30 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-07-10 13:35:20 -0600 |
commit | 27401b6ea459921a6152ab1744da1618358465f4 (patch) | |
tree | 2c4f9c096f1a593e65d7f824901e815ca48bfaf0 /lib/btrfs/btrfsvol/addr_test.go | |
parent | 42f6f78e0a32ba0eda707154f8e1ffb4579604ee (diff) |
Rename the module, mv pkg lib
Diffstat (limited to 'lib/btrfs/btrfsvol/addr_test.go')
-rw-r--r-- | lib/btrfs/btrfsvol/addr_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/btrfs/btrfsvol/addr_test.go b/lib/btrfs/btrfsvol/addr_test.go new file mode 100644 index 0000000..aae6378 --- /dev/null +++ b/lib/btrfs/btrfsvol/addr_test.go @@ -0,0 +1,36 @@ +package btrfsvol_test + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" + + "git.lukeshu.com/btrfs-progs-ng/lib/btrfs/btrfsvol" +) + +func TestAddrFormat(t *testing.T) { + t.Parallel() + type TestCase struct { + InputAddr btrfsvol.LogicalAddr + InputFmt string + Output string + } + addr := btrfsvol.LogicalAddr(0x3a41678000) + testcases := map[string]TestCase{ + "v": {InputAddr: addr, InputFmt: "%v", Output: "0x0000003a41678000"}, + "s": {InputAddr: addr, InputFmt: "%s", Output: "0x0000003a41678000"}, + "q": {InputAddr: addr, InputFmt: "%q", Output: `"0x0000003a41678000"`}, + "x": {InputAddr: addr, InputFmt: "%x", Output: "3a41678000"}, + "d": {InputAddr: addr, InputFmt: "%d", Output: "250205405184"}, + "neg": {InputAddr: -1, InputFmt: "%v", Output: "-0x000000000000001"}, + } + for tcName, tc := range testcases { + tc := tc + t.Run(tcName, func(t *testing.T) { + t.Parallel() + actual := fmt.Sprintf(tc.InputFmt, tc.InputAddr) + assert.Equal(t, tc.Output, actual) + }) + } +} |