aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/protobuf/json/ut/util_ut.cpp
blob: 05101dca28fb6d82cf1047006439d5aaa2fb10c6 (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
36
37
38
39
40
41
42
#include <library/cpp/protobuf/json/util.h>

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

using namespace NProtobufJson;

Y_UNIT_TEST_SUITE(TEqualsTest) {
    Y_UNIT_TEST(TestEmpty) {
        UNIT_ASSERT(EqualsIgnoringCaseAndUnderscores("", ""));
        UNIT_ASSERT(EqualsIgnoringCaseAndUnderscores("", "_"));
        UNIT_ASSERT(!EqualsIgnoringCaseAndUnderscores("f", ""));
    }

    Y_UNIT_TEST(TestTrivial) {
        UNIT_ASSERT(EqualsIgnoringCaseAndUnderscores("f", "f"));
        UNIT_ASSERT(!EqualsIgnoringCaseAndUnderscores("f", "o"));
        UNIT_ASSERT(!EqualsIgnoringCaseAndUnderscores("fo", "f"));
        UNIT_ASSERT(!EqualsIgnoringCaseAndUnderscores("f", "fo"));
        UNIT_ASSERT(!EqualsIgnoringCaseAndUnderscores("bar", "baz"));
    }

    Y_UNIT_TEST(TestUnderscores) {
        UNIT_ASSERT(EqualsIgnoringCaseAndUnderscores("foo_bar", "foobar"));
        UNIT_ASSERT(EqualsIgnoringCaseAndUnderscores("foo_bar_", "foobar"));
        UNIT_ASSERT(!EqualsIgnoringCaseAndUnderscores("foo_bar_z", "foobar"));
        UNIT_ASSERT(EqualsIgnoringCaseAndUnderscores("foo__bar__", "foobar"));
        UNIT_ASSERT(!EqualsIgnoringCaseAndUnderscores("foo__bar__z", "foobar"));
        UNIT_ASSERT(EqualsIgnoringCaseAndUnderscores("_foo_bar", "foobar"));
        UNIT_ASSERT(EqualsIgnoringCaseAndUnderscores("_foo_bar_", "foobar"));
        UNIT_ASSERT(EqualsIgnoringCaseAndUnderscores("_foo_bar_", "foo___bar"));
    }

    Y_UNIT_TEST(TestCase) {
        UNIT_ASSERT(EqualsIgnoringCaseAndUnderscores("foo_bar", "FOO_BAR"));
        UNIT_ASSERT(EqualsIgnoringCaseAndUnderscores("foobar", "fooBar"));
    }

    Y_UNIT_TEST(TestCaseAndUnderscores) {
        UNIT_ASSERT(EqualsIgnoringCaseAndUnderscores("fooBar", "FOO_BAR"));
        UNIT_ASSERT(EqualsIgnoringCaseAndUnderscores("FOO_BAR_BAZ", "fooBar_BAZ"));
    }
}