]> pd.if.org Git - uuid/blobdiff - t/sha1.c
Set hash tests to auto calculate number of tests
[uuid] / t / sha1.c
index 4903d43a1be0aa26dd76acae189a529ce31594fa..4096552105ba2f414eed9c4bf48e1ad15e894450 100644 (file)
--- a/t/sha1.c
+++ b/t/sha1.c
@@ -18,33 +18,15 @@ static void bytestr(unsigned char *h, char *s, int len) {
        }
 }
 
-static int strbytes(char *s, unsigned char *d) {
-        unsigned int byte;
-        int i = 0;
-
-       if (!s) return 0;
-        if (*s == 0) return 0;
-
-       while (*s) {
-                if (*s == '-' || *s == ':' || *s == ' ') s++;
-
-                if (sscanf(s, "%02x", &byte) != 1) {
-                        return 0;
-                }
-                s += 2;
-                d[i++] = byte & 0xff;
-        }
-        return i;
-}
-
 int main(int ac, char *av[]) {
        unsigned char tmp[20];
        hash_state md;
        int i, j;
        char want[64];
        char have[64];
+       int n;
 
-       static const struct {
+       static struct {
                char *msg;
                int repeat;
                unsigned char hash[20];
@@ -67,10 +49,12 @@ int main(int ac, char *av[]) {
        { "0123456701234567012345670123456701234567012345670123456701234567", 10, 
        {0xDE, 0xA3, 0x56, 0xA2, 0xCD, 0xDD, 0x90, 0xC7, 0xA7, 0xEC, 0xED, 0xC5, 0xEB, 0xB5, 0x63, 0x93, 0x4F, 0x46, 0x04, 0x52},
        },
-    { NULL, { 0 } }
+    { NULL, 0, { 0 } }
   };
 
-       plan(8);
+       for (n=0;tests[n].msg != NULL; n++);
+
+       plan(2*n);
 
        for (i = 0; tests[i].msg != NULL; i++) {
                sha1_init(&md);