align_ut.cpp 1012 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "align.h"
  2. #include <library/cpp/testing/unittest/registar.h>
  3. class TAlignTest: public TTestBase {
  4. UNIT_TEST_SUITE(TAlignTest);
  5. UNIT_TEST(TestDown)
  6. UNIT_TEST(TestUp)
  7. UNIT_TEST_SUITE_END();
  8. private:
  9. inline void TestDown() {
  10. UNIT_ASSERT(AlignDown(0, 4) == 0);
  11. UNIT_ASSERT(AlignDown(1, 4) == 0);
  12. UNIT_ASSERT(AlignDown(2, 4) == 0);
  13. UNIT_ASSERT(AlignDown(3, 4) == 0);
  14. UNIT_ASSERT(AlignDown(4, 4) == 4);
  15. UNIT_ASSERT(AlignDown(5, 4) == 4);
  16. UNIT_ASSERT(AlignDown(0, 8) == 0);
  17. UNIT_ASSERT(AlignDown(1, 8) == 0);
  18. }
  19. inline void TestUp() {
  20. UNIT_ASSERT(AlignUp(0, 4) == 0);
  21. UNIT_ASSERT(AlignUp(1, 4) == 4);
  22. UNIT_ASSERT(AlignUp(2, 4) == 4);
  23. UNIT_ASSERT(AlignUp(3, 4) == 4);
  24. UNIT_ASSERT(AlignUp(4, 4) == 4);
  25. UNIT_ASSERT(AlignUp(5, 4) == 8);
  26. UNIT_ASSERT(AlignUp(0, 8) == 0);
  27. UNIT_ASSERT(AlignUp(1, 8) == 8);
  28. }
  29. };
  30. UNIT_TEST_SUITE_REGISTRATION(TAlignTest);