aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/align_ut.cpp
blob: 3ba3a3442b9b73e56beac9b8546451d68cb9167b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "align.h"

#include <library/cpp/testing/unittest/registar.h>

class TAlignTest: public TTestBase {
    UNIT_TEST_SUITE(TAlignTest);
    UNIT_TEST(TestDown)
    UNIT_TEST(TestUp)
    UNIT_TEST_SUITE_END();

private:
    inline void TestDown() {
        UNIT_ASSERT(AlignDown(0, 4) == 0);
        UNIT_ASSERT(AlignDown(1, 4) == 0);
        UNIT_ASSERT(AlignDown(2, 4) == 0);
        UNIT_ASSERT(AlignDown(3, 4) == 0);
        UNIT_ASSERT(AlignDown(4, 4) == 4);
        UNIT_ASSERT(AlignDown(5, 4) == 4);
        UNIT_ASSERT(AlignDown(0, 8) == 0);
        UNIT_ASSERT(AlignDown(1, 8) == 0);
    }

    inline void TestUp() {
        UNIT_ASSERT(AlignUp(0, 4) == 0);
        UNIT_ASSERT(AlignUp(1, 4) == 4);
        UNIT_ASSERT(AlignUp(2, 4) == 4);
        UNIT_ASSERT(AlignUp(3, 4) == 4);
        UNIT_ASSERT(AlignUp(4, 4) == 4);
        UNIT_ASSERT(AlignUp(5, 4) == 8);
        UNIT_ASSERT(AlignUp(0, 8) == 0);
        UNIT_ASSERT(AlignUp(1, 8) == 8);
    }
};

UNIT_TEST_SUITE_REGISTRATION(TAlignTest);