sortutil_test.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Public Domain Software
  3. *
  4. * I (Matthias Ladkau) am the author of the source code in this file.
  5. * I have placed the source code in this file in the public domain.
  6. *
  7. * For further information see: http://creativecommons.org/publicdomain/zero/1.0/
  8. */
  9. package sortutil
  10. import (
  11. "reflect"
  12. "testing"
  13. )
  14. func TestInt64s(t *testing.T) {
  15. testSlice := []int64{5, 2, 3, 0xFFFFFFFF, 1}
  16. Int64s(testSlice)
  17. if !reflect.DeepEqual(testSlice, []int64{1, 2, 3, 5, 0xFFFFFFFF}) {
  18. t.Error("Unexpected sorted order:", testSlice)
  19. return
  20. }
  21. }
  22. func TestUInt64s(t *testing.T) {
  23. testSlice := []uint64{5, 2, 3, 0xFFFFFFFF, 1}
  24. UInt64s(testSlice)
  25. if !reflect.DeepEqual(testSlice, []uint64{1, 2, 3, 5, 0xFFFFFFFF}) {
  26. t.Error("Unexpected sorted order:", testSlice)
  27. return
  28. }
  29. }
  30. func TestAbstractSlice(t *testing.T) {
  31. testSlice := []interface{}{5, 2, "bla", 0xFFFFFFFF, 1}
  32. InterfaceStrings(testSlice)
  33. if !reflect.DeepEqual(testSlice, []interface{}{1, 2, 0xFFFFFFFF, 5, "bla"}) {
  34. t.Error("Unexpected sorted order:", testSlice)
  35. return
  36. }
  37. }