#include "gtest/gtest.h" #include "pistring.h" #include "pistringlist.h" #include "math.h" using namespace std; template bool is_equal(T x, T y) { return std::fabs(x - y) < std::numeric_limits::epsilon(); } TEST(PIString_Tests, constructor_empty){ PIString str1; ASSERT_TRUE(str1.isEmpty()); } TEST(PIString_Tests, operator_concatenation_pichar){ PIString str1 = "AB C"; const PIChar str2 = " "; str1 += str2; PIString res = "AB C "; ASSERT_EQ(str1, res); } TEST(PIString_Tests, operator_concatenation_pichar_zero1){ PIString str1 = ""; const PIChar str2 = "D"; str1 += str2; ASSERT_EQ(str1, "D"); } TEST(PIString_Tests, operator_concatenation_cstring){ PIString str1 = "AB C"; const char *str2 = "D D "; str1 += str2; ASSERT_EQ(str1, "AB CD D "); } TEST(PIString_Tests, operator_concatenation_cstring_zero1){ PIString str1 = ""; const char *str2 = "D D "; str1 += str2; ASSERT_EQ(str1, "D D "); } TEST(PIString_Tests, operator_concatenation_wchar){ PIString str1= "AB C"; wchar_t str2[] = L"C"; str1 += str2; ASSERT_EQ(str1, "AB CC"); } TEST(PIString_Tests, operator_concatenation_wchar_zero1){ PIString str1 = ""; wchar_t str2[] = L"C"; str1 += str2; ASSERT_EQ(str1, "C"); } TEST(PIString_Tests, operator_concatenation_pistring){ PIString str1 = "AB C"; PIString str2 = " CD "; str1 += str2; ASSERT_EQ(str1, "AB C CD "); } TEST(PIString_Tests, operator_concatenation_pistring_zero1){ PIString str1 = ""; PIString str2 = "D DD"; str1 += str2; ASSERT_EQ(str1, "D DD"); } TEST(PIString_Tests, operator_concatenation_pistring_zero2){ PIString str1 = "AB C"; PIString str2 = ""; str1 += str2; ASSERT_EQ(str1, "AB C"); } TEST(PIString_Tests, operator_concatenation_pistring_zero_zero){ PIString str1; PIString str2; str1 += str2; ASSERT_EQ(str1, ""); } TEST(PIString_Tests, operator_concatenation_piByteArray){ PIString str1 = "AB C"; PIByteArray str2; str2.append('g'); str1 += str2; ASSERT_EQ(str1, "AB Cg"); } TEST(PIString_Tests, operator_concatenation_piByteArray_zero1){ PIString str1 = ""; PIByteArray str2; str2.append('0'); str1 += str2; ASSERT_EQ(str1, "0"); } TEST(PIString_Tests, operator_concatenation_piByteArray_zero2){ PIString str1 = "AB C"; PIByteArray str2; str1 += str2; ASSERT_EQ(str1, "AB C"); } TEST(PIString_Tests, operator_concatenation_piByteArray_zero_zero){ PIString str1; PIByteArray str2; str1 += str2; ASSERT_EQ(str1, ""); } TEST(PIString_Tests, construct_pistring){ PIString str1 = "New"; PIString str(str1); ASSERT_EQ(str1, str); } TEST(PIString_Tests, construct_pistring_move){ PIString str1 = "New"; PIString res = str1; PIString str(move(str1)); ASSERT_EQ(res, str); } TEST(PIString_Tests, construct_from_pichar){ PIChar str1 = 'n'; PIString res = "n"; ASSERT_EQ(res, PIString(str1)); } TEST(PIString_Tests, construct_from_char){ char str1 = 'n'; PIString res = "n"; ASSERT_EQ(res, PIString(str1)); } TEST(PIString_Tests, construct_from_cstring){ char str1[] = "mew"; PIString res = "mew"; ASSERT_EQ(res, PIString(str1)); }