-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflags_test.go
More file actions
53 lines (45 loc) · 1.49 KB
/
flags_test.go
File metadata and controls
53 lines (45 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package squashfs_test
import (
"testing"
"github.com/KarpelesLab/squashfs"
)
// TestFlagsOperations tests the Flags type operations
func TestFlagsOperations(t *testing.T) {
// Test flag string representation
testCases := []struct {
flag squashfs.Flags
expected string
}{
{squashfs.UNCOMPRESSED_INODES, "UNCOMPRESSED_INODES"},
{squashfs.UNCOMPRESSED_DATA, "UNCOMPRESSED_DATA"},
{squashfs.CHECK, "CHECK"},
{squashfs.UNCOMPRESSED_FRAGMENTS, "UNCOMPRESSED_FRAGMENTS"},
{squashfs.NO_FRAGMENTS, "NO_FRAGMENTS"},
{squashfs.ALWAYS_FRAGMENTS, "ALWAYS_FRAGMENTS"},
{squashfs.DUPLICATES, "DUPLICATES"},
{squashfs.EXPORTABLE, "EXPORTABLE"},
{squashfs.UNCOMPRESSED_XATTRS, "UNCOMPRESSED_XATTRS"},
{squashfs.NO_XATTRS, "NO_XATTRS"},
{squashfs.COMPRESSOR_OPTIONS, "COMPRESSOR_OPTIONS"},
{squashfs.UNCOMPRESSED_IDS, "UNCOMPRESSED_IDS"},
{squashfs.EXPORTABLE | squashfs.NO_FRAGMENTS, "NO_FRAGMENTS|EXPORTABLE"},
{0, ""},
{1<<15 | 1<<14, ""}, // Unknown flags
}
for _, tc := range testCases {
if tc.flag.String() != tc.expected {
t.Errorf("Expected flag %d string to be %s, got %s", tc.flag, tc.expected, tc.flag.String())
}
}
// Test Has method
flags := squashfs.EXPORTABLE | squashfs.UNCOMPRESSED_DATA
if !flags.Has(squashfs.EXPORTABLE) {
t.Errorf("flags should have EXPORTABLE")
}
if !flags.Has(squashfs.UNCOMPRESSED_DATA) {
t.Errorf("flags should have UNCOMPRESSED_DATA")
}
if flags.Has(squashfs.NO_FRAGMENTS) {
t.Errorf("flags should not have NO_FRAGMENTS")
}
}