aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/string/unittests/string_ut.cpp
blob: 3e12312af0b7ec9ebd737d10122f8fc596be9f4b (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
43
44
45
46
47
48
49
50
51
52
#include <library/cpp/testing/gtest/gtest.h>

#include <library/cpp/yt/string/string.h>

namespace NYT {
namespace {

////////////////////////////////////////////////////////////////////////////////

struct TTestCase
{
    const char* UnderCase;
    const char* CamelCase;
};

static std::vector<TTestCase> TestCases {
    { "kenny", "Kenny" },
    { "south_park", "SouthPark" },
    { "a", "A" },
    { "a_b_c", "ABC" },
    { "reed_solomon_6_3", "ReedSolomon_6_3" },
    { "lrc_12_2_2", "Lrc_12_2_2" },
    { "0", "0" },
    { "0_1_2", "0_1_2" },
    { "int64", "Int64" }
};

////////////////////////////////////////////////////////////////////////////////

TEST(TStringTest, UnderscoreCaseToCamelCase)
{
    for (const auto& testCase : TestCases) {
        auto result = UnderscoreCaseToCamelCase(testCase.UnderCase);
        EXPECT_STREQ(testCase.CamelCase, result.c_str())
            << "Original: \"" << testCase.UnderCase << '"';
    }
}

TEST(TStringTest, CamelCaseToUnderscoreCase)
{
    for (const auto& testCase : TestCases) {
        auto result = CamelCaseToUnderscoreCase(testCase.CamelCase);
        EXPECT_STREQ(testCase.UnderCase, result.c_str())
            << "Original: \"" << testCase.CamelCase << '"';
    }
}

////////////////////////////////////////////////////////////////////////////////

} // namespace
} // namespace NYT