]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
* testsuite/Makefile.am (TS_PROGS): Added base16-test.
authorNiels Möller <nisse@lysator.liu.se>
Wed, 30 Oct 2002 20:54:59 +0000 (21:54 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Wed, 30 Oct 2002 20:54:59 +0000 (21:54 +0100)
* testsuite/base16-test.c: New test.

Rev: src/nettle/testsuite/Makefile.am:1.27
Rev: src/nettle/testsuite/base16-test.c:1.1

testsuite/Makefile.am
testsuite/base16-test.c [new file with mode: 0644]

index 9a6fcbbcce259222210351df0af3cd02013b03b6..51b505dd5b81f170a723534e8d14076810ae31fa 100644 (file)
@@ -2,7 +2,7 @@ CFLAGS = -I$(top_srcdir) @CFLAGS@
 CPPFLAGS = @CPPFLAGS@
 
 TS_PROGS = aes-test arcfour-test blowfish-test cast128-test \
-           base64-test \
+           base16-test base64-test \
           des-test des3-test des-compat-test \
           md5-test md5-compat-test sha1-test sha256-test \
           serpent-test twofish-test \
diff --git a/testsuite/base16-test.c b/testsuite/base16-test.c
new file mode 100644 (file)
index 0000000..fe8fe92
--- /dev/null
@@ -0,0 +1,27 @@
+#include "testutils.h"
+#include "base16.h"
+
+int
+test_main(void)
+{
+  ASSERT(BASE16_ENCODE_LENGTH(0) == 0);
+  ASSERT(BASE16_ENCODE_LENGTH(1) == 2);
+  ASSERT(BASE16_ENCODE_LENGTH(2) == 4);
+
+  ASSERT(BASE16_DECODE_LENGTH(0) == 0);
+  ASSERT(BASE16_DECODE_LENGTH(1) == 1);
+  ASSERT(BASE16_DECODE_LENGTH(2) == 1);
+  ASSERT(BASE16_DECODE_LENGTH(3) == 2);
+  ASSERT(BASE16_DECODE_LENGTH(4) == 2);
+  
+  test_armor(&nettle_base16, 0, "", "");
+  test_armor(&nettle_base16, 1, "H", "48");
+  test_armor(&nettle_base16, 2, "He", "4865");
+  test_armor(&nettle_base16, 3, "Hel", "48656c");
+  test_armor(&nettle_base16, 4, "Hell", "48656c6c");
+  test_armor(&nettle_base16, 5, "Hello", "48656c6c6f");
+  test_armor(&nettle_base16, 6, "Hello", "48656c6c6f00");
+  
+  SUCCESS();
+}
+