| 28 | ) |
| 29 | |
| 30 | func TestBitmask(t *testing.T) { |
| 31 | var tests = []struct { |
| 32 | typ Type |
| 33 | expected bool |
| 34 | }{ |
| 35 | {TerminateThread, true}, |
| 36 | {TerminateProcess, true}, |
| 37 | {CreateThread, true}, |
| 38 | {CreateFile, false}, |
| 39 | {WriteFile, false}, |
| 40 | {LoadModule, false}, |
| 41 | {MapFileRundown, true}, |
| 42 | {ProcessRundown, true}, |
| 43 | } |
| 44 | |
| 45 | b := bitmask.New() |
| 46 | for _, typ := range AllWithState() { |
| 47 | if typ == WriteFile || typ == LoadModule || typ == CreateFile { |
| 48 | continue |
| 49 | } |
| 50 | b.Set(typ.ID()) |
| 51 | } |
| 52 | |
| 53 | for _, tt := range tests { |
| 54 | t.Run(tt.typ.String(), func(t *testing.T) { |
| 55 | assert.Equal(t, tt.expected, b.IsSet(tt.typ.ID())) |
| 56 | }) |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | func TestBitSets(t *testing.T) { |
| 61 | var tests = []struct { |