test_get_directory_depth_offset 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env bash
  2. set -e
  3. set -u
  4. set -o pipefail
  5. source "${BASH_SOURCE%/*}/assertions.sh"
  6. test_get_directory_depth_offset() {
  7. local path=${1:?}
  8. source "${BASH_SOURCE%/*}/../src/utils/functions.sh"
  9. get_directory_depth_offset "$path"
  10. }
  11. test_get_directory_depth_offset_main() {
  12. assert_equal \
  13. "test_get_directory_depth_offset" \
  14. "./" \
  15. "$(test_get_directory_depth_offset "foo.html")"
  16. assert_equal \
  17. "test_get_directory_depth_offset" \
  18. "./" \
  19. "$(test_get_directory_depth_offset "./foo.html")"
  20. assert_equal \
  21. "test_get_directory_depth_offset" \
  22. "./../" \
  23. "$(test_get_directory_depth_offset "./bar/foo.html")"
  24. assert_equal \
  25. "test_get_directory_depth_offset" \
  26. "./../../" \
  27. "$(test_get_directory_depth_offset "./baz/bar/foo.html")"
  28. assert_equal \
  29. "test_get_directory_depth_offset" \
  30. "./../../../" \
  31. "$(test_get_directory_depth_offset "./fip/baz/bar/foo.html")"
  32. }
  33. test_get_directory_depth_offset_main