[util] Use simple unit test suite.
#include <library/unittest/registar.h>
-class TUtilityTest: public TTestBase {
- UNIT_TEST_SUITE(TUtilityTest);
- UNIT_TEST(TestSwapPrimitive)
- UNIT_TEST(TestSwapClass)
- UNIT_TEST(TestMaxMin)
- UNIT_TEST(TestMean)
- UNIT_TEST(TestZeroInitWithDefaultZeros)
- UNIT_TEST(TestZeroInitWithDefaultNonZeros)
- UNIT_TEST_SUITE_END();
-
class TTest {
public:
inline TTest(int val)
@@ -31,8 +21,10 @@ class TUtilityTest: public TTestBase {
TTest& operator=(const TTest&);
};
-private:
- inline void TestSwapPrimitive() {
+
+SIMPLE_UNIT_TEST_SUITE(TUtilityTest) {
+
+ SIMPLE_UNIT_TEST(TestSwapPrimitive) {
int i = 0;
int j = 1;
@@ -42,7 +34,7 @@ private:
UNIT_ASSERT_EQUAL(j, 0);
}
- inline void TestSwapClass() {
+ SIMPLE_UNIT_TEST(TestSwapClass) {
TTest i(0);
TTest j(1);
@@ -52,14 +44,14 @@ private:
UNIT_ASSERT_EQUAL(j.Val, 0);
}
- inline void TestMaxMin() {
+ SIMPLE_UNIT_TEST(TestMaxMin) {
static_assert(Min(10, 3, 8) == 3, "Min doesn't work");
static_assert(Max(10, 3, 8) == 10, "Max doesn't work");
UNIT_ASSERT_EQUAL(Min(10, 3, 8), 3);
UNIT_ASSERT_EQUAL(Max(3.5, 4.2, 8.1, 99.025, 0.33, 29.0), 99.025);
}
- inline void TestMean() {
+ SIMPLE_UNIT_TEST(TestMean) {
UNIT_ASSERT_EQUAL(Mean(5), 5);
UNIT_ASSERT_EQUAL(Mean(1, 2, 3), 2);
UNIT_ASSERT_EQUAL(Mean(6, 5, 4), 5);
@@ -67,7 +59,7 @@ private:
UNIT_ASSERT(Abs(Mean(1., 2., 7.5) - 3.5) < std::numeric_limits<double>::epsilon());
}
- inline void TestZeroInitWithDefaultZeros() {
+ SIMPLE_UNIT_TEST(TestZeroInitWithDefaultZeros) {
struct TStructWithPaddingBytes : public TZeroInit<TStructWithPaddingBytes> {
bool Field1_ = static_cast<bool>(0);
// here between Field1_ and Field2_ will be padding bytes
@@ -84,7 +76,7 @@ private:
}
}
- inline void TestZeroInitWithDefaultNonZeros() {
+ SIMPLE_UNIT_TEST(TestZeroInitWithDefaultNonZeros) {
struct TStructWithPaddingBytes : public TZeroInit<TStructWithPaddingBytes> {
bool Field1_ = true;
// here between Field1_ and Field2_ will be padding bytes
@@ -105,5 +97,3 @@ private:
}
}
};
-
-UNIT_TEST_SUITE_REGISTRATION(TUtilityTest);
