func TestGetMap(t *testing.T) { b := FooBuilder.X(1).Y(2).Add(3).Add(4) m := builder.GetMap(b) expected := map[string]interface{}{ "X": 1, "Y": 2, "Add": []int{3, 4}, } if !reflect.DeepEqual(m, expected) { t.Errorf("expected %v, got %v", expected, m) } }
func TestUnregisteredBuilder(t *testing.T) { b := unregBuilder{}.Add(1) x, _ := builder.Get(b, "X") expected := []interface{}{1} if !reflect.DeepEqual(x.([]interface{}), expected) { t.Errorf("expected %v, got %v", expected, x) } x = builder.GetMap(b)["X"] expected = []interface{}{1} if !reflect.DeepEqual(x.([]interface{}), expected) { t.Errorf("expected %v, got %v", expected, x) } s := builder.GetStruct(b) if s != nil { t.Errorf("expected nil, got %v", s) } }