1
0
mirror of https://github.com/yarrick/iodine.git synced 2024-11-25 22:46:05 +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 <stdlib.h>
#include <string.h>
#include <errno.h>
#include "base32.h"
#include "test.h"
@ -35,14 +36,17 @@ START_TEST(test_base32_encode)
{
size_t len;
char *buf;
int val;
int i;
len = 0;
buf = NULL;
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,
va_str("'%s' != '%s'", buf, testpairs[i].b));
}
@ -53,14 +57,17 @@ START_TEST(test_base32_decode)
{
size_t len;
void *buf;
int val;
int i;
len = 0;
buf = NULL;
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,
va_str("'%s' != '%s'", buf, testpairs[i].a));
}