From 220f0f0226910b506b0de7fcc01aa5d08a9526d3 Mon Sep 17 00:00:00 2001 From: Klas Lindfors Date: Tue, 3 Feb 2015 10:56:13 +0100 Subject: [PATCH] add a negative test for the hex decode --- lib/tests/parse_key.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/tests/parse_key.c b/lib/tests/parse_key.c index 4523241..9d4bb18 100644 --- a/lib/tests/parse_key.c +++ b/lib/tests/parse_key.c @@ -37,9 +37,7 @@ struct key { const char text[49]; const unsigned char formatted[24]; int valid; -}; - -struct key keys[] = { +} keys[] = { {"010203040506070801020304050607080102030405060708", {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}, 1}, @@ -49,6 +47,9 @@ struct key keys[] = { {"A1A2A3A4A5A6A7A8A1A2A3A4A5A6A7A8A1A2A3A4A5A6A7A8", {0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8,0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8}, 1}, + {"This is not something considered valid hex......", + {}, + 0}, }; static int parse_key(const char *text, const unsigned char *expected, int valid) {