written some parametric tests, few more to go
This commit is contained in:
parent
06cebc829e
commit
d5e355bf0b
63
test.cpp
63
test.cpp
@ -2,6 +2,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <tuple>
|
||||||
#include "String.h"
|
#include "String.h"
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
@ -54,38 +55,68 @@ TEST(StringTest, uninitializedStringcStrThrows)
|
|||||||
EXPECT_THROW(str.c_str(), std::runtime_error);
|
EXPECT_THROW(str.c_str(), std::runtime_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StringTest, addable)
|
using str3 = std::tuple<const char*, const char*, const char*>;
|
||||||
{
|
class addStringTest : public ::testing::TestWithParam<str3>
|
||||||
String str1("cica");
|
{};
|
||||||
String str2("sajt");
|
|
||||||
|
|
||||||
EXPECT_STREQ("cicasajt", (str1+str2).c_str());
|
TEST_P(addStringTest, addable)
|
||||||
|
{
|
||||||
|
String str1(std::get<0>(GetParam()));
|
||||||
|
String str2(std::get<1>(GetParam()));
|
||||||
|
|
||||||
|
EXPECT_STREQ(std::get<2>(GetParam()), (str1+str2).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StringTest, plusequalsAddable)
|
TEST_P(addStringTest, plusEqualsable)
|
||||||
{
|
{
|
||||||
String str1("cica");
|
String str1(std::get<0>(GetParam()));
|
||||||
String str2("sajt");
|
String str2(std::get<1>(GetParam()));
|
||||||
str1 += str2;
|
str1 += str2;
|
||||||
|
|
||||||
EXPECT_STREQ("cicasajt", str1.c_str());
|
EXPECT_STREQ(std::get<2>(GetParam()), str1.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StringTest, addableChar)
|
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));
|
||||||
|
|
||||||
|
using strcharstr = std::tuple<const char*, char, const char*>;
|
||||||
|
class addCharStringTest : public ::testing::TestWithParam<strcharstr>
|
||||||
|
{};
|
||||||
|
|
||||||
|
TEST_P(addCharStringTest, addCharable)
|
||||||
{
|
{
|
||||||
String str("cicá");
|
String str(std::get<0>(GetParam()));
|
||||||
|
|
||||||
EXPECT_STREQ("cicák", (str+'k').c_str());
|
EXPECT_STREQ(std::get<2>(GetParam()), (str+std::get<1>(GetParam())).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(StringTest, plusequalsAddableChar)
|
TEST_P(addCharStringTest, plusEqualsCharable)
|
||||||
{
|
{
|
||||||
String str("sajto");
|
String str(std::get<0>(GetParam()));
|
||||||
str+='k';
|
str+=std::get<1>(GetParam());
|
||||||
|
|
||||||
EXPECT_STREQ("sajtok", 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));
|
||||||
|
|
||||||
TEST(StringTest, comparable)
|
TEST(StringTest, comparable)
|
||||||
{
|
{
|
||||||
String str1("cica");
|
String str1("cica");
|
||||||
|
Loading…
Reference in New Issue
Block a user