diff --git a/test.cpp b/test.cpp index 5fe251f..612946f 100644 --- a/test.cpp +++ b/test.cpp @@ -7,7 +7,46 @@ #include +/////////////////////////////////////////////////////////////// +/// Testing helper classes /// +/////////////////////////////////////////////////////////////// +using str3 = std::tuple; +class addStringTest : public ::testing::TestWithParam +{}; +using strcharstr = std::tuple; +class addCharStringTest : public ::testing::TestWithParam +{}; + +struct StreamStringTest : public ::testing::Test +{ + std::stringstream _stream; +}; + +/////////////////////////////////////////////////////////////// +/// Testing data /// +/////////////////////////////////////////////////////////////// +static const std::vector testvalues1 = + { + std::make_tuple("cica", "sajt", "cicasajt"), + std::make_tuple("sajtos", " cica", "sajtos cica"), + std::make_tuple("szeretem", " a sajtot", "szeretem a sajtot"), + std::make_tuple("meg ", "a cicákat", "meg a cicákat"), + std::make_tuple("ennyi már ", "elég lesz", "ennyi már elég lesz") + }; + +static const std::vector testvalues2 = + { + std::make_tuple("cicá", 'k', "cicák"), + std::make_tuple("sajto", 'k', "sajtok"), + std::make_tuple("C++1", '1', "C++11"), + std::make_tuple("sö", 'r', "sör"), + std::make_tuple("te", 'j', "tej") + }; + +/////////////////////////////////////////////////////////////// +/// Tests /// +/////////////////////////////////////////////////////////////// TEST(StringTest, defaultConstructible) { EXPECT_TRUE(std::is_default_constructible::value); @@ -55,10 +94,6 @@ TEST(StringTest, uninitializedStringcStrThrows) EXPECT_THROW(str.c_str(), std::runtime_error); } -using str3 = std::tuple; -class addStringTest : public ::testing::TestWithParam -{}; - TEST_P(addStringTest, addable) { String str1(std::get<0>(GetParam())); @@ -75,22 +110,8 @@ TEST_P(addStringTest, plusEqualsable) EXPECT_STREQ(std::get<2>(GetParam()), str1.c_str()); } - -static const std::vector testvalues1 = - { - std::make_tuple("cica", "sajt", "cicasajt"), - std::make_tuple("sajtos", " cica", "sajtos cica"), - std::make_tuple("szeretem", " a sajtot", "szeretem a sajtot"), - std::make_tuple("meg ", "a cicákat", "meg a cicákat"), - std::make_tuple("ennyi már ", "elég lesz", "ennyi már elég lesz") - }; - INSTANTIATE_TEST_CASE_P(testGroup1, addStringTest, ::testing::ValuesIn(testvalues1)); -using strcharstr = std::tuple; -class addCharStringTest : public ::testing::TestWithParam -{}; - TEST_P(addCharStringTest, addCharable) { String str(std::get<0>(GetParam())); @@ -105,16 +126,6 @@ TEST_P(addCharStringTest, plusEqualsCharable) EXPECT_STREQ(std::get<2>(GetParam()), str.c_str()); } - -static const std::vector testvalues2 = - { - std::make_tuple("cicá", 'k', "cicák"), - std::make_tuple("sajto", 'k', "sajtok"), - std::make_tuple("C++1", '1', "C++11"), - std::make_tuple("sö", 'r', "sör"), - std::make_tuple("te", 'j', "tej") - }; - INSTANTIATE_TEST_CASE_P(testGroup1, addCharStringTest, ::testing::ValuesIn(testvalues2)); TEST(StringTest, comparable) @@ -172,11 +183,6 @@ TEST(StringTest, resourceSharingWorks) EXPECT_EQ(str1.c_str(), str2.c_str()); } -struct StreamStringTest : public ::testing::Test -{ - std::stringstream _stream; -}; - TEST_F(StreamStringTest, ostreamOperatorWorks) { String str("cica");