Пример #1
0
// TestComposeFilter_Empty_Nothing
func TestComposeFilter_Empty_Nothing(t *testing.T) {
	f := maybe.ComposeFilter()
	m := maybe.Nothing()
	b := f(m)
	assertFalse(t, b)
}
Пример #2
0
// TestComposeFilter_True_Nothing
func TestComposeFilter_True_Nothing(t *testing.T) {
	f := maybe.ComposeFilter(FilterTrue)
	m := maybe.Nothing()
	b := f(m)
	assertFalse(t, b)
}
Пример #3
0
// TestComposeMap_Empty_Nothing
func TestComposeMap_Empty_Nothing(t *testing.T) {
	f := maybe.ComposeMap()
	_m := maybe.Nothing()
	m := f(_m)
	assertNothing(t, m)
}
Пример #4
0
// TestComposeMap_Increment_Nothing
func TestComposeMap_Increment_Nothing(t *testing.T) {
	f := maybe.ComposeMap(increment)
	_m := maybe.Nothing()
	m := f(_m)
	assertNothing(t, m)
}
Пример #5
0
// TestCall_Nothing
func TestCall_Nothing(t *testing.T) {
	_m := maybe.Nothing()
	m := maybe.Call(MapAny_Echo, _m)
	assertNothing(t, m)
}
Пример #6
0
// TestCall_Multi_Nil
func TestCall_Multi_Nil(t *testing.T) {
	arg1 := maybe.New("one")
	arg2 := maybe.Nothing()
	m := maybe.Call(MultiArgs_Last, arg1, arg2)
	assertNothing(t, m)
}
Пример #7
0
// TestFilter_Nothing_Nil
func TestFilter_Nothing_Nil(t *testing.T) {
	_m := maybe.Nothing()
	m := _m.Filter(nil)
	assertNothing(t, m)
}
Пример #8
0
// TestFilter_Nothing_Panic
func TestFilter_Nothing_Panic(t *testing.T) {
	_m := maybe.Nothing()
	m := _m.Filter(FilterPanic)
	assertNothing(t, m)
}
Пример #9
0
// TestMap_Nothing_Nil
func TestMap_Nothing_Nil(t *testing.T) {
	_m := maybe.Nothing()
	m := _m.Map(nil)
	assertNothing(t, m)
}
Пример #10
0
// TestMap_Nothing_Panic
func TestMap_Nothing_Panic(t *testing.T) {
	_m := maybe.Nothing()
	m := _m.Map(MapPanic)
	assertNothing(t, m)
}
Пример #11
0
// TestGetOrElse_Nothing
func TestGetOrElse_Nothing(t *testing.T) {
	m := maybe.Nothing()
	assertGetOrElse(t, m, ELSE, ELSE)
}
Пример #12
0
// TestGetOrNil_Nothing
func TestGetOrNil_Nothing(t *testing.T) {
	m := maybe.Nothing()
	assertGetOrNil(t, m, nil)
}
Пример #13
0
// TestNothing
func TestNothing(t *testing.T) {
	m := maybe.Nothing()
	assertNothing(t, m)
}
Пример #14
0
// MapNothing
func MapNothing(m *maybe.T) *maybe.T {
	return maybe.Nothing()
}
Пример #15
0
 *********************************************************************/

const (
	ELSE             = "else"
	ERROR_MSG        = "error message"
	FILTER_PANIC     = "filter_panic"
	MAP_PANIC        = "map_panic"
	MAPPED           = "mapped"
	SOMETHING        = "something"
	FILTER_FUNC_ERR  = "maybe.T.Filter() expects func with single return value of type bool"
	MAP_FUNC_ERR     = "maybe.T.Map() expects func"
	MAP_FUNC_RET_ERR = "maybe.T.Map() expects return types to be one of: (any), (any, bool), (any, error)"
	CALL_FUNC_ERR    = "maybe.Call() expects func"
)

var nothing = maybe.Nothing()

/*********************************************************************
 ** Test Assert Functions
 *********************************************************************/

// 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()