aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/codecs/static/ut/static_ut.cpp
blob: ae11e2f2d245125c7c6f58d91b4d799ec2bdb989 (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
#include <library/cpp/testing/unittest/registar.h>
#include <library/cpp/codecs/static/example/example.h>

class TStaticCodecUsageTest: public NUnitTest::TTestBase {
    UNIT_TEST_SUITE(TStaticCodecUsageTest)
    UNIT_TEST(TestUsage)
    UNIT_TEST_SUITE_END();

private:
    void DoTestUsage(NStaticCodecExample::EDictVersion dv, size_t expectedSize) {
        const TStringBuf letov = "Всё идёт по плану";

        TBuffer outEnc, outDec;
        NStaticCodecExample::Encode(outEnc, letov, dv);
        NStaticCodecExample::Decode(outDec, TStringBuf{outEnc.data(), outEnc.size()}); 

        UNIT_ASSERT_VALUES_EQUAL(outEnc.Size(), expectedSize);
        UNIT_ASSERT_EQUAL(TStringBuf(outDec.data(), outDec.size()), letov); 
    }

    void TestUsage() {
        DoTestUsage(NStaticCodecExample::DV_HUFF_20160707, 18u);
        DoTestUsage(NStaticCodecExample::DV_SA_HUFF_20160707, 22u);
    }
};

UNIT_TEST_SUITE_REGISTRATION(TStaticCodecUsageTest)