put/getlong fixed

This commit is contained in:
Bjorn Andersson 2007-01-28 02:52:19 +00:00
parent 7368bcaff7
commit 8babf3f1a6

View File

@ -59,34 +59,26 @@ END_TEST
START_TEST(test_read_putlong) START_TEST(test_read_putlong)
{ {
char buf[4]; uint32_t k;
uint32_t putint; uint32_t l;
uint32_t tempi;
uint32_t tint;
uint32_t *l;
char* p; char* p;
int i; int i;
int j;
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
tint = 0xF << i; p = (char*)&k;
tempi = htonl(tint); j = 0xf << i;
p = buf;
putlong(&p, tint);
l = &putint;
memcpy(l, buf, sizeof(uint32_t));
fail_unless(putint == tempi, putlong(&p, j);
va_str("Bad value on putlong for %d: %d != %d",
i, putint, tempi));
l = &tempi; fail_unless(ntohl(k) == j,
memcpy(buf, l, sizeof(uint32_t)); va_str("Bad value on putlong for %d: %d != %d", i, ntohl(j), j));
p = buf;
readlong(NULL, &p, &tempi);
fail_unless(tempi == tint, p = (char*)&k;
va_str("Bad value on readlong for %d: %d != %d", readlong(NULL, &p, &l);
i, tempi, tint));
fail_unless(l == j,
va_str("Bad value on readlong for %d: %d != %d", i, l, j));
} }
} }
END_TEST END_TEST