diff --git a/.gitignore b/.gitignore index 22cc44b5..0191619d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ /.svn /doc/rtf _unsused -CMakeLists.txt.user \ No newline at end of file +*.user* \ No newline at end of file diff --git a/tests/core/pistringTest.cpp b/tests/core/pistringTest.cpp index 26f5c97f..900b2cfd 100644 --- a/tests/core/pistringTest.cpp +++ b/tests/core/pistringTest.cpp @@ -46,20 +46,6 @@ TEST(PIString_Tests, operator_concatenation_char_zero1){ ASSERT_STREQ(str1, "D D "); } -TEST(PIString_Tests, operator_concatenation_char_zero2){ - PIString str1 = "AB C"; - const char *str2; - str1 += str2; - ASSERT_STREQ(str1, "AB C"); -} - -TEST(PIString_Tests, operator_concatenation_char_zero_zero){ - PIString str1; - const char *str2; - str1 += str2; - ASSERT_STREQ(str1, ""); -} - TEST(PIString_Tests, operator_concatenation_wchar){ PIString str1= "AB C"; wchar_t str2[] = L"C"; @@ -74,20 +60,6 @@ TEST(PIString_Tests, operator_concatenation_wchar_zero1){ ASSERT_STREQ(str1, "C"); } -TEST(PIString_Tests, operator_concatenation_wchar_zero2){ - PIString str1 = "AB C"; - wchar_t *str2; - str1 += str2; - ASSERT_STREQ(str1, "AB C"); -} - -TEST(PIString_Tests, operator_concatenation_wchar_zero_zero){ - PIString str1; - wchar_t *str2; - str1 += str2; - ASSERT_STREQ(str1, ""); -} - TEST(PIString_Tests, operator_concatenation_pistring){ PIString str1 = "AB C"; PIString str2 = " CD "; @@ -1287,6 +1259,13 @@ TEST(PIString_Tests, split){ ASSERT_STREQ(list[1], list[0]); } +TEST(PIString_Tests, split_sec){ + PIString str1 = " mirrow best detail "; + PIStringList list = str1.split("best"); + ASSERT_STREQ(" mirrow ", list[0]); + ASSERT_STREQ(list[1], " detail "); +} + TEST(PIString_Tests, split_empty){ PIString str1 = ""; PIStringList list = str1.split("best"); @@ -1568,52 +1547,51 @@ TEST(PIString_Tests, find_range){ PIString str1 = "A very strong programmer wrote this code"; PIChar start = "v"; PIChar end = "g"; - int *len; - ASSERT_EQ(3, str1.findRange(start, end, "n", 1, len)); + ASSERT_EQ(3, str1.findRange(start, end, "n", 1)); } TEST(PIString_Tests, find_range_len){ PIString str1 = "A very strong programmer wrote this code"; PIChar start = "v"; PIChar end = "g"; - int *len; - str1.findRange(start, end, "n", 1, len); - ASSERT_EQ(14, *len); + int len; + str1.findRange(start, end, "n", 1, &len); + ASSERT_EQ(14, len); } TEST(PIString_Tests, find_range_len_without_shield){ PIString str1 = "A very strong programmer wrote this code"; PIChar start = "v"; PIChar end = "g"; - int *len; - str1.findRange(start, end, "/", 1, len); - ASSERT_EQ(9, *len); + int len; + str1.findRange(start, end, "/", 1, &len); + ASSERT_EQ(9, len); } TEST(PIString_Tests, find_range_start){ PIString str1 = "A very strong programmer wrote this code"; PIChar start = "g"; PIChar end = "o"; - int *len; - str1.findRange(start, end, " ", 17, len); - ASSERT_EQ(9, *len); + int len; + str1.findRange(start, end, " ", 17, &len); + ASSERT_EQ(9, len); } TEST(PIString_Tests, find_range_eq){ PIString str1 = "A very strong programmer wrote this code"; PIChar start = "v"; PIChar end = "v"; - int *len; - str1.findRange(start, end, "n", 1, len); - ASSERT_EQ(0, *len); + int len; + str1.findRange(start, end, "n", 1, &len); + ASSERT_EQ(0, len); } TEST(PIString_Tests, find_range_trim){ PIString str1 = " A very strong programmer wrote this code"; PIChar start = "A"; PIChar end = "v"; - int *len; - ASSERT_EQ(2, str1.findRange(start, end, "n", 0, len)); + int len; + ASSERT_EQ(2, str1.findRange(start, end, "n", 0, &len)); } TEST(PIString_Tests, find_any){ @@ -1776,22 +1754,22 @@ TEST(PIString_Tests, to_short_0x){ TEST(PIString_Tests, to_short_false){ PIString str1 = "0x133"; - bool *ok; - str1.toShort(1, ok); - ASSERT_FALSE(*ok); + bool ok; + str1.toShort(1, &ok); + ASSERT_FALSE(ok); } TEST(PIString_Tests, to_short_false_base){ PIString str1 = "7"; - bool *ok; - str1.toShort(6, ok); - ASSERT_FALSE(*ok); + bool ok; + str1.toShort(6, &ok); + ASSERT_FALSE(ok); } TEST(PIString_Tests, to_short_neg){ PIString str1 = "-7"; - bool *ok; - ASSERT_EQ(-7, str1.toShort(10, ok)); + bool ok; + ASSERT_EQ(-7, str1.toShort(10, &ok)); } TEST(PIString_Tests, to_ushort){ @@ -1806,22 +1784,22 @@ TEST(PIString_Tests, to_ushort_0x){ TEST(PIString_Tests, to_ushort_false){ PIString str1 = "0x133"; - bool *ok; - str1.toUShort(1, ok); - ASSERT_FALSE(*ok); + bool ok; + str1.toUShort(1, &ok); + ASSERT_FALSE(ok); } TEST(PIString_Tests, to_ushort_false_base){ PIString str1 = "7"; - bool *ok; - str1.toUShort(6, ok); - ASSERT_FALSE(*ok); + bool ok; + str1.toUShort(6, &ok); + ASSERT_FALSE(ok); } TEST(PIString_Tests, to_ushort_neg){ PIString str1 = "-7"; - bool *ok; - ASSERT_EQ(65529, str1.toUShort(10, ok)); + bool ok; + ASSERT_EQ(65529, str1.toUShort(10, &ok)); } TEST(PIString_Tests, to_int){ @@ -1836,22 +1814,22 @@ TEST(PIString_Tests, to_int_0x){ TEST(PIString_Tests, to_int_false){ PIString str1 = "0x133"; - bool *ok; - str1.toInt(1, ok); - ASSERT_FALSE(*ok); + bool ok; + str1.toInt(1, &ok); + ASSERT_FALSE(ok); } TEST(PIString_Tests, to_int_false_base){ PIString str1 = "7"; - bool *ok; - str1.toInt(6, ok); - ASSERT_FALSE(*ok); + bool ok; + str1.toInt(6, &ok); + ASSERT_FALSE(ok); } TEST(PIString_Tests, to_int_neg){ PIString str1 = "-7"; - bool *ok; - ASSERT_EQ(-7, str1.toShort(10, ok)); + bool ok; + ASSERT_EQ(-7, str1.toShort(10, &ok)); } TEST(PIString_Tests, to_uint){ @@ -1866,22 +1844,22 @@ TEST(PIString_Tests, to_uint_0x){ TEST(PIString_Tests, to_uint_false){ PIString str1 = "0x133"; - bool *ok; - str1.toUInt(1, ok); - ASSERT_FALSE(*ok); + bool ok; + str1.toUInt(1, &ok); + ASSERT_FALSE(ok); } TEST(PIString_Tests, to_uint_false_base){ PIString str1 = "7"; - bool *ok; - str1.toUInt(6, ok); - ASSERT_FALSE(*ok); + bool ok; + str1.toUInt(6, &ok); + ASSERT_FALSE(ok); } TEST(PIString_Tests, to_uint_neg){ PIString str1 = "-7"; - bool *ok; - ASSERT_EQ(4294967289, str1.toUInt(10, ok)); + bool ok; + ASSERT_EQ(4294967289, str1.toUInt(10, &ok)); } TEST(PIString_Tests, to_long){ @@ -1896,22 +1874,22 @@ TEST(PIString_Tests, to_long_0x){ TEST(PIString_Tests, to_long_false){ PIString str1 = "0x133"; - bool *ok; - str1.toLong(1, ok); - ASSERT_FALSE(*ok); + bool ok; + str1.toLong(1, &ok); + ASSERT_FALSE(ok); } TEST(PIString_Tests, to_long_false_base){ PIString str1 = "7"; - bool *ok; - str1.toLong(6, ok); - ASSERT_FALSE(*ok); + bool ok; + str1.toLong(6, &ok); + ASSERT_FALSE(ok); } TEST(PIString_Tests, to_long_neg){ PIString str1 = "-7"; - bool *ok; - ASSERT_EQ(-7, str1.toLong(10, ok)); + bool ok; + ASSERT_EQ(-7, str1.toLong(10, &ok)); } TEST(PIString_Tests, to_ulong){ @@ -1926,22 +1904,22 @@ TEST(PIString_Tests, to_ulong_0x){ TEST(PIString_Tests, to_ulong_false){ PIString str1 = "0x133"; - bool *ok; - str1.toULong(1, ok); - ASSERT_FALSE(*ok); + bool ok; + str1.toULong(1, &ok); + ASSERT_FALSE(ok); } TEST(PIString_Tests, to_ulong_false_base){ PIString str1 = "7"; - bool *ok; - str1.toULong(6, ok); - ASSERT_FALSE(*ok); + bool ok; + str1.toULong(6, &ok); + ASSERT_FALSE(ok); } TEST(PIString_Tests, to_ulong_neg){ PIString str1 = "-7"; - bool *ok; - ASSERT_EQ(4294967289, str1.toULong(10, ok)); + bool ok; + ASSERT_EQ(4294967289, str1.toULong(10, &ok)); } TEST(PIString_Tests, to_llong){ @@ -1956,22 +1934,22 @@ TEST(PIString_Tests, to_llong_0x){ TEST(PIString_Tests, to_llong_false){ PIString str1 = "0x133"; - bool *ok; - str1.toLLong(1, ok); - ASSERT_FALSE(*ok); + bool ok; + str1.toLLong(1, &ok); + ASSERT_FALSE(ok); } TEST(PIString_Tests, to_llong_false_base){ PIString str1 = "7"; - bool *ok; - str1.toLLong(6, ok); - ASSERT_FALSE(*ok); + bool ok; + str1.toLLong(6, &ok); + ASSERT_FALSE(ok); } TEST(PIString_Tests, to_llong_neg){ PIString str1 = "-7"; - bool *ok; - ASSERT_EQ(-7, str1.toLLong(10, ok)); + bool ok; + ASSERT_EQ(-7, str1.toLLong(10, &ok)); } TEST(PIString_Tests, to_ullong){ @@ -1986,23 +1964,16 @@ TEST(PIString_Tests, to_ullong_0x){ TEST(PIString_Tests, to_ullong_false){ PIString str1 = "0x133"; - bool *ok; - str1.toULLong(1, ok); - ASSERT_FALSE(*ok); + bool ok; + str1.toULLong(1, &ok); + ASSERT_FALSE(ok); } TEST(PIString_Tests, to_ullong_false_base){ PIString str1 = "7"; - bool *ok; - str1.toULLong(6, ok); - ASSERT_FALSE(*ok); -} - -TEST(PIString_Tests, to_ullong_neg){ - PIString str1 = "-7"; - bool *ok; - ullong f = 184467451609; - ASSERT_EQ(f, str1.toULLong(10, ok)); + bool ok; + str1.toULLong(6, &ok); + ASSERT_FALSE(ok); } TEST(PIString_Tests, to_float){ @@ -2964,17 +2935,16 @@ TEST(PIString_Tests, operator_plus_chars_pstr){ ASSERT_STREQ("second first", str2 + str1); } -TEST(PIString_Tests, versionCompare2){ //дописать +TEST(PIString_Tests, versionCompare2){ //дописать PIString str1 = "first"; PIString str2 = "first 1"; versionCompare(str1, str2, 0); ASSERT_EQ(898448032, piHash(str1)); } -TEST(PIString_Tests, versionNormalize2){ //дописать - PIString str1 = "first"; - cout << versionNormalize(str1); - ASSERT_EQ(1, 1); +TEST(PIString_Tests, versionNormalize2){ + PIString str1 = "first second"; + ASSERT_STREQ("0.0_first second", versionNormalize(str1)); } TEST(PIString_Tests, piHash){ diff --git a/tests/math/testpimathmatrix.cpp b/tests/math/testpimathmatrix.cpp index 1251b311..3dc1943a 100644 --- a/tests/math/testpimathmatrix.cpp +++ b/tests/math/testpimathmatrix.cpp @@ -52,25 +52,6 @@ TEST(PIMathMatrixT_Test, element) { ASSERT_TRUE(true); } -TEST(PIMathMatrixT_Test, element) { - auto matrix = PIMathMatrix::identity(3, 3); - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 3; j++){ - if(i != j){ - if(matrix[i][j] != 0.0){ - ASSERT_TRUE(false); - } - } - else { - if(matrix.element(i,i) != 1.0) { - ASSERT_TRUE(false); - } - } - } - } - ASSERT_TRUE(true); -} - TEST(PIMathMatrix_Test, matrixRow) { PIMathVector vector; vector.resize(3, 3.0); @@ -573,58 +554,3 @@ TEST(PIMathMatrix_Test, hermitian) { } ASSERT_TRUE(true); } - -TEST(PIMathMatrix_Test, matrixMultiplication) -{ - PIMathMatrix matrix1(2, 2, 1.5); - PIMathMatrix matrix2(2, 2, 2.5); - ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1 * matrix2, 7.5, 2)); -} - -TEST(PIMathMatrix_Test, matrixAndVectorMultiplication) { - PIMathMatrix matrix1(2, 2, 1.5); - PIMathVector vector; - vector.resize(2, 2.5); - for(uint i = 0; i < 2; i++) { - if((matrix1 * vector)[i] != 7.5) { - ASSERT_TRUE(false); - } - } - ASSERT_TRUE(true); -} - -TEST(PIMathMatrix_Test, vectorAndMatrixMultiplication) { - PIMathMatrix matrix1(2, 2, 1.5); - PIMathVector vector; - vector.resize(2, 2.5); - for(uint i = 0; i < 2; i++) { - if((vector * matrix1)[i] != 7.5) { - ASSERT_TRUE(false); - } - } - ASSERT_TRUE(true); -} - -TEST(PIMathMatrix_Test, valAndMatrixMultiplication) { - PIMathMatrix matrix1(3, 3, 1.5); - ASSERT_TRUE(cmpSquareMatrixWithValue(25.0*matrix1, 37.5, 3)); -} - -TEST(PIMathMatrix_Test, hermitian) { - complex val; - complex res; - val.imag(1.0); - val.real(1.0); - PIMathMatrix> matrix(3, 3, val); - res.imag(-1.0); - res.real(1.0); - auto matr = hermitian(matrix); - for(uint i = 0; i < 3; i++) { - for(uint j = 0; j < 3; j++) { - if(matr.element(i, j) != res) { - ASSERT_TRUE(false); - } - } - } - ASSERT_TRUE(true); -} diff --git a/tests/math/testpimathmatrixt.cpp b/tests/math/testpimathmatrixt.cpp index db572942..d7f11563 100644 --- a/tests/math/testpimathmatrixt.cpp +++ b/tests/math/testpimathmatrixt.cpp @@ -33,7 +33,6 @@ TEST(PIMathMatrixT_Test, identity) { } } } ->>>>>>> 05a32cc... doc correction ASSERT_TRUE(true); } @@ -298,8 +297,7 @@ TEST(PIMathMatrixT_Test, operator_Addition_Assignment) { auto matrix1 = PIMathMatrixT::filled(6.72) ; auto matrix2 = PIMathMatrixT::filled(1.0) ; matrix1 += matrix2; - b = cmpSquareMatrixWithValue(matrix1, 7.72, rows); - ASSERT_TRUE(b); + ASSERT_TRUE(cmpSquareMatrixWithValue(matrix1, 7.72, rows)); } TEST(PIMathMatrixT_Test, operator_Subtraction_Assignment) {