Skip to content

Commit

Permalink
test endianswap uint/int
Browse files Browse the repository at this point in the history
  • Loading branch information
no-lex committed Oct 24, 2024
1 parent 0ccf5f7 commit f195940
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/testutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,37 @@ namespace
assert(std::strlen(s) == std::strlen(s1) + std::strlen(s2));
}

void test_endianswap()
{
std::printf("Testing endianswap\n");
//int
{
int i = -1;
assert(endianswap(i) == -1);
}
{
int i = 0;
assert(endianswap(i) == 0);
}
{
int i = 32768;
assert(endianswap(i) == 8388608);
}
//uint
{
uint i = 1;
assert(endianswap(i) == 16777216);
}
{
uint i = 0;
assert(endianswap(i) == 0);
}
{
uint i = 32768;
assert(endianswap(i) == 8388608);
}
}

void test_matchstring()
{
std::printf("Testing match string\n");
Expand Down Expand Up @@ -487,6 +518,7 @@ testing tools functionality\n\
test_matchstring();
testparentdir();
testfixpackagedir();
test_endianswap();
test_vector_putint();
test_databuf_putint();
test_databuf_putuint();
Expand Down

0 comments on commit f195940

Please sign in to comment.