Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117886087
byteorder64.testc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
643 B
Referenced Files
None
Subscribers
None
byteorder64.testc
View Options
#include "cunit/cunit.h"
#include "byteorder64.h"
static void test_byteorder(void)
{
uint64_t src64;
uint32_t src32;
uint64_t res64;
uint32_t res32;
char buf[8];
buf[0] = 0;
buf[1] = 0;
buf[2] = 0;
buf[3] = 0;
buf[4] = 0;
buf[5] = 0;
buf[6] = 0;
buf[7] = 1;
memcpy(&src64, buf, 8);
memcpy(&src32, buf+4, 4);
/* test 64 bit */
CU_ASSERT_EQUAL(ntohll(src64), 1);
res64 = htonll(1);
CU_ASSERT_EQUAL(memcmp(&res64, &src64, 8), 0);
/* test 32 bit */
CU_ASSERT_EQUAL(ntohl(src32), 1);
res32 = htonl(1);
CU_ASSERT_EQUAL(memcmp(&res32, &src32, 4), 0);
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Mon, Apr 6, 2:23 AM (1 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
27/fd/1e18d5881ccb4c0e90d79bed0f84
Default Alt Text
byteorder64.testc (643 B)
Attached To
Mode
R111 cyrus-imapd
Attached
Detach File
Event Timeline