func TestContainsWhenDontExistItem(t *testing.T) { for _, tt := range inputTestToDontExists { ret, err := gotains.Contains(tt.collectionTest, tt.itensToVerify) if err != nil { t.Error(err) } if ret { t.Errorf("Error to verify when item in slice don't exist with values %s and %s", tt.collectionTest, tt.itensToVerify) } } for _, tt := range inputTestToDontExistsInArray { ret, err := gotains.Contains(tt.collectionTest, tt.itensToVerify) if err != nil { t.Error(err) } if ret { t.Errorf("Error to verify when item in array don't exist with values %s and %s", tt.collectionTest, tt.itensToVerify) } } }
func TestContainsWhenExistItem(t *testing.T) { for _, tt := range inputTestToExists { ret, err := gotains.Contains(tt.collectionTest, tt.itensToVerify) if err != nil { t.Error(err) } if !ret { t.Errorf("Error to verify slice when item exist with values %v and %v", tt.collectionTest, tt.itensToVerify) } } for _, tt := range inputTestToExistsInArray { ret, err := gotains.Contains(tt.collectionTest, tt.itensToVerify) if err != nil { t.Error(err) } if !ret { t.Errorf("Error to verify arrays when item exist with values %v and %v", tt.collectionTest, tt.itensToVerify) } } }
func TestContainsWhenTypeNeitherSliceNorArray(t *testing.T) { _, err := gotains.Contains("testError", "testError") if err == nil && err.Error() != "InterfaceSlice() given a non-slice type" { t.Error("Validation has a problem") } }