Skip to content

Commit

Permalink
Add more complete test.
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkx committed Apr 2, 2021
1 parent 99da99a commit 9c4777f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ For this reason - the industry generally encodes these in base45. A document for

```https://datatracker.ietf.org/doc/draft-faltstrom-base45/```

## Testing

The test.sh script does a simple test against the Javascript and Python versions of this utility.

31 changes: 31 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh
#
# Test against python and JS scripts
#
C_BASE45=./base45
PY_BASE45=${PY_BASE45:-$(python-config --prefix)/bin/base45}
JS_BASE45=${JS_BASE45:-${NPMDIR}/bin/base45}

I=0
while test ${I} -lt 100
do
for len in ${I} $RANDOM
do
openssl rand ${len} > x
cat x |\
${C_BASE45} | ${PY_BASE45} --decode |\
${PY_BASE45} --encode | ${C_BASE45} -d |\
${JS_BASE45} | ${C_BASE45} -d |\
${C_BASE45} | ${JS_BASE45} -d |\
${JS_BASE45} | ${PY_BASE45} --decode |\
${PY_BASE45} --encode | ${JS_BASE45} -d |\
cat > y

if ! diff x y; then
echo FAIL
break
fi
done
I=$(expr ${I} + 1)
done
exit 0

0 comments on commit 9c4777f

Please sign in to comment.