added testing for functions from lib/path.awk
This commit is contained in:
parent
f6d8c46314
commit
e3c7c148f9
1
Makefile
1
Makefile
|
@ -24,6 +24,7 @@ upload:
|
|||
scp -r html/* techn0path@vern.cc:public_html
|
||||
|
||||
test: testing/input/index.gmi testing/input/feed.txt
|
||||
echo '' | mawk -f lib/navbar.awk -f lib/path.awk -f scripts/test.awk > testing/output/functionOutputs.txt
|
||||
mawk -f lib/navbar.awk -f lib/path.awk -f scripts/html.awk -v 'sourcePath=testing/input' -- testing/input/index.gmi > testing/output/index.html
|
||||
mawk -f lib/navbar.awk -f lib/path.awk -f scripts/gemini.awk -v 'sourcePath=testing/input' -- testing/input/index.gmi > testing/output/index.gmi
|
||||
mawk -f lib/path.awk -f scripts/feed.awk -- testing/input/feed.txt > testing/output/feed.atom
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
function assert(expectedValue, actualValue) {
|
||||
if (expectedValue == actualValue) {
|
||||
printf("%s == %s\n", expectedValue, actualValue)
|
||||
} else {
|
||||
printf("%s != %s\n", expectedValue, actualValue)
|
||||
}
|
||||
}
|
||||
|
||||
END {
|
||||
print "=> getDirname('../path/deep/down/here')"
|
||||
assert("../path/deep/down/", getDirname("../path/deep/down/here"))
|
||||
|
||||
print "=> getDirname('a_single_directory')"
|
||||
assert(".", getDirname("a_single_directory"))
|
||||
|
||||
print "=> resolvePath('./path/to/irrelevant_directory/../file.txt')"
|
||||
assert("path/to/file.txt", resolvePath("./path/to/irrelevant_directory/../file.txt"))
|
||||
|
||||
print "=> getRelativePath('parent/directory/', 'parent/path/to/file.txt')"
|
||||
assert("../path/to/file.txt", getRelativePath("parent/directory", "parent/path/to/file.txt"))
|
||||
|
||||
print "=> getRelativePath('parent/directory/', 'parent/directory/path/to/file.txt')"
|
||||
assert("path/to/file.txt", getRelativePath("parent/directory", "parent/directory/path/to/file.txt"))
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
=> getDirname('../path/deep/down/here')
|
||||
../path/deep/down/ == ../path/deep/down/
|
||||
=> getDirname('a_single_directory')
|
||||
. == .
|
||||
=> resolvePath('./path/to/irrelevant_directory/../file.txt')
|
||||
path/to/file.txt != path/to/../
|
||||
=> getRelativePath('parent/directory/', 'parent/path/to/file.txt')
|
||||
../path/to/file.txt != to/path/parent
|
||||
=> getRelativePath('parent/directory/', 'parent/directory/path/to/file.txt')
|
||||
path/to/file.txt != path/directory/parent/to
|
Loading…
Reference in New Issue