repo: uritools action: commit revision: path_from: revision_from: 5d8aa8f7c4e55a1b32b8c149b0aad02404966a83: path_to: revision_to:
commit 5d8aa8f7c4e55a1b32b8c149b0aad02404966a83 Author: epochDate: Mon Aug 14 15:10:20 2023 -0500 added scripts, make target, and a few tests for uricut and urijoin diff --git a/Makefile b/Makefile
--- a/Makefile +++ b/Makefile @@ -56,3 +56,6 @@ install: all install -t $(PREFIX)/bin rfc-list install -t $(PREFIX)/bin man-list chgrp shorten $(PREFIX)/bin/shorten && chmod g+s $(PREFIX)/bin/shorten || true #ignore this error + +test: + ./test.sh diff --git a/make-test.sh b/make-test.sh new file mode 100755 index 0000000000000000000000000000000000000000..faf9026670a66801f1e415f9a5a34c4aa52d6940 --- /dev/null +++ b/make-test.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +if [ ! "$1" ];then + printf 'usage: make-test.sh\n' >&2 + exit 1 +fi + +uri="$1" + +hash="$(md5sum <<< "$uri" | cut '-d ' -f1)" +uricut <<< "$uri" > ./tests/"${hash}" +printf 'new test created: %s\n' "./tests/${hash}" +cat "./tests/${hash}" diff --git a/test.sh b/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..0cf3ccbed9129cd4df8f26444c96d5e81c1b04b5 --- /dev/null +++ b/test.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +passed=0 +failed=0 + +for i in tests/*;do + uri="$(tail -n1 "${i}" | cut '-d ' -f2)" + if diff <(uricut <<< "${uri}") "${i}";then + printf 'uricut\t%s[\x1b[32mGOOD\x1b[0m] %s\n' "$i" "$uri" + passed=$[$passed+1] + else + printf 'uricut\t%s[\x1b[31mFAIL\x1b[0m] %s\n' "$i" "$uri" + failed=$[$failed+1] + fi + joined="$(grep -v '^whole_uri:' "${i}" | urijoin)" + if [ "${joined}" = "${uri}" ];then + printf 'urijoin\t%s[\x1b[32mGOOD\x1b[0m] %s == %s\n' "$i" "$uri" "$joined" + passed=$[$passed+1] + else + printf 'urijoin\t%s[\x1b[31mFAIL\x1b[0m] %s != %s\n' "$i" "$uri" "$joined" + failed=$[$failed+1] + fi +done +printf 'tests passed: %d\n' "$passed" +printf 'tests failed: %d\n' "$failed" diff --git a/tests/70805c51245d2cd58820c1d8b1a674d5 b/tests/70805c51245d2cd58820c1d8b1a674d5 new file mode 100644 index 0000000000000000000000000000000000000000..f618d7081fa6da8337dd6b14ea94414f1527f77e --- /dev/null +++ b/tests/70805c51245d2cd58820c1d8b1a674d5 @@ -0,0 +1,4 @@ +scheme: scheme +path: +query_string: query +whole_uri: scheme:?query diff --git a/tests/7aed69f2061217da6b5040b36d0a8612 b/tests/7aed69f2061217da6b5040b36d0a8612 new file mode 100644 index 0000000000000000000000000000000000000000..e515bb3b910f8e6756aaef91ff36ee8dbbc94a1b --- /dev/null +++ b/tests/7aed69f2061217da6b5040b36d0a8612 @@ -0,0 +1,5 @@ +scheme: scheme +domain: +path: / +fragment_id: fragment +whole_uri: scheme:///#fragment diff --git a/tests/ad8b507a8d92a70eae4e2e821b7fcf63 b/tests/ad8b507a8d92a70eae4e2e821b7fcf63 new file mode 100644 index 0000000000000000000000000000000000000000..1c263054c7d55dc010647d42ae5818400de56249 --- /dev/null +++ b/tests/ad8b507a8d92a70eae4e2e821b7fcf63 @@ -0,0 +1,2 @@ +fragment_id: fragment +whole_uri: #fragment diff --git a/tests/d5f404b6f076347b696e845fcf85b294 b/tests/d5f404b6f076347b696e845fcf85b294 new file mode 100644 index 0000000000000000000000000000000000000000..02f1013119cfaa6e26a9ff5bcb93f30307bfc59d --- /dev/null +++ b/tests/d5f404b6f076347b696e845fcf85b294 @@ -0,0 +1,5 @@ +scheme: scheme +domain: +path: / +query_string: query +whole_uri: scheme:///?query diff --git a/tests/e092dca39dd580ff0ab7e78a3405a005 b/tests/e092dca39dd580ff0ab7e78a3405a005 new file mode 100644 index 0000000000000000000000000000000000000000..c3ec42e935f2709cf328db57cd19bb0a0a0241b7 --- /dev/null +++ b/tests/e092dca39dd580ff0ab7e78a3405a005 @@ -0,0 +1,5 @@ +scheme: scheme +domain: domain +path: +query_string: query +whole_uri: scheme://domain?query diff --git a/tests/f0b7c8e37cb08f856808cd5571f8154a b/tests/f0b7c8e37cb08f856808cd5571f8154a new file mode 100644 index 0000000000000000000000000000000000000000..2bdb6aac1b445594efef8bb8c317442c46b955c2 --- /dev/null +++ b/tests/f0b7c8e37cb08f856808cd5571f8154a @@ -0,0 +1,4 @@ +domain: +path: / +fragment_id: fragment +whole_uri: ///#fragment
-----END OF PAGE-----