sort_linux_test.go 481 B

1234567891011121314151617181920212223242526272829
  1. package graphdb
  2. import (
  3. "testing"
  4. )
  5. func TestSort(t *testing.T) {
  6. paths := []string{
  7. "/",
  8. "/myreallylongname",
  9. "/app/db",
  10. }
  11. sortByDepth(paths)
  12. if len(paths) != 3 {
  13. t.Fatalf("Expected 3 parts got %d", len(paths))
  14. }
  15. if paths[0] != "/app/db" {
  16. t.Fatalf("Expected /app/db got %s", paths[0])
  17. }
  18. if paths[1] != "/myreallylongname" {
  19. t.Fatalf("Expected /myreallylongname got %s", paths[1])
  20. }
  21. if paths[2] != "/" {
  22. t.Fatalf("Expected / got %s", paths[2])
  23. }
  24. }