1
0
mirror of https://github.com/yarrick/iodine.git synced 2024-11-29 16:36:03 +03:00

removed possible segfault in the test-code

This commit is contained in:
Bjorn Andersson 2007-01-27 16:32:44 +00:00
parent f3da9d2d85
commit ec1ed45793

View File

@ -18,6 +18,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h>
#include "base32.h" #include "base32.h"
#include "test.h" #include "test.h"
@ -35,14 +36,17 @@ START_TEST(test_base32_encode)
{ {
size_t len; size_t len;
char *buf; char *buf;
int val;
int i; int i;
len = 0; len = 0;
buf = NULL; buf = NULL;
for (i = 0; testpairs[i].a != NULL; i++) { for (i = 0; testpairs[i].a != NULL; i++) {
base32_encode(&buf, &len, testpairs[i].a, strlen(testpairs[i].a)); val = base32_encode(&buf, &len, testpairs[i].a, strlen(testpairs[i].a));
fail_unless(val > 0, strerror(errno));
fail_unless(buf != NULL, "buf == NULL");
fail_unless(strcmp(buf, testpairs[i].b) == 0, fail_unless(strcmp(buf, testpairs[i].b) == 0,
va_str("'%s' != '%s'", buf, testpairs[i].b)); va_str("'%s' != '%s'", buf, testpairs[i].b));
} }
@ -53,14 +57,17 @@ START_TEST(test_base32_decode)
{ {
size_t len; size_t len;
void *buf; void *buf;
int val;
int i; int i;
len = 0; len = 0;
buf = NULL; buf = NULL;
for (i = 0; testpairs[i].a != NULL; i++) { for (i = 0; testpairs[i].a != NULL; i++) {
base32_decode(&buf, &len, testpairs[i].b); val = base32_decode(&buf, &len, testpairs[i].b);
fail_unless(val > 0, strerror(errno));
fail_unless(buf != NULL, "buf == NULL");
fail_unless(strcmp(buf, testpairs[i].a) == 0, fail_unless(strcmp(buf, testpairs[i].a) == 0,
va_str("'%s' != '%s'", buf, testpairs[i].a)); va_str("'%s' != '%s'", buf, testpairs[i].a));
} }