diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index 9a6fcbbcce259222210351df0af3cd02013b03b6..51b505dd5b81f170a723534e8d14076810ae31fa 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -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 index 0000000000000000000000000000000000000000..fe8fe92305fa067c6145fb62fc39c33bc869ed70 --- /dev/null +++ b/testsuite/base16-test.c @@ -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(); +} +