byteorder_ut.cpp 652 B

1234567891011121314151617181920212223242526
  1. #include "byteorder.h"
  2. #include <library/cpp/testing/unittest/registar.h>
  3. class TByteOrderTest: public TTestBase {
  4. UNIT_TEST_SUITE(TByteOrderTest);
  5. UNIT_TEST(TestSwap16)
  6. UNIT_TEST(TestSwap32)
  7. UNIT_TEST(TestSwap64)
  8. UNIT_TEST_SUITE_END();
  9. private:
  10. inline void TestSwap16() {
  11. UNIT_ASSERT_EQUAL((ui16)0x1234, SwapBytes((ui16)0x3412));
  12. }
  13. inline void TestSwap32() {
  14. UNIT_ASSERT_EQUAL(0x12345678, SwapBytes(0x78563412));
  15. }
  16. inline void TestSwap64() {
  17. UNIT_ASSERT_EQUAL(0x1234567890abcdefULL, SwapBytes((ui64)ULL(0xefcdab9078563412)));
  18. }
  19. };
  20. UNIT_TEST_SUITE_REGISTRATION(TByteOrderTest);