| 1 | package mlog |
| 2 | |
| 3 | import ( |
| 4 | "io" |
| 5 | "testing" |
| 6 | ) |
| 7 | |
| 8 | func TestFlagSet(t *testing.T) { |
| 9 | logger := New(io.Discard, 0) |
| 10 | |
| 11 | expected := Ltimestamp | Ldebug |
| 12 | logger.SetFlags(expected) |
| 13 | flags := logger.Flags() |
| 14 | t.Log(flags) |
| 15 | if flags&(expected) == 0 { |
| 16 | t.Errorf("flags did not match\n%12s %#v\n%12s %#v", |
| 17 | "expected:", expected.GoString(), |
| 18 | "actual:", flags.GoString()) |
| 19 | } |
| 20 | |
| 21 | expected = Ltimestamp | Llongfile |
| 22 | logger.SetFlags(expected) |
| 23 | flags = logger.Flags() |
| 24 | if flags&(expected) == 0 { |
| 25 | t.Errorf("flags did not match\n%12s %#v\n%12s %#v", |
| 26 | "expected:", expected.GoString(), |
| 27 | "actual:", flags.GoString()) |
| 28 | } |
| 29 | } |