mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-29 16:36:03 +03:00
put/getlong fixed
This commit is contained in:
parent
7368bcaff7
commit
8babf3f1a6
34
tests/read.c
34
tests/read.c
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user