From cd74ac5f880be750d9bd8b370b74f9c16d4121ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Thu, 7 Nov 2002 08:57:02 +0100 Subject: [PATCH] Moved test from examples directory. Rev: src/nettle/testsuite/sexp-conv-test:1.1 --- testsuite/sexp-conv-test | 95 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100755 testsuite/sexp-conv-test diff --git a/testsuite/sexp-conv-test b/testsuite/sexp-conv-test new file mode 100755 index 00000000..a0f58812 --- /dev/null +++ b/testsuite/sexp-conv-test @@ -0,0 +1,95 @@ +#! /bin/sh + +if [ -z "$srcdir" ] ; then + srcdir=`pwd` +fi + +# echo -n is not portable + +if [ "`echo -n ''`" = "" ]; then + n='-n'; c='' +elif [ "`echo '\c'`" = "" ]; then + n=''; c='\c' +else + echo >&2 'Neither echo -n nor echo \c seems to work.' + exit 1 +fi + +test_advanced () { + echo "$1" > test.in + if ./sexp-conv -s advanced <test.in >test1.out ; then + true + else + exit 1 + fi + echo "$2" > test2.out + + if cmp test1.out test2.out ; then + true + else + exit 1; + fi +} + +test_transport () { + echo "$1" > test.in + if ./sexp-conv -s transport <test.in >test1.out ; then + true + else + exit 1 + fi + echo "$2" > test2.out + + if cmp test1.out test2.out ; then + true + else + exit 1; + fi +} + +test_canonical () { + echo "$1" > test.in + if ./sexp-conv -s canonical <test.in >test1.out ; then + true + else + exit 1 + fi + echo $n "$2$c" > test2.out + + if cmp test1.out test2.out ; then + true + else + exit 1; + fi +} + +test_advanced '0:' '""' +test_advanced '3:foo' 'foo' +test_advanced '12:fooooooooooo' 'fooooooooooo' +test_advanced '10:fooooooooo' 'fooooooooo' +test_advanced '4:3des' '"3des"' +test_advanced '"foo"' 'foo' +test_advanced '4:foo +' '"foo\n"' +test_advanced '2:"\' '"\"\\"' +test_advanced '()' '()' +test_advanced '(foo bar baz)' '(foo bar + baz)' +test_advanced '; comment +()' '()' + +test_advanced '(foo[bar]foo)' '(foo [bar]foo)' + +test_transport '0:' '{MDo=}' +test_transport '()' '{KCk=}' +test_transport 'foo' '{Mzpmb28=}' +test_transport '(foo bar baz)' '{KDM6Zm9vMzpiYXIzOmJheik=}' + +test_canonical '""' '0:' +test_canonical 'foo' '3:foo' +test_canonical 'fooooooooooo' '12:fooooooooooo' +test_canonical 'fooooooooo' '10:fooooooooo' +test_canonical '(foo bar baz)' '(3:foo3:bar3:baz)' +test_canonical '{KDM6Zm9vMzpiYXIzOmJheik=}' '(3:foo3:bar3:baz)' + +exit 0 -- GitLab