File: flagset_test.go

package info (click to toggle)
golang-github-cactus-mlog 1.0.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 272 kB
  • sloc: makefile: 2
file content (29 lines) | stat: -rw-r--r-- 603 bytes parent folder | download
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
package mlog

import (
	"io"
	"testing"
)

func TestFlagSet(t *testing.T) {
	logger := New(io.Discard, 0)

	expected := Ltimestamp | Ldebug
	logger.SetFlags(expected)
	flags := logger.Flags()
	t.Log(flags)
	if flags&(expected) == 0 {
		t.Errorf("flags did not match\n%12s %#v\n%12s %#v",
			"expected:", expected.GoString(),
			"actual:", flags.GoString())
	}

	expected = Ltimestamp | Llongfile
	logger.SetFlags(expected)
	flags = logger.Flags()
	if flags&(expected) == 0 {
		t.Errorf("flags did not match\n%12s %#v\n%12s %#v",
			"expected:", expected.GoString(),
			"actual:", flags.GoString())
	}
}