support_test.go 642 B

12345678910111213141516171819202122232425
  1. package attl
  2. import "testing"
  3. import "reflect"
  4. func TestSort(t *testing.T) {
  5. arr := StringList("banana", "pear", "apple")
  6. expect := StringList("apple", "banana", "pear")
  7. sorted := arr.SortStrings()
  8. if !reflect.DeepEqual(sorted, expect) {
  9. t.Errorf("Not equal: %v<->%v", sorted, expect)
  10. }
  11. arr = StringList("banana")
  12. expect = StringList("banana")
  13. sorted = arr.SortStrings()
  14. if !reflect.DeepEqual(sorted, expect) {
  15. t.Errorf("Not equal: %v<->%v", sorted, expect)
  16. }
  17. arr = StringList()
  18. expect = StringList()
  19. sorted = arr.SortStrings()
  20. if !reflect.DeepEqual(sorted, expect) {
  21. t.Errorf("Not equal: %v<->%v", sorted, expect)
  22. }
  23. }