Esempio n. 1
0
// assertNothing
func assertNothing(t *testing.T, m *maybe.T) {
	if m != nothing {
		t.Fatal("AssertNothing: m is not equal to maybe.Nothing()")
	}
	_, ok := m.Get()
	if ok {
		t.Fatal("assertNothing: m.Get() returned true")
	}
	err := m.Err()
	if err != nil {
		t.Fatalf("assertNothing: m.Err() returned non-nil")
	}
}
Esempio n. 2
0
// assertSomethingValue
func assertSomethingValue(t *testing.T, m *maybe.T, v interface{}) {
	if m == nothing {
		t.Fatal("AssertSomethingValue: m is equal to maybe.Nothing()")
	}
	g, ok := m.Get()
	if !ok {
		t.Fatal("assertSomethingValue(): m.Get() returned false")
	}
	if g != v {
		t.Fatalf("assertSomethingValue(): m.Get() returned '%v' instead of '%v'", g, v)
	}
	err := m.Err()
	if err != nil {
		t.Fatalf("assertSomethingValue: m.Err() returned non-nil")
	}
}
Esempio n. 3
0
// assertSomething
func assertSomething(t *testing.T, m *maybe.T) {
	if m == nothing {
		t.Fatal("AssertSomething: m is equal to maybe.Nothing()")
	}
	g, ok := m.Get()
	if !ok {
		t.Fatal("assertSomething: m.Get() returned false")
	}
	if g != SOMETHING {
		t.Fatalf("assertSomething: m.Get() returned '%v' instead of '%s'", g, SOMETHING)
	}
	err := m.Err()
	if err != nil {
		t.Fatalf("assertSomething: m.Err() returned non-nil")
	}
}
Esempio n. 4
0
// assertError
func assertError(t *testing.T, m *maybe.T, msg string) {
	if m == nothing {
		t.Fatal("AssertError: m is equal to maybe.Nothing()")
	}
	_, ok := m.Get()
	if ok {
		t.Fatal("assertError: m.Get() returned true")
	}
	err := m.Err()
	if err == nil {
		t.Fatalf("assertError: m.Err() returned nil")
	}
	if err.Error() != msg {
		t.Fatalf("assertError: m.Err() returned '%s' instead of '%s'", err.Error(), msg)
	}
}