Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

40 wiersze
1.1 KiB

  1. // Copyright 2017 Google Inc. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package testing
  15. import (
  16. "reflect"
  17. "testing"
  18. )
  19. func TestCompareSlices(t *testing.T) {
  20. for _, test := range []struct {
  21. a, b []int
  22. wantEqual bool
  23. }{
  24. {nil, nil, true},
  25. {nil, []int{}, true},
  26. {[]int{1, 2}, []int{1, 2}, true},
  27. {[]int{1}, []int{1, 2}, false},
  28. {[]int{1, 2}, []int{1}, false},
  29. {[]int{1, 2}, []int{1, 3}, false},
  30. } {
  31. _, got := compareSlices(reflect.ValueOf(test.a), reflect.ValueOf(test.b))
  32. if got != test.wantEqual {
  33. t.Errorf("%v, %v: got %t, want %t", test.a, test.b, got, test.wantEqual)
  34. }
  35. }
  36. }