made test.cpp format more reasonable
This commit is contained in:
parent
d5e355bf0b
commit
80f0c71445
72
test.cpp
72
test.cpp
@ -7,7 +7,46 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
/// Testing helper classes ///
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
using str3 = std::tuple<const char*, const char*, const char*>;
|
||||||
|
class addStringTest : public ::testing::TestWithParam<str3>
|
||||||
|
{};
|
||||||
|
|
||||||
|
using strcharstr = std::tuple<const char*, char, const char*>;
|
||||||
|
class addCharStringTest : public ::testing::TestWithParam<strcharstr>
|
||||||
|
{};
|
||||||
|
|
||||||
|
struct StreamStringTest : public ::testing::Test
|
||||||
|
{
|
||||||
|
std::stringstream _stream;
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
/// Testing data ///
|
||||||
|
///////////////////////////////////////////////////////////////
|
||||||
|
static const std::vector<str3> 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<strcharstr> 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)
|
TEST(StringTest, defaultConstructible)
|
||||||
{
|
{
|
||||||
EXPECT_TRUE(std::is_default_constructible<String>::value);
|
EXPECT_TRUE(std::is_default_constructible<String>::value);
|
||||||
@ -55,10 +94,6 @@ TEST(StringTest, uninitializedStringcStrThrows)
|
|||||||
EXPECT_THROW(str.c_str(), std::runtime_error);
|
EXPECT_THROW(str.c_str(), std::runtime_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
using str3 = std::tuple<const char*, const char*, const char*>;
|
|
||||||
class addStringTest : public ::testing::TestWithParam<str3>
|
|
||||||
{};
|
|
||||||
|
|
||||||
TEST_P(addStringTest, addable)
|
TEST_P(addStringTest, addable)
|
||||||
{
|
{
|
||||||
String str1(std::get<0>(GetParam()));
|
String str1(std::get<0>(GetParam()));
|
||||||
@ -75,22 +110,8 @@ TEST_P(addStringTest, plusEqualsable)
|
|||||||
|
|
||||||
EXPECT_STREQ(std::get<2>(GetParam()), str1.c_str());
|
EXPECT_STREQ(std::get<2>(GetParam()), str1.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
static const std::vector<str3> 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));
|
INSTANTIATE_TEST_CASE_P(testGroup1, addStringTest, ::testing::ValuesIn(testvalues1));
|
||||||
|
|
||||||
using strcharstr = std::tuple<const char*, char, const char*>;
|
|
||||||
class addCharStringTest : public ::testing::TestWithParam<strcharstr>
|
|
||||||
{};
|
|
||||||
|
|
||||||
TEST_P(addCharStringTest, addCharable)
|
TEST_P(addCharStringTest, addCharable)
|
||||||
{
|
{
|
||||||
String str(std::get<0>(GetParam()));
|
String str(std::get<0>(GetParam()));
|
||||||
@ -105,16 +126,6 @@ TEST_P(addCharStringTest, plusEqualsCharable)
|
|||||||
|
|
||||||
EXPECT_STREQ(std::get<2>(GetParam()), str.c_str());
|
EXPECT_STREQ(std::get<2>(GetParam()), str.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
static const std::vector<strcharstr> 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));
|
INSTANTIATE_TEST_CASE_P(testGroup1, addCharStringTest, ::testing::ValuesIn(testvalues2));
|
||||||
|
|
||||||
TEST(StringTest, comparable)
|
TEST(StringTest, comparable)
|
||||||
@ -172,11 +183,6 @@ TEST(StringTest, resourceSharingWorks)
|
|||||||
EXPECT_EQ(str1.c_str(), str2.c_str());
|
EXPECT_EQ(str1.c_str(), str2.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
struct StreamStringTest : public ::testing::Test
|
|
||||||
{
|
|
||||||
std::stringstream _stream;
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(StreamStringTest, ostreamOperatorWorks)
|
TEST_F(StreamStringTest, ostreamOperatorWorks)
|
||||||
{
|
{
|
||||||
String str("cica");
|
String str("cica");
|
||||||
|
Loading…
Reference in New Issue
Block a user