| 31 | |
| 32 | Y_UNIT_TEST_SUITE(UnalignedMem) { |
| 33 | Y_UNIT_TEST(TestReadWrite) { |
| 34 | alignas(ui64) char buf[100]; |
| 35 | |
| 36 | WriteUnaligned<ui16>(buf + 1, (ui16)1); |
| 37 | WriteUnaligned<ui32>(buf + 1 + 2, (ui32)2); |
| 38 | WriteUnaligned<ui64>(buf + 1 + 2 + 4, (ui64)3); |
| 39 | |
| 40 | UNIT_ASSERT_VALUES_EQUAL(ReadUnaligned<ui16>(buf + 1), 1); |
| 41 | UNIT_ASSERT_VALUES_EQUAL(ReadUnaligned<ui32>(buf + 1 + 2), 2); |
| 42 | UNIT_ASSERT_VALUES_EQUAL(ReadUnaligned<ui64>(buf + 1 + 2 + 4), 3); |
| 43 | } |
| 44 | |
| 45 | Y_UNIT_TEST(TestReadWriteRuntime) { |
| 46 | // Unlike the test above, this test avoids compile-time execution by a smart compiler. |