concat_test.go 783 B

12345678910111213141516171819202122232425262728293031
  1. package help
  2. import "testing"
  3. func TestAppend(t *testing.T) {
  4. input := []int{1, 2, 3, 4}
  5. want := []interface{}{1, 2, 3, 4, 5}
  6. if q := From(input).Append(5); !validateQuery(q, want) {
  7. t.Errorf("From(%v).Append()=%v expected %v", input, toSlice(q), want)
  8. }
  9. }
  10. func TestConcat(t *testing.T) {
  11. input1 := []int{1, 2, 3}
  12. input2 := []int{4, 5}
  13. want := []interface{}{1, 2, 3, 4, 5}
  14. if q := From(input1).Concat(From(input2)); !validateQuery(q, want) {
  15. t.Errorf("From(%v).Concat(%v)=%v expected %v", input1, input2, toSlice(q), want)
  16. }
  17. }
  18. func TestPrepend(t *testing.T) {
  19. input := []int{1, 2, 3, 4}
  20. want := []interface{}{0, 1, 2, 3, 4}
  21. if q := From(input).Prepend(0); !validateQuery(q, want) {
  22. t.Errorf("From(%v).Prepend()=%v expected %v", input, toSlice(q), want)
  23. }
  24. }