Exemplo 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")
	}
}
Exemplo 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")
	}
}
Exemplo 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")
	}
}
Exemplo 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)
	}
}
Exemplo n.º 5
0
// assertGetOrElse
func assertGetOrElse(t *testing.T, m *maybe.T, e string, v string) {
	g := m.GetOrElse(e)
	if g != v {
		t.Fatalf("assertGitOrElse: m.Get() returned '%v' instead of '%s'", g, v)
	}
}
Exemplo n.º 6
0
// assertGetOrNil
func assertGetOrNil(t *testing.T, m *maybe.T, v interface{}) {
	g := m.GetOrNil()
	if g != v {
		t.Fatalf("assertGetOrNil: m.Get() returned '%v' instead of '%v'", g, v)
	}
}