Skip to content

Commit

Permalink
test(byteswap): adding deeper unit testing
Browse files Browse the repository at this point in the history
Found a glitch during ESP-IDF testing
  • Loading branch information
malachib committed Jan 3, 2025
1 parent 1461b33 commit eea4016
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/arduino/unity/test/test_embedded/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void setup()
test_avr_pgm();
#endif
test_bipbuf();
test_bit();
test_chrono();
test_cpp();
test_cstddef();
Expand Down
4 changes: 4 additions & 0 deletions test/catch/bit-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ TEST_CASE("bit operations")
auto v = estd::byteswap<int32_t>(0x1234);

REQUIRE(v == 0x34120000);

auto v1 = estd::byteswap<int32_t>(-500);

REQUIRE(estd::byteswap(v1) == -500);
}
}
}
16 changes: 16 additions & 0 deletions test/unity/bit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <estd/bit.h>

#include "unit-test.h"

#ifdef ESP_IDF_TESTING
TEST_CASE("bit/endian tests", "[bit]")
#else
void test_bit()
#endif
{
auto vu16 = estd::byteswap<uint16_t>(0x1234);
auto vi32 = estd::byteswap<int32_t>(-500);

TEST_ASSERT_EQUAL(0x3421, vu16);
TEST_ASSERT_EQUAL(-500, estd::byteswap(vi32));
}
1 change: 1 addition & 0 deletions test/unity/unit-test.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void test_align();
void test_array();
void test_avr_pgm();
void test_bipbuf();
void test_bit();
void test_cpp();
void test_chrono();
void test_cstddef();
Expand Down

0 comments on commit eea4016

Please sign in to comment.