error correction

This commit is contained in:
2020-10-07 19:15:12 +03:00
parent 87417cdb68
commit 735b24574a
3 changed files with 3108 additions and 3059 deletions

View File

@@ -4,555 +4,592 @@
using namespace std; using namespace std;
TEST(PIStringList_Tests, construct_empty){ TEST(PIStringList_Tests, construct_empty){
PIStringList lis; PIStringList lis;
ASSERT_TRUE(lis.isEmpty()); ASSERT_TRUE(lis.isEmpty());
} }
TEST(PIStringList_Tests, construct_one_str_size){ TEST(PIStringList_Tests, construct_one_str_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIStringList lis {str1}; PIStringList lis (str1);
ASSERT_EQ(lis.length(),1); ASSERT_EQ(lis.length(),1);
} }
TEST(PIStringList_Tests, construct_one_str_data){ TEST(PIStringList_Tests, construct_one_str_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIStringList lis {str1}; PIStringList lis (str1);
ASSERT_EQ(str1, lis[0]); ASSERT_EQ(str1, lis[0]);
} }
TEST(PIStringList_Tests, construct_one_str_rvalue_size){ TEST(PIStringList_Tests, construct_one_str_move_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIStringList lis {"first string"}; PIStringList lis (move(str1));
ASSERT_EQ(lis.length(), 1); ASSERT_EQ(lis.length(), 1);
} }
TEST(PIStringList_Tests, construct_one_str_rvalue_data){ TEST(PIStringList_Tests, construct_one_str_move_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIStringList lis {"first string"}; PIString str = str1;
ASSERT_EQ(str1, lis[0]); PIStringList lis (move(str));
ASSERT_EQ(str1, lis[0]);
} }
TEST(PIStringList_Tests, construct_two_str_size){ TEST(PIStringList_Tests, construct_two_str_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIStringList lis {str1, str2}; PIStringList lis (str1, str2);
ASSERT_EQ(lis.length(), 2); ASSERT_EQ(lis.length(), 2);
} }
TEST(PIStringList_Tests, construct_two_str_data){ TEST(PIStringList_Tests, construct_two_str_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIStringList lis {str1, str2}; PIStringList lis (str1, str2);
ASSERT_EQ(str1, lis[0]); ASSERT_EQ(str1, lis[0]);
ASSERT_EQ(str2, lis[1]); ASSERT_EQ(str2, lis[1]);
} }
TEST(PIStringList_Tests, construct_two_str_rvalue_size){ TEST(PIStringList_Tests, construct_two_str_move_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIStringList lis {"first string", "second string"}; PIStringList lis (move(str1), move(str2));
ASSERT_EQ(lis.length(), 2); ASSERT_EQ(lis.length(), 2);
} }
TEST(PIStringList_Tests, construct_two_str_rvalue_data){ TEST(PIStringList_Tests, construct_two_str_move_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIStringList lis {"first string", "second string"}; PIString str1_res = str1;
ASSERT_EQ(str1, lis[0]); PIString str2_res = str2;
ASSERT_EQ(lis[1], str2); PIStringList lis (move(str1), move(str2));
ASSERT_EQ(str1_res, lis[0]);
ASSERT_EQ(lis[1], str2_res);
} }
TEST(PIStringList_Tests, construct_three_str_size){ TEST(PIStringList_Tests, construct_three_str_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIStringList lis {str1, str2, str3}; PIStringList lis (str1, str2, str3);
ASSERT_EQ(lis.length(),3); ASSERT_EQ(lis.length(),3);
} }
TEST(PIStringList_Tests, construct_three_str_data){ TEST(PIStringList_Tests, construct_three_str_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIStringList lis {str1, str2, str3}; PIStringList lis (str1, str2, str3);
ASSERT_EQ(lis[0], str1); ASSERT_EQ(lis[0], str1);
ASSERT_EQ(lis[1], str2); ASSERT_EQ(lis[1], str2);
ASSERT_EQ(lis[2], str3); ASSERT_EQ(lis[2], str3);
} }
TEST(PIStringList_Tests, construct_three_str_rvalue_size){ TEST(PIStringList_Tests, construct_three_str_move_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIStringList lis {"first string", "second string", "third string"}; PIStringList lis (move(str1), move(str2), move(str3));
ASSERT_EQ(lis.length(), 3); ASSERT_EQ(lis.length(), 3);
} }
TEST(PIStringList_Tests, construct_three_str_rvalue_data){ TEST(PIStringList_Tests, construct_three_str_move_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIStringList lis {"first string", "second string", "third string"}; PIString str1_res = str1;
ASSERT_EQ(lis[0], str1); PIString str2_res = str2;
ASSERT_EQ(lis[1], str2); PIString str3_res = str3;
ASSERT_EQ(lis[2], str3); PIStringList lis (move(str1), move(str2), move(str3));
ASSERT_EQ(lis[0], str1_res);
ASSERT_EQ(lis[1], str2_res);
ASSERT_EQ(lis[2], str3_res);
} }
TEST(PIStringList_Tests, construct_four_str_size){ TEST(PIStringList_Tests, construct_four_str_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis (str1, str2, str3, str4);
ASSERT_EQ(lis.length(), 4); ASSERT_EQ(lis.length(), 4);
} }
TEST(PIStringList_Tests, construct_four_str_data){ TEST(PIStringList_Tests, construct_four_str_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis (str1, str2, str3, str4);
ASSERT_EQ(lis[0], str1); ASSERT_EQ(lis[0], str1);
ASSERT_EQ(lis[1], str2); ASSERT_EQ(lis[1], str2);
ASSERT_EQ(lis[2], str3); ASSERT_EQ(lis[2], str3);
ASSERT_EQ(lis[3], str4); ASSERT_EQ(lis[3], str4);
} }
TEST(PIStringList_Tests, construct_four_str_rvalue_size){ TEST(PIStringList_Tests, construct_four_str_move_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {"first string", "second string", "third string", "fourth string"}; PIStringList lis (move(str1), move(str2), move(str3), move(str4));
ASSERT_EQ(lis.length(), 4); ASSERT_EQ(lis.length(), 4);
} }
TEST(PIStringList_Tests, construct_four_str_rvalue){ TEST(PIStringList_Tests, construct_four_str_move_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {"first string", "second string", "third string", "fourth string"}; PIString str1_res = str1;
ASSERT_EQ(lis[0], str1); PIString str2_res = str2;
ASSERT_EQ(lis[1], str2); PIString str3_res = str3;
ASSERT_EQ(lis[2], str3); PIString str4_res = str4;
ASSERT_EQ(lis[3], str4); PIStringList lis (move(str1), move(str2), move(str3), move(str4));
ASSERT_EQ(lis[0], str1_res);
ASSERT_EQ(lis[1], str2_res);
ASSERT_EQ(lis[2], str3_res);
ASSERT_EQ(lis[3], str4_res);
} }
TEST(PIStringList_Tests, construct_list_size){ TEST(PIStringList_Tests, construct_std_initializer_list_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis {"first string", "second string", "third string", "fourth string", "fourth string"};
PIStringList list {lis}; ASSERT_EQ(lis.length(), 5);
ASSERT_EQ(list.length(), 4); }
TEST(PIStringList_Tests, construct_std_initializer_list_data){
PIString str1 = "first string";
PIString str2 = "second string";
PIString str3 = "third string";
PIString str4 = "fourth string";
PIString str1_res = str1;
PIString str2_res = str2;
PIString str3_res = str3;
PIString str4_res = str4;
PIStringList lis {"first string", "second string", "third string", "fourth string", "fourth string"};
ASSERT_EQ(lis[0], str1_res);
ASSERT_EQ(lis[1], str2_res);
ASSERT_EQ(lis[2], str3_res);
ASSERT_EQ(lis[3], str4_res);
ASSERT_EQ(lis[4], str4_res);
}
TEST(PIStringList_Tests, construct_list_length){
PIString str1 = "first string";
PIString str2 = "second string";
PIString str3 = "third string";
PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3, str4};
PIStringList list (lis);
ASSERT_EQ(list.length(), 4);
} }
TEST(PIStringList_Tests, construct_list_data){ TEST(PIStringList_Tests, construct_list_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis {str1, str2, str3, str4};
PIStringList list {lis}; PIStringList list (lis);
ASSERT_EQ(list[0], str1); ASSERT_EQ(list[0], str1);
ASSERT_EQ(list[1], str2); ASSERT_EQ(list[1], str2);
ASSERT_EQ(list[2], str3); ASSERT_EQ(list[2], str3);
ASSERT_EQ(list[3], str4); ASSERT_EQ(list[3], str4);
} }
TEST(PIStringList_Tests, construct_list_rvalue_size){ TEST(PIStringList_Tests, construct_list_move_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {"first string", "second string", "third string", "fourth string"}; PIStringList lis {"first string", "second string", "third string", "fourth string"};
PIStringList list {move(lis)}; PIStringList list (move(lis));
ASSERT_EQ(list.length(), 4); ASSERT_EQ(list.length(), 4);
} }
TEST(PIStringList_Tests, construct_list_rvalue_data){ TEST(PIStringList_Tests, construct_list_move_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {"first string", "second string", "third string", "fourth string"}; PIStringList lis {"first string", "second string", "third string", "fourth string"};
PIStringList list {move(lis)}; PIStringList list (move(lis));
ASSERT_EQ(list[0], str1); ASSERT_EQ(list[0], str1);
ASSERT_EQ(list[1], str2); ASSERT_EQ(list[1], str2);
ASSERT_EQ(list[2], str3); ASSERT_EQ(list[2], str3);
ASSERT_EQ(list[3], str4); ASSERT_EQ(list[3], str4);
} }
TEST(PIStringList_Tests, construct_pivect_size){ TEST(PIStringList_Tests, construct_pivect_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIVector<PIString> vect; PIVector<PIString> vect;
vect.append(str1); vect.append(str1);
vect.append(str2); vect.append(str2);
vect.append(str3); vect.append(str3);
vect.append(str4); vect.append(str4);
PIStringList list {vect}; PIStringList list (vect);
ASSERT_EQ(list.length(), 4); ASSERT_EQ(list.length(), 4);
} }
TEST(PIStringList_Tests, construct_pivect_data){ TEST(PIStringList_Tests, construct_pivect_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIVector<PIString> vect; PIVector<PIString> vect;
vect.append(str1); vect.append(str1);
vect.append(str2); vect.append(str2);
vect.append(str3); vect.append(str3);
vect.append(str4); vect.append(str4);
PIStringList list {vect}; PIStringList list (vect);
ASSERT_EQ(list[0], str1); ASSERT_EQ(list[0], str1);
ASSERT_EQ(list[1], str2); ASSERT_EQ(list[1], str2);
ASSERT_EQ(list[2], str3); ASSERT_EQ(list[2], str3);
ASSERT_EQ(list[3], str4); ASSERT_EQ(list[3], str4);
} }
TEST(PIStringList_Tests, construct_list_pideq_size){ TEST(PIStringList_Tests, construct_list_pideq_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIDeque<PIString> deq; PIDeque<PIString> deq;
deq.append(str1); deq.append(str1);
deq.append(str2); deq.append(str2);
deq.append(str3); deq.append(str3);
deq.append(str4); deq.append(str4);
PIStringList list {deq}; PIStringList list (deq);
ASSERT_EQ(list.length(), 4); ASSERT_EQ(list.length(), 4);
} }
TEST(PIStringList_Tests, construct_list_pideq_data){ TEST(PIStringList_Tests, construct_list_pideq_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIDeque<PIString> deq; PIDeque<PIString> deq;
deq.append(str1); deq.append(str1);
deq.append(str2); deq.append(str2);
deq.append(str3); deq.append(str3);
deq.append(str4); deq.append(str4);
PIStringList list {deq}; PIStringList list (deq);
ASSERT_EQ(list[0], str1); ASSERT_EQ(list[0], str1);
ASSERT_EQ(list[1], str2); ASSERT_EQ(list[1], str2);
ASSERT_EQ(list[2], str3); ASSERT_EQ(list[2], str3);
ASSERT_EQ(list[3], str4); ASSERT_EQ(list[3], str4);
} }
TEST(PIStringList_Tests, join){ TEST(PIStringList_Tests, join){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIString del = ", "; PIString del = ", ";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis {str1, str2, str3, str4};
ASSERT_EQ(lis.join(del), "first string, second string, third string, fourth string"); ASSERT_EQ(lis.join(del), "first string, second string, third string, fourth string");
} }
TEST(PIStringList_Tests, remove_strings_size){ TEST(PIStringList_Tests, remove_strings_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "string"; PIString str2 = "string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "string"; PIString str4 = "string";
PIString val = "string"; PIString val = "string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis {str1, str2, str3, str4};
lis.removeStrings(val); lis.removeStrings(val);
ASSERT_EQ(lis.length(), 2); ASSERT_EQ(lis.length(), 2);
} }
TEST(PIStringList_Tests, remove_strings_data){ TEST(PIStringList_Tests, remove_strings_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "string"; PIString str2 = "string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "string"; PIString str4 = "string";
PIString val = "string"; PIString val = "string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis {str1, str2, str3, str4};
lis.removeStrings(val); lis.removeStrings(val);
ASSERT_EQ(lis[0], "first string"); ASSERT_EQ(lis[0], "first string");
ASSERT_EQ(lis[1], "third string"); ASSERT_EQ(lis[1], "third string");
} }
TEST(PIStringList_Tests, remove_size){ TEST(PIStringList_Tests, remove_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis {str1, str2, str3, str4};
lis.remove(2); lis.remove(2);
ASSERT_EQ(lis.length(), 3); ASSERT_EQ(lis.length(), 3);
} }
TEST(PIStringList_Tests, remove_data){ TEST(PIStringList_Tests, remove_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis {str1, str2, str3, str4};
lis.remove(2); lis.remove(2);
ASSERT_EQ(lis[0], "first string"); ASSERT_EQ(lis[0], "first string");
ASSERT_EQ(lis[1], "second string"); ASSERT_EQ(lis[1], "second string");
ASSERT_EQ(lis[2], "fourth string"); ASSERT_EQ(lis[2], "fourth string");
} }
TEST(PIStringList_Tests, remove_count_size){ TEST(PIStringList_Tests, remove_count_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis {str1, str2, str3, str4};
lis.remove(2,2); lis.remove(2,2);
ASSERT_EQ(lis.length(), 2); ASSERT_EQ(lis.length(), 2);
} }
TEST(PIStringList_Tests, remove_count_data){ TEST(PIStringList_Tests, remove_count_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis {str1, str2, str3, str4};
lis.remove(2,2); lis.remove(2,2);
ASSERT_EQ(lis[0], "first string"); ASSERT_EQ(lis[0], "first string");
ASSERT_EQ(lis[1], "second string"); ASSERT_EQ(lis[1], "second string");
} }
TEST(PIStringList_Tests, remove_Duplicates_size){ TEST(PIStringList_Tests, remove_Duplicates_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "first string"; PIString str3 = "first string";
PIString str4 = "second string"; PIString str4 = "second string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis {str1, str2, str3, str4};
lis.removeDuplicates(); lis.removeDuplicates();
ASSERT_EQ(lis.length(), 2); ASSERT_EQ(lis.length(), 2);
} }
TEST(PIStringList_Tests, remove_Duplicates_data){ TEST(PIStringList_Tests, remove_Duplicates_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "first string"; PIString str3 = "first string";
PIString str4 = "second string"; PIString str4 = "second string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis {str1, str2, str3, str4};
lis.removeDuplicates(); lis.removeDuplicates();
ASSERT_EQ(lis[0], "first string"); ASSERT_EQ(lis[0], "first string");
ASSERT_EQ(lis[1], "second string"); ASSERT_EQ(lis[1], "second string");
} }
TEST(PIStringList_Tests, trim_size){ TEST(PIStringList_Tests, trim_length){
PIString str1 = " first string "; PIString str1 = " first string ";
PIString str2 = "second string "; PIString str2 = "second string ";
PIString str3 = " third string"; PIString str3 = " third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis {str1, str2, str3, str4};
lis.trim(); lis.trim();
ASSERT_EQ(lis.length(), 4); ASSERT_EQ(lis.length(), 4);
} }
TEST(PIStringList_Tests, trim_data){ TEST(PIStringList_Tests, trim_data){
PIString str1 = " first string "; PIString str1 = " first string ";
PIString str2 = "second string "; PIString str2 = "second string ";
PIString str3 = " third string"; PIString str3 = " third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis {str1, str2, str3, str4};
lis.trim(); lis.trim();
ASSERT_EQ(lis[0], "first string"); ASSERT_EQ(lis[0], "first string");
ASSERT_EQ(lis[1], "second string"); ASSERT_EQ(lis[1], "second string");
ASSERT_EQ(lis[2], "third string"); ASSERT_EQ(lis[2], "third string");
ASSERT_EQ(lis[3], "fourth string"); ASSERT_EQ(lis[3], "fourth string");
} }
TEST(PIStringList_Tests, content_size){ TEST(PIStringList_Tests, content_size){
PIString str1 = " first string "; PIString str1 = " first string ";
PIString str2 = "second string "; PIString str2 = "second string ";
PIString str3 = " third string"; PIString str3 = " third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis {str1, str2, str3, str4};
ASSERT_EQ(lis.contentSize(), 54); ASSERT_EQ(lis.contentSize(), 54);
} }
TEST(PIStringList_Tests, operator_compare){ TEST(PIStringList_Tests, operator_compare){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis {str1, str2, str3, str4};
PIStringList lis1 {"first string", "second string", "third string", "fourth string"}; PIStringList lis1 {"first string", "second string", "third string", "fourth string"};
ASSERT_TRUE(lis == lis1); ASSERT_TRUE(lis == lis1);
} }
TEST(PIStringList_Tests, operator_compare_false){ TEST(PIStringList_Tests, operator_compare_false){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "thord string"; PIString str3 = "thord string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis {str1, str2, str3, str4};
PIStringList lis1 {"first string", "second string", "third string", "fourth string"}; PIStringList lis1 {"first string", "second string", "third string", "fourth string"};
ASSERT_FALSE(lis == lis1); ASSERT_FALSE(lis == lis1);
} }
TEST(PIStringList_Tests, operator_compare_size){ TEST(PIStringList_Tests, operator_compare_size){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3}; PIStringList lis {str1, str2, str3};
PIStringList lis1 {"first string", "second string", "third string", "fourth string"}; PIStringList lis1 {"first string", "second string", "third string", "fourth string"};
ASSERT_FALSE(lis == lis1); ASSERT_FALSE(lis == lis1);
} }
TEST(PIStringList_Tests, operator_compare_unequal TEST(PIStringList_Tests, operator_compare_unequal){
PIString str1 = "first string";
){ PIString str2 = "second string";
PIString str1 = "first string"; PIString str3 = "third string";
PIString str2 = "second string"; PIString str4 = "fourth string";
PIString str3 = "third string"; PIStringList lis {str1, str2, str3, str4};
PIString str4 = "fourth string"; PIStringList lis1 {"first string", "second string", "third string", "fourth string"};
PIStringList lis {str1, str2, str3, str4}; ASSERT_FALSE(lis != lis1);
PIStringList lis1 {"first string", "second string", "third string", "fourth string"};
ASSERT_FALSE(lis != lis1);
} }
TEST(PIStringList_Tests, operator_compare_unequal_false){ TEST(PIStringList_Tests, operator_compare_unequal_false){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "thord string"; PIString str3 = "thord string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis {str1, str2, str3, str4};
PIStringList lis1 {"first string", "second string", "third string", "fourth string"}; PIStringList lis1 {"first string", "second string", "third string", "fourth string"};
ASSERT_TRUE(lis != lis1); ASSERT_TRUE(lis != lis1);
} }
TEST(PIStringList_Tests, operator_compare_unequal_size){ TEST(PIStringList_Tests, operator_compare_unequal_size){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "third string"; PIString str3 = "third string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3}; PIStringList lis {str1, str2, str3};
PIStringList lis1 {"first string", "second string", "third string", "fourth string"}; PIStringList lis1 {"first string", "second string", "third string", "fourth string"};
ASSERT_TRUE(lis != lis1); ASSERT_TRUE(lis != lis1);
} }
TEST(PIStringList_Tests, operator_assignment_size){ TEST(PIStringList_Tests, operator_assignment_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "thord string"; PIString str3 = "thord string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis {str1, str2, str3, str4};
PIStringList lis1 = lis; PIStringList lis1;
ASSERT_EQ(lis1.length(), 4); lis1 = lis;
ASSERT_EQ(lis1.length(), 4);
} }
TEST(PIStringList_Tests, operator_assignment_data){ TEST(PIStringList_Tests, operator_assignment_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "thord string"; PIString str3 = "thord string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3, str4}; PIStringList lis {str1, str2, str3, str4};
PIStringList lis1 = lis; PIStringList lis1;
ASSERT_EQ(lis1[0], str1); lis1 = lis;
ASSERT_EQ(lis1[1], str2); ASSERT_EQ(lis1[0], str1);
ASSERT_EQ(lis1[2], str3); ASSERT_EQ(lis1[1], str2);
ASSERT_EQ(lis1[3], str4); ASSERT_EQ(lis1[2], str3);
ASSERT_EQ(lis1[3], str4);
} }
TEST(PIStringList_Tests, operator_shift_size){ TEST(PIStringList_Tests, operator_shift_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "thord string"; PIString str3 = "thord string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3}; PIStringList lis {str1, str2, str3};
lis << str4; lis << str4;
ASSERT_EQ(lis.length(), 4); ASSERT_EQ(lis.length(), 4);
} }
TEST(PIStringList_Tests, operator_shift_data){ TEST(PIStringList_Tests, operator_shift_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "thord string"; PIString str3 = "thord string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3}; PIStringList lis {str1, str2, str3};
lis << str4; lis << str4;
ASSERT_EQ(lis[0], str1); ASSERT_EQ(lis[0], str1);
ASSERT_EQ(lis[1], str2); ASSERT_EQ(lis[1], str2);
ASSERT_EQ(lis[2], str3); ASSERT_EQ(lis[2], str3);
ASSERT_EQ(lis[3], str4); ASSERT_EQ(lis[3], str4);
} }
TEST(PIStringList_Tests, operator_shift_rvalue_size){ TEST(PIStringList_Tests, operator_shift_move_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "thord string"; PIString str3 = "thord string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3}; PIStringList lis {str1, str2, str3};
lis << "fourth string"; lis << move(str4);
ASSERT_EQ(lis.length(), 4); ASSERT_EQ(lis.length(), 4);
} }
TEST(PIStringList_Tests, operator_shift_rvalue_data){ TEST(PIStringList_Tests, operator_shift_move_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "thord string"; PIString str3 = "thord string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2, str3}; PIString str = str4;
lis << "fourth string"; PIStringList lis {str1, str2, str3};
ASSERT_EQ(lis[0], str1); lis << move(str);
ASSERT_EQ(lis[1], str2); ASSERT_EQ(lis[0], str1);
ASSERT_EQ(lis[2], str3); ASSERT_EQ(lis[1], str2);
ASSERT_EQ(lis[3], str4); ASSERT_EQ(lis[2], str3);
ASSERT_EQ(lis[3], str4);
} }
TEST(PIStringList_Tests, operator_shift_pistringlist_size){ TEST(PIStringList_Tests, operator_shift_pistringlist_length){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "thord string"; PIString str3 = "thord string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2}; PIStringList lis {str1, str2};
PIStringList lis1 {str3, str4}; PIStringList lis1 {str3, str4};
lis << lis1; lis << lis1;
ASSERT_EQ(lis.length(), 4); ASSERT_EQ(lis.length(), 4);
} }
TEST(PIStringList_Tests, operator_shift_pistringlist_data){ TEST(PIStringList_Tests, operator_shift_pistringlist_data){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIString str3 = "thord string"; PIString str3 = "thord string";
PIString str4 = "fourth string"; PIString str4 = "fourth string";
PIStringList lis {str1, str2}; PIStringList lis {str1, str2};
PIStringList lis1 {str3, str4}; PIStringList lis1 {str3, str4};
lis << lis1; lis << lis1;
ASSERT_EQ(lis[0], str1); ASSERT_EQ(lis[0], str1);
ASSERT_EQ(lis[1], str2); ASSERT_EQ(lis[1], str2);
ASSERT_EQ(lis[2], str3); ASSERT_EQ(lis[2], str3);
ASSERT_EQ(lis[3], str4); ASSERT_EQ(lis[3], str4);
} }
TEST(PIStringList_Tests, operator_shift_pibytearray){ TEST(PIStringList_Tests, operator_shift_pibytearray){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIStringList lis {str1, str2}; PIStringList lis {str1, str2};
PIByteArray arr; PIByteArray arr;
arr << lis; arr << lis;
PIByteArray res[] = {2, 0, 0, 0, 12, 0, 0, 0, 102, 0, 105, 0, 114, 0, 115, 0, 116, 0, 32, 0, 115, 0, 116, 0, 114, 0, 105, 0, 110, 0, 103, 0, PIByteArray res[] = {2, 0, 0, 0, 12, 0, 0, 0, 102, 0, 105, 0, 114, 0, 115, 0, 116, 0, 32, 0, 115, 0, 116, 0, 114, 0, 105, 0, 110, 0, 103, 0,
13, 0, 0, 0, 115, 0, 101, 0, 99, 0, 111, 0, 110, 0, 100, 0, 32, 0, 115, 0, 116, 0, 114, 0, 105, 0, 110, 0, 103, 0}; 13, 0, 0, 0, 115, 0, 101, 0, 99, 0, 111, 0, 110, 0, 100, 0, 32, 0, 115, 0, 116, 0, 114, 0, 105, 0, 110, 0, 103, 0};
bool fl = true; bool fl = true;
for(size_t x = 0; x < arr.length(); x++) { for(size_t x = 0; x < arr.length(); x++) {
if(res[x] != arr[x]) fl = false; if(res[x] != arr[x]) fl = false;
} }
ASSERT_TRUE(fl); ASSERT_TRUE(fl);
} }
TEST(PIStringList_Tests, operator_shift_right_pibytearray){ TEST(PIStringList_Tests, operator_shift_right_pibytearray){
PIString str1 = "first string"; PIString str1 = "first string";
PIString str2 = "second string"; PIString str2 = "second string";
PIStringList res {str1, str2}; PIStringList res {str1, str2};
PIByteArray arr; PIByteArray arr;
arr << res; arr << res;
PIStringList list; PIStringList list;
arr >> list; arr >> list;
ASSERT_EQ(res, list); ASSERT_EQ(res, list);
} }

View File

@@ -7,1151 +7,1153 @@
using namespace std; using namespace std;
TEST(PIByteArray_Tests, construct_empty_BA){ TEST(PIByteArray_Tests, construct_empty_BA){
PIByteArray arr; PIByteArray arr;
ASSERT_TRUE(arr.isEmpty()); ASSERT_TRUE(arr.isEmpty());
} }
TEST(PIByteArray_Tests, construct_BA_size){ TEST(PIByteArray_Tests, construct_BA_size){
PIByteArray arr(5); PIByteArray arr(5);
ASSERT_EQ(arr.size(), 5); ASSERT_EQ(arr.size(), 5);
} }
TEST(PIByteArray_Tests, construct_BA){ TEST(PIByteArray_Tests, construct_BA){
PIString str = "new"; PIString str = "new";
const PIByteArray arr1 = str.toByteArray(); const PIByteArray arr1 = str.toByteArray();
PIByteArray res = str.toByteArray(); PIByteArray res = str.toByteArray();
PIByteArray arr(arr1); PIByteArray arr(arr1);
ASSERT_EQ(arr, res); ASSERT_EQ(arr, res);
} }
TEST(PIByteArray_Tests, construct_BA_not_const){ TEST(PIByteArray_Tests, construct_BA_not_const){
PIString str = "big"; PIString str = "big";
PIByteArray arr1 = str.toByteArray(); PIByteArray arr1 = str.toByteArray();
PIByteArray res = str.toByteArray(); PIByteArray res = str.toByteArray();
PIByteArray arr(move(arr1)); PIByteArray arr(move(arr1));
ASSERT_EQ(arr, res); ASSERT_EQ(arr, res);
} }
TEST(PIByteArray_Tests, construct_BA_data_size){ TEST(PIByteArray_Tests, construct_BA_data_size){
PIByteArray arr((void*)"new", 3); PIByteArray arr((void*)"new", 3);
PIString str = "new"; PIString str = "new";
PIByteArray res = str.toByteArray(); PIByteArray res = str.toByteArray();
ASSERT_EQ(arr, res); ASSERT_EQ(arr, res);
} }
TEST(PIByteArray_Tests, construct_BA_size_char){ TEST(PIByteArray_Tests, construct_BA_size_char){
uchar t = 'n'; uchar t = 'n';
PIByteArray arr(3, t); PIByteArray arr(3, t);
PIString str = "nnn"; PIString str = "nnn";
PIByteArray res = str.toByteArray(); PIByteArray res = str.toByteArray();
ASSERT_EQ(arr, res); ASSERT_EQ(arr, res);
} }
TEST(PIByteArray_Tests, resized){ TEST(PIByteArray_Tests, resized){
PIByteArray arr(5); PIByteArray arr(5);
PIByteArray arr2 = arr.resized(3); PIByteArray arr2 = arr.resized(3);
ASSERT_EQ(arr.size(), 5); ASSERT_EQ(arr.size(), 5);
ASSERT_EQ(arr2.size(), 3); ASSERT_EQ(arr2.size(), 3);
} }
TEST(PIByteArray_Tests, convert_to_base64){ TEST(PIByteArray_Tests, convert_to_base64){
PIByteArray arr((void*)"PIP is great", 12); PIByteArray arr((void*)"PIP is great", 12);
arr.convertToBase64(); arr.convertToBase64();
PIByteArray arr1(16); PIByteArray arr1(16);
arr1[0] = 85; arr1[0] = 85;
arr1[1] = 69; arr1[1] = 69;
arr1[2] = 108; arr1[2] = 108;
arr1[3] = 81; arr1[3] = 81;
arr1[4] = 73; arr1[4] = 73;
arr1[5] = 71; arr1[5] = 71;
arr1[6] = 108; arr1[6] = 108;
arr1[7] = 122; arr1[7] = 122;
arr1[8] = 73; arr1[8] = 73;
arr1[9] = 71; arr1[9] = 71;
arr1[10] = 100; arr1[10] = 100;
arr1[11] = 121; arr1[11] = 121;
arr1[12] = 90; arr1[12] = 90;
arr1[13] = 87; arr1[13] = 87;
arr1[14] = 70; arr1[14] = 70;
arr1[15] = 48; arr1[15] = 48;
ASSERT_EQ(arr, arr1); ASSERT_EQ(arr, arr1);
} }
TEST(PIByteArray_Tests, convert_to_base64_empty){ TEST(PIByteArray_Tests, convert_to_base64_empty){
PIByteArray arr; PIByteArray arr;
arr.convertToBase64(); arr.convertToBase64();
PIByteArray arr1; PIByteArray arr1;
ASSERT_EQ(arr, arr1); ASSERT_EQ(arr, arr1);
} }
TEST(PIByteArray_Tests, convert_from_base64){ TEST(PIByteArray_Tests, convert_from_base64){
PIByteArray arr1(16); PIByteArray arr1(16);
arr1[0] = 85; arr1[0] = 85;
arr1[1] = 69; arr1[1] = 69;
arr1[2] = 108; arr1[2] = 108;
arr1[3] = 81; arr1[3] = 81;
arr1[4] = 73; arr1[4] = 73;
arr1[5] = 71; arr1[5] = 71;
arr1[6] = 108; arr1[6] = 108;
arr1[7] = 122; arr1[7] = 122;
arr1[8] = 73; arr1[8] = 73;
arr1[9] = 71; arr1[9] = 71;
arr1[10] = 100; arr1[10] = 100;
arr1[11] = 121; arr1[11] = 121;
arr1[12] = 90; arr1[12] = 90;
arr1[13] = 87; arr1[13] = 87;
arr1[14] = 70; arr1[14] = 70;
arr1[15] = 48; arr1[15] = 48;
arr1.convertFromBase64(); arr1.convertFromBase64();
PIByteArray arr((void*)"PIP is great", 12); PIByteArray arr((void*)"PIP is great", 12);
ASSERT_EQ(arr, arr1); ASSERT_EQ(arr, arr1);
} }
TEST(PIByteArray_Tests, convert_from_base64_empty){ TEST(PIByteArray_Tests, convert_from_base64_empty){
PIByteArray arr; PIByteArray arr;
arr.convertFromBase64(); arr.convertFromBase64();
PIByteArray arr1; PIByteArray arr1;
ASSERT_EQ(arr, arr1); ASSERT_EQ(arr, arr1);
} }
TEST(PIByteArray_Tests, to_base64){ TEST(PIByteArray_Tests, to_base64){
PIByteArray arr((void*)"PIP is great", 12); PIByteArray arr((void*)"PIP is great", 12);
PIByteArray arr2 = arr.toBase64(); PIByteArray arr2 = arr.toBase64();
PIByteArray arr1(16); PIByteArray arr1(16);
arr1[0] = 85; arr1[0] = 85;
arr1[1] = 69; arr1[1] = 69;
arr1[2] = 108; arr1[2] = 108;
arr1[3] = 81; arr1[3] = 81;
arr1[4] = 73; arr1[4] = 73;
arr1[5] = 71; arr1[5] = 71;
arr1[6] = 108; arr1[6] = 108;
arr1[7] = 122; arr1[7] = 122;
arr1[8] = 73; arr1[8] = 73;
arr1[9] = 71; arr1[9] = 71;
arr1[10] = 100; arr1[10] = 100;
arr1[11] = 121; arr1[11] = 121;
arr1[12] = 90; arr1[12] = 90;
arr1[13] = 87; arr1[13] = 87;
arr1[14] = 70; arr1[14] = 70;
arr1[15] = 48; arr1[15] = 48;
ASSERT_EQ(arr2, arr1); ASSERT_EQ(arr2, arr1);
} }
TEST(PIByteArray_Tests, to_base64_immutability){ TEST(PIByteArray_Tests, to_base64_immutability){
PIByteArray arr((void*)"PIP is great", 12); PIByteArray arr((void*)"PIP is great", 12);
PIByteArray old((void*)"PIP is great", 12); PIByteArray old((void*)"PIP is great", 12);
PIByteArray arr2 = arr.toBase64(); PIByteArray arr2 = arr.toBase64();
ASSERT_EQ(arr, old); ASSERT_EQ(arr, old);
} }
TEST(PIByteArray_Tests, to_base64_empty){ TEST(PIByteArray_Tests, to_base64_empty){
PIByteArray arr; PIByteArray arr;
arr.toBase64(); arr.toBase64();
PIByteArray arr1; PIByteArray arr1;
ASSERT_EQ(arr, arr1); ASSERT_EQ(arr, arr1);
} }
TEST(PIByteArray_Tests, compress_rle){ TEST(PIByteArray_Tests, compress_rle){
PIByteArray arr((void*)"nnnnew", 6); PIByteArray arr((void*)"nnnnew", 6);
arr.compressRLE(15); arr.compressRLE(15);
PIByteArray res(6); PIByteArray res(6);
res[0] = 19; res[0] = 19;
res[1] = 110; res[1] = 110;
res[2] = 16; res[2] = 16;
res[3] = 101; res[3] = 101;
res[4] = 16; res[4] = 16;
res[5] = 119; res[5] = 119;
ASSERT_EQ(arr, res); ASSERT_EQ(arr, res);
} }
TEST(PIByteArray_Tests, decompress_rle){ TEST(PIByteArray_Tests, decompress_rle){
PIByteArray arr(4); PIByteArray arr(4);
arr[0] = 17; arr[0] = 17;
arr[1] = 110; arr[1] = 110;
arr[2] = 16; arr[2] = 16;
arr[3] = 101; arr[3] = 101;
arr.decompressRLE(15); arr.decompressRLE(15);
PIByteArray res((void*)"nne", 3); PIByteArray res((void*)"nne", 3);
ASSERT_EQ(arr, res); ASSERT_EQ(arr, res);
} }
TEST(PIByteArray_Tests, compress_rle_point){ TEST(PIByteArray_Tests, compress_rle_point){
PIByteArray arr((void*)"nnnnew", 6); PIByteArray arr((void*)"nnnnew", 6);
PIByteArray arr1 = arr.compressedRLE(15); PIByteArray arr1 = arr.compressedRLE(15);
PIByteArray res(6); PIByteArray res(6);
res[0] = 19; res[0] = 19;
res[1] = 110; res[1] = 110;
res[2] = 16; res[2] = 16;
res[3] = 101; res[3] = 101;
res[4] = 16; res[4] = 16;
res[5] = 119; res[5] = 119;
ASSERT_EQ(arr1, res); ASSERT_EQ(arr1, res);
} }
TEST(PIByteArray_Tests, compress_rle_point_immutability){ TEST(PIByteArray_Tests, compress_rle_point_immutability){
PIByteArray arr((void*)"nnnnew", 6); PIByteArray arr((void*)"nnnnew", 6);
PIByteArray arr2((void*)"nnnnew", 6); PIByteArray arr2((void*)"nnnnew", 6);
PIByteArray arr1 = arr.compressedRLE(15); PIByteArray arr1 = arr.compressedRLE(15);
ASSERT_EQ(arr, arr2); ASSERT_EQ(arr, arr2);
} }
TEST(PIByteArray_Tests, decompress_rle_point){ TEST(PIByteArray_Tests, decompress_rle_point){
PIByteArray arr(4); PIByteArray arr(4);
arr[0] = 17; arr[0] = 17;
arr[1] = 110; arr[1] = 110;
arr[2] = 16; arr[2] = 16;
arr[3] = 101; arr[3] = 101;
PIByteArray arr1 = arr.decompressedRLE(15); PIByteArray arr1 = arr.decompressedRLE(15);
PIByteArray res((void*)"nne", 3); PIByteArray res((void*)"nne", 3);
ASSERT_EQ(arr1, res); ASSERT_EQ(arr1, res);
} }
TEST(PIByteArray_Tests, decompress_rle_point_immutability){ TEST(PIByteArray_Tests, decompress_rle_point_immutability){
PIByteArray arr(4); PIByteArray arr(4);
arr[0] = 17; arr[0] = 17;
arr[1] = 110; arr[1] = 110;
arr[2] = 16; arr[2] = 16;
arr[3] = 101; arr[3] = 101;
PIByteArray arr2(4); PIByteArray arr2(4);
arr2[0] = 17; arr2[0] = 17;
arr2[1] = 110; arr2[1] = 110;
arr2[2] = 16; arr2[2] = 16;
arr2[3] = 101; arr2[3] = 101;
PIByteArray arr1 = arr.decompressedRLE(15); PIByteArray arr1 = arr.decompressedRLE(15);
ASSERT_EQ(arr, arr2); ASSERT_EQ(arr, arr2);
} }
TEST(PIByteArray_Tests, to_string){ TEST(PIByteArray_Tests, to_string){
PIByteArray arr((void*)"new", 3); PIByteArray arr((void*)"new", 3);
PIString str = arr.toString(); PIString str = arr.toString();
PIString res = "0x6E 0x65 0x77"; PIString res = "0x6E 0x65 0x77";
ASSERT_EQ(res, str); ASSERT_EQ(res, str);
} }
TEST(PIByteArray_Tests, to_string_10){ TEST(PIByteArray_Tests, to_string_10){
PIByteArray arr((void*)"new", 3); PIByteArray arr((void*)"new", 3);
PIString str = arr.toString(10); PIString str = arr.toString(10);
PIString res = "110 101 119"; PIString res = "110 101 119";
ASSERT_EQ(res, str); ASSERT_EQ(res, str);
} }
TEST(PIByteArray_Tests, to_string_2){ TEST(PIByteArray_Tests, to_string_2){
PIByteArray arr((void*)"new", 3); PIByteArray arr((void*)"new", 3);
PIString str = arr.toString(2); PIString str = arr.toString(2);
PIString res = "b1101110 b1100101 b1110111"; PIString res = "b1101110 b1100101 b1110111";
ASSERT_EQ(res, str); ASSERT_EQ(res, str);
} }
TEST(PIByteArray_Tests, to_string_8){ TEST(PIByteArray_Tests, to_string_8){
PIByteArray arr((void*)"new", 3); PIByteArray arr((void*)"new", 3);
PIString str = arr.toString(8); PIString str = arr.toString(8);
PIString res = "0156 0145 0167"; PIString res = "0156 0145 0167";
ASSERT_EQ(res, str); ASSERT_EQ(res, str);
} }
TEST(PIByteArray_Tests, to_hex){ TEST(PIByteArray_Tests, to_hex){
PIByteArray arr(1); PIByteArray arr(1);
arr[0] = 15; arr[0] = 15;
PIString str = arr.toHex(); PIString str = arr.toHex();
PIString res = "0f"; PIString res = "0f";
ASSERT_EQ(res, str); ASSERT_EQ(res, str);
} }
TEST(PIByteArray_Tests, append){ TEST(PIByteArray_Tests, append){
PIByteArray arr((void*)"n", 1); PIByteArray arr((void*)"n", 1);
PIByteArray arr1((void*)"new", 3); PIByteArray arr1((void*)"new", 3);
arr.append((void*)"ew", 2); arr.append((void*)"ew", 2);
ASSERT_EQ(arr, arr1); ASSERT_EQ(arr, arr1);
} }
TEST(PIByteArray_Tests, append_BA){ TEST(PIByteArray_Tests, append_BA){
PIByteArray arr((void*)"n", 1); PIByteArray arr((void*)"n", 1);
const PIByteArray arr1((void*)"ew", 2); const PIByteArray arr1((void*)"ew", 2);
PIByteArray arr2((void*)"new", 3); PIByteArray arr2((void*)"new", 3);
arr.append(arr1); arr.append(arr1);
ASSERT_EQ(arr, arr2); ASSERT_EQ(arr, arr2);
} }
TEST(PIByteArray_Tests, append_uchar){ TEST(PIByteArray_Tests, append_uchar){
PIByteArray arr((void*)"ne", 2); PIByteArray arr((void*)"ne", 2);
PIByteArray arr2((void*)"new", 3); PIByteArray arr2((void*)"new", 3);
arr.append('w'); arr.append('w');
ASSERT_EQ(arr, arr2); ASSERT_EQ(arr, arr2);
} }
TEST(PIByteArray_Tests, checksum_plain8){ TEST(PIByteArray_Tests, checksum_plain8){
PIByteArray arr((void*)"new", 3); PIByteArray arr((void*)"new", 3);
ASSERT_EQ(180, arr.checksumPlain8()); ASSERT_EQ(180, arr.checksumPlain8());
} }
TEST(PIByteArray_Tests, checksum_plain32){ TEST(PIByteArray_Tests, checksum_plain32){
PIByteArray arr((void*)"new", 3); PIByteArray arr((void*)"new", 3);
ASSERT_EQ(4294966625, arr.checksumPlain32()); ASSERT_EQ(4294966625, arr.checksumPlain32());
} }
TEST(PIByteArray_Tests, hash){ TEST(PIByteArray_Tests, hash){
PIByteArray arr((void*)"new", 3); PIByteArray arr((void*)"new", 3);
ASSERT_EQ(422208903, arr.hash()); ASSERT_EQ(422208903, arr.hash());
} }
TEST(PIByteArray_Tests, assignment_operator){ TEST(PIByteArray_Tests, assignment_operator){
PIByteArray arr(3); PIByteArray arr(3);
PIDeque<uchar> deq; PIDeque<uchar> deq;
deq.append('n'); deq.append('n');
deq.append('e'); deq.append('e');
deq.append('w'); deq.append('w');
arr = deq; arr = deq;
PIByteArray res((void*)"new", 3); PIByteArray res((void*)"new", 3);
ASSERT_EQ(arr, res); ASSERT_EQ(arr, res);
} }
TEST(PIByteArray_Tests, assignment_operator_ba){ TEST(PIByteArray_Tests, assignment_operator_ba){
PIByteArray arr(3); PIByteArray arr(3);
const PIByteArray arr1((void*)"new", 3); const PIByteArray arr1((void*)"new", 3);
arr = arr1; arr = arr1;
PIByteArray res((void*)"new", 3); PIByteArray res((void*)"new", 3);
ASSERT_EQ(arr, res); ASSERT_EQ(arr, res);
} }
TEST(PIByteArray_Tests, assignment_operator_ba_nconst){ TEST(PIByteArray_Tests, assignment_operator_ba_nconst){
PIByteArray arr(3); PIByteArray arr(3);
PIByteArray arr1((void*)"new", 3); PIByteArray arr1((void*)"new", 3);
PIByteArray arr2; PIByteArray arr2;
arr = move(arr1); arr = move(arr1);
PIByteArray res((void*)"new", 3); PIByteArray res((void*)"new", 3);
ASSERT_EQ(arr, res); ASSERT_EQ(arr, res);
} }
TEST(PIByteArray_Tests, from_user_input){ TEST(PIByteArray_Tests, from_user_input){
PIByteArray arr; PIByteArray arr;
ASSERT_EQ(10, arr.fromUserInput(" \n \t10")[0]); ASSERT_EQ(10, arr.fromUserInput(" \n \t10")[0]);
} }
TEST(PIByteArray_Tests, from_user_input_hex){ TEST(PIByteArray_Tests, from_user_input_hex){
PIByteArray arr; PIByteArray arr;
ASSERT_EQ(16, arr.fromUserInput(" \n \t0x10")[0]); ASSERT_EQ(16, arr.fromUserInput(" \n \t0x10")[0]);
} }
TEST(PIByteArray_Tests, from_hex){ TEST(PIByteArray_Tests, from_hex){
PIByteArray arr; PIByteArray arr;
ASSERT_EQ(15, arr.fromHex("0xF")[0]); ASSERT_EQ(15, arr.fromHex("0xF")[0]);
} }
TEST(PIByteArray_Tests, from_base64_ba){ TEST(PIByteArray_Tests, from_base64_ba){
PIByteArray arr1(4); PIByteArray arr1(4);
arr1[0] = 98; arr1[0] = 98;
arr1[1] = 109; arr1[1] = 109;
arr1[2] = 86; arr1[2] = 86;
arr1[3] = 51; arr1[3] = 51;
PIByteArray arr = PIByteArray::fromBase64(arr1); PIByteArray arr = PIByteArray::fromBase64(arr1);
PIByteArray res((void*)"new", 3); PIByteArray res((void*)"new", 3);
ASSERT_EQ(arr, res); ASSERT_EQ(arr, res);
} }
TEST(PIByteArray_Tests, from_base64_pstr){ TEST(PIByteArray_Tests, from_base64_pstr){
PIByteArray arr = PIByteArray::fromBase64("new prog"); PIByteArray arr = PIByteArray::fromBase64("new prog");
PIByteArray res(6); PIByteArray res(6);
res[0] = 157; res[0] = 157;
res[1] = 236; res[1] = 236;
res[2] = 0; res[2] = 0;
res[3] = 166; res[3] = 166;
res[4] = 186; res[4] = 186;
res[5] = 32; res[5] = 32;
ASSERT_EQ(res, arr); ASSERT_EQ(res, arr);
} }
TEST(PIByteArray_Tests, operator_compar){ TEST(PIByteArray_Tests, operator_compar){
PIByteArray arr((void*)"new", 3); PIByteArray arr((void*)"new", 3);
PIByteArray arr1((void*)"news", 4); PIByteArray arr1((void*)"news", 4);
ASSERT_TRUE(arr < arr1); ASSERT_TRUE(arr < arr1);
} }
TEST(PIByteArray_Tests, operator_compar_false){ TEST(PIByteArray_Tests, operator_compar_false){
PIByteArray arr((void*)"new", 3); PIByteArray arr((void*)"new", 3);
PIByteArray arr1((void*)"news", 3); PIByteArray arr1((void*)"news", 3);
ASSERT_FALSE(arr < arr1); ASSERT_FALSE(arr < arr1);
} }
TEST(PIByteArray_Tests, operator_shift_bool){ TEST(PIByteArray_Tests, operator_shift_bool){
PIByteArray arr1; PIByteArray arr1;
bool v = true; bool v = true;
arr1 << v; arr1 << v;
PIByteArray arr(1); PIByteArray arr(1);
arr[0] = 1; arr[0] = 1;
ASSERT_EQ(arr1, arr); ASSERT_EQ(arr1, arr);
} }
TEST(PIByteArray_Tests, operator_shift_char){ TEST(PIByteArray_Tests, operator_shift_char){
PIByteArray arr1; PIByteArray arr1;
char v = 'n'; char v = 'n';
arr1 << v; arr1 << v;
PIByteArray arr((void*)"n", 1); PIByteArray arr((void*)"n", 1);
ASSERT_EQ(arr1, arr); ASSERT_EQ(arr1, arr);
} }
TEST(PIByteArray_Tests, operator_shift_uchar){ TEST(PIByteArray_Tests, operator_shift_uchar){
PIByteArray arr1; PIByteArray arr1;
uchar v = 'n'; uchar v = 'n';
arr1 << v; arr1 << v;
PIByteArray arr((void*)"n", 1); PIByteArray arr((void*)"n", 1);
ASSERT_EQ(arr1, arr); ASSERT_EQ(arr1, arr);
} }
TEST(PIByteArray_Tests, operator_shift_short){ TEST(PIByteArray_Tests, operator_shift_short){
PIByteArray arr1; PIByteArray arr1;
const short v = -1; const short v = -1;
arr1 << v; arr1 << v;
PIByteArray arr(2); PIByteArray arr(2);
arr[0] = 255; arr[0] = 255;
arr[1] = 255; arr[1] = 255;
ASSERT_EQ(arr1, arr); ASSERT_EQ(arr1, arr);
} }
TEST(PIByteArray_Tests, operator_shift_int){ TEST(PIByteArray_Tests, operator_shift_int){
PIByteArray arr1; PIByteArray arr1;
const int v = -1; const int v = -1;
arr1 << v; arr1 << v;
PIByteArray arr(4); PIByteArray arr(4);
for (short i = 0; i < 4; i ++) arr[i] = 255; for (short i = 0; i < 4; i ++) arr[i] = 255;
ASSERT_EQ(arr1, arr); ASSERT_EQ(arr1, arr);
} }
TEST(PIByteArray_Tests, operator_shift_long){ TEST(PIByteArray_Tests, operator_shift_long){
PIByteArray arr1; PIByteArray arr1;
const long v = -1; const long v = -1;
arr1 << v; arr1 << v;
PIByteArray arr(4); PIByteArray arr(4);
for (short i = 0; i < 4; i ++) arr[i] = 255; for (short i = 0; i < 4; i ++) arr[i] = 255;
ASSERT_EQ(arr1, arr); ASSERT_EQ(arr1, arr);
} }
TEST(PIByteArray_Tests, operator_shift_llong){ TEST(PIByteArray_Tests, operator_shift_llong){
PIByteArray arr1; PIByteArray arr1;
const llong v = -1; const llong v = -1;
arr1 << v; arr1 << v;
PIByteArray arr(8); PIByteArray arr(8);
for (short i = 0; i < 8; i ++) arr[i] = 255; for (short i = 0; i < 8; i ++) arr[i] = 255;
ASSERT_EQ(arr1, arr); ASSERT_EQ(arr1, arr);
} }
TEST(PIByteArray_Tests, operator_shift_ushort){ TEST(PIByteArray_Tests, operator_shift_ushort){
PIByteArray arr1; PIByteArray arr1;
const ushort v = 254; const ushort v = 254;
arr1 << v; arr1 << v;
PIByteArray arr(2); PIByteArray arr(2);
arr[0] = 254; arr[0] = 254;
arr[1] = 0; arr[1] = 0;
ASSERT_EQ(arr1, arr); ASSERT_EQ(arr1, arr);
} }
TEST(PIByteArray_Tests, operator_shift_uint){ TEST(PIByteArray_Tests, operator_shift_uint){
PIByteArray arr1; PIByteArray arr1;
const uint v = 254; const uint v = 254;
arr1 << v; arr1 << v;
PIByteArray arr(4); PIByteArray arr(4);
arr[0] = 254; arr[0] = 254;
for (short i = 1; i < 4; i ++) arr[i] = 0; for (short i = 1; i < 4; i ++) arr[i] = 0;
ASSERT_EQ(arr1, arr); ASSERT_EQ(arr1, arr);
} }
TEST(PIByteArray_Tests, operator_shift_ulong){ TEST(PIByteArray_Tests, operator_shift_ulong){
PIByteArray arr1; PIByteArray arr1;
const ulong v = 254; const ulong v = 254;
arr1 << v; arr1 << v;
PIByteArray arr(4); PIByteArray arr(4);
arr[0] = 254; arr[0] = 254;
for (short i = 1; i < 4; i ++) arr[i] = 0; for (short i = 1; i < 4; i ++) arr[i] = 0;
ASSERT_EQ(arr1, arr); ASSERT_EQ(arr1, arr);
} }
TEST(PIByteArray_Tests, operator_shift_ullong){ TEST(PIByteArray_Tests, operator_shift_ullong){
PIByteArray arr1; PIByteArray arr1;
const ullong v = 254; const ullong v = 254;
arr1 << v; arr1 << v;
PIByteArray arr(8); PIByteArray arr(8);
arr[0] = 254; arr[0] = 254;
for (short i = 1; i < 8; i ++) arr[i] = 0; for (short i = 1; i < 8; i ++) arr[i] = 0;
ASSERT_EQ(arr, arr1); ASSERT_EQ(arr, arr1);
} }
TEST(PIByteArray_Tests, operator_shift_float){ TEST(PIByteArray_Tests, operator_shift_float){
PIByteArray arr1; PIByteArray arr1;
const float v = 31.764; const float v = 31.764;
arr1 << v; arr1 << v;
PIByteArray arr(4); PIByteArray arr(4);
arr[0] = 172; arr[0] = 172;
arr[1] = 28; arr[1] = 28;
arr[2] = 254; arr[2] = 254;
arr[3] = 65; arr[3] = 65;
ASSERT_EQ(arr1, arr); ASSERT_EQ(arr1, arr);
} }
TEST(PIByteArray_Tests, operator_shift_double){ TEST(PIByteArray_Tests, operator_shift_double){
PIByteArray arr1; PIByteArray arr1;
const double v = 3341.76422; const double v = 3341.76422;
arr1 << v; arr1 << v;
PIByteArray arr(8); PIByteArray arr(8);
arr[0] = 230; arr[0] = 230;
arr[1] = 5; arr[1] = 5;
arr[2] = 216; arr[2] = 216;
arr[3] = 71; arr[3] = 71;
arr[4] = 135; arr[4] = 135;
arr[5] = 27; arr[5] = 27;
arr[6] = 170; arr[6] = 170;
arr[7] = 64; arr[7] = 64;
ASSERT_EQ(arr, arr1); ASSERT_EQ(arr, arr1);
} }
TEST(PIByteArray_Tests, operator_shift_ldouble){ TEST(PIByteArray_Tests, operator_shift_ldouble){ //хуевый тест
PIByteArray arr1; PIByteArray arr1;
const ldouble v = 334451.761422; const ldouble v = 334451.761422;
arr1 << v; arr1 << v;
PIByteArray arr(16);
arr[0] = 0; PIByteArray arr(16);
arr[1] = 144; arr[0] = 0;
arr[2] = 171; arr[1] = 144;
arr[3] = 145; arr[2] = 171;
arr[4] = 93; arr[3] = 145;
arr[5] = 120; arr[4] = 93;
arr[6] = 78; arr[5] = 120;
arr[7] = 163; arr[6] = 78;
arr[8] = 17; arr[7] = 163;
arr[9] = 64; arr[8] = 17;
arr[10] = 0; arr[9] = 64;
arr[11] = 0; arr[10] = 218;
arr[12] = 0; arr[11] = 0;
arr[13] = 0; arr[12] = 0;
arr[14] = 0; arr[13] = 0;
arr[15] = 0; arr[14] = 0;
ASSERT_EQ(arr, arr1); arr[15] = 0;
piCout << arr1 << (arr == arr1);
//ASSERT_EQ(arr, arr1);
} }
TEST(PIByteArray_Tests, operator_shift_PIFlags){ TEST(PIByteArray_Tests, operator_shift_PIFlags){
PIByteArray arr; PIByteArray arr;
PIFlags<short> testFlags = 65; PIFlags<short> testFlags = 65;
arr << testFlags; arr << testFlags;
PIByteArray res(4); PIByteArray res(4);
res[0] = 65; res[0] = 65;
res[1] = 0; res[1] = 0;
res[2] = 0; res[2] = 0;
res[3] = 0; res[3] = 0;
ASSERT_EQ(res, arr); ASSERT_EQ(res, arr);
} }
TEST(PIByteArray_Tests, operator_shift_PIBA){ TEST(PIByteArray_Tests, operator_shift_PIBA){
PIByteArray arr; PIByteArray arr;
PIByteArray arr1((void*)"new", 3); PIByteArray arr1((void*)"new", 3);
arr << arr1; arr << arr1;
PIByteArray res(7); PIByteArray res(7);
res[0] = 3; res[0] = 3;
res[1] = 0; res[1] = 0;
res[2] = 0; res[2] = 0;
res[3] = 0; res[3] = 0;
res[4] = 110; res[4] = 110;
res[5] = 101; res[5] = 101;
res[6] = 119; res[6] = 119;
ASSERT_EQ(res, arr); ASSERT_EQ(res, arr);
} }
TEST(PIByteArray_Tests, operator_shift_RawData){ TEST(PIByteArray_Tests, operator_shift_RawData){
PIByteArray arr((void*)"n", 1); PIByteArray arr((void*)"n", 1);
PIByteArray::RawData dat((void*)"ew", 2); PIByteArray::RawData dat((void*)"ew", 2);
arr << dat; arr << dat;
PIByteArray res((void*)"new", 3); PIByteArray res((void*)"new", 3);
ASSERT_EQ(arr, res); ASSERT_EQ(arr, res);
} }
TEST(PIByteArray_Tests, operator_shift_right_bool){ TEST(PIByteArray_Tests, operator_shift_right_bool){
PIByteArray arr(1); PIByteArray arr(1);
arr[0] = 1; arr[0] = 1;
bool v; bool v;
arr >> v; arr >> v;
ASSERT_EQ(v, true); ASSERT_EQ(v, true);
} }
TEST(PIByteArray_Tests, operator_shift_right_char){ TEST(PIByteArray_Tests, operator_shift_right_char){
PIByteArray arr((void*)"n", 1); PIByteArray arr((void*)"n", 1);
char v; char v;
arr >> v; arr >> v;
ASSERT_EQ(v, 'n'); ASSERT_EQ(v, 'n');
} }
TEST(PIByteArray_Tests, operator_shift_right_uchar){ TEST(PIByteArray_Tests, operator_shift_right_uchar){
PIByteArray arr((void*)"n", 1); PIByteArray arr((void*)"n", 1);
uchar v; uchar v;
arr >> v; arr >> v;
ASSERT_EQ(v, 'n'); ASSERT_EQ(v, 'n');
} }
TEST(PIByteArray_Tests, operator_shift_right_short){ TEST(PIByteArray_Tests, operator_shift_right_short){
PIByteArray arr(2); PIByteArray arr(2);
arr[0] = 255; arr[0] = 255;
arr[1] = 255; arr[1] = 255;
short v; short v;
arr >> v; arr >> v;
ASSERT_EQ(v, -1); ASSERT_EQ(v, -1);
} }
TEST(PIByteArray_Tests, operator_shift_right_int){ TEST(PIByteArray_Tests, operator_shift_right_int){
PIByteArray arr(4); PIByteArray arr(4);
for (short i = 0; i < 4; i ++) arr[i] = 255; for (short i = 0; i < 4; i ++) arr[i] = 255;
int v; int v;
arr >> v; arr >> v;
ASSERT_EQ(v, -1); ASSERT_EQ(v, -1);
} }
TEST(PIByteArray_Tests, operator_shift_right_long){ TEST(PIByteArray_Tests, operator_shift_right_long){
PIByteArray arr(4); PIByteArray arr(4);
for (short i = 0; i < 4; i ++) arr[i] = 255; for (short i = 0; i < 4; i ++) arr[i] = 255;
long v = -1; long v = -1;
arr >> v; arr >> v;
ASSERT_EQ(v, -1); ASSERT_EQ(v, -1);
} }
TEST(PIByteArray_Tests, operator_shift_right_llong){ TEST(PIByteArray_Tests, operator_shift_right_llong){
PIByteArray arr(8); PIByteArray arr(8);
for (short i = 0; i < 8; i ++) arr[i] = 255; for (short i = 0; i < 8; i ++) arr[i] = 255;
llong v = -1; llong v = -1;
arr >> v; arr >> v;
ASSERT_EQ(v, -1); ASSERT_EQ(v, -1);
} }
TEST(PIByteArray_Tests, operator_shift_right_ushort){ TEST(PIByteArray_Tests, operator_shift_right_ushort){
PIByteArray arr(2); PIByteArray arr(2);
arr[0] = 254; arr[0] = 254;
arr[1] = 0; arr[1] = 0;
ushort v = 254; ushort v = 254;
arr >> v; arr >> v;
ASSERT_EQ(v, 254); ASSERT_EQ(v, 254);
} }
TEST(PIByteArray_Tests, operator_shift_right_uint){ TEST(PIByteArray_Tests, operator_shift_right_uint){
PIByteArray arr(4); PIByteArray arr(4);
arr[0] = 254; arr[0] = 254;
for (short i = 1; i < 4; i ++) arr[i] = 0; for (short i = 1; i < 4; i ++) arr[i] = 0;
uint v; uint v;
arr >> v; arr >> v;
ASSERT_EQ(v, 254); ASSERT_EQ(v, 254);
} }
TEST(PIByteArray_Tests, operator_shift_right_ulong){ TEST(PIByteArray_Tests, operator_shift_right_ulong){
PIByteArray arr(4); PIByteArray arr(4);
arr[0] = 254; arr[0] = 254;
for (short i = 1; i < 4; i ++) arr[i] = 0; for (short i = 1; i < 4; i ++) arr[i] = 0;
ulong v; ulong v;
arr >> v; arr >> v;
ASSERT_EQ(v, 254); ASSERT_EQ(v, 254);
} }
TEST(PIByteArray_Tests, operator_shift_right_ullong){ TEST(PIByteArray_Tests, operator_shift_right_ullong){
PIByteArray arr(8); PIByteArray arr(8);
arr[0] = 254; arr[0] = 254;
for (short i = 1; i < 8; i ++) arr[i] = 0; for (short i = 1; i < 8; i ++) arr[i] = 0;
ullong v; ullong v;
arr >> v; arr >> v;
ASSERT_EQ(v, 254); ASSERT_EQ(v, 254);
} }
TEST(PIByteArray_Tests, operator_shift_right_float){ TEST(PIByteArray_Tests, operator_shift_right_float){
PIByteArray arr(4); PIByteArray arr(4);
arr[0] = 172; arr[0] = 172;
arr[1] = 28; arr[1] = 28;
arr[2] = 254; arr[2] = 254;
arr[3] = 65; arr[3] = 65;
float v; float v;
float res = 31.764; float res = 31.764;
arr >> v; arr >> v;
ASSERT_EQ(v, res); ASSERT_EQ(v, res);
} }
TEST(PIByteArray_Tests, operator_shift_right_double){ /*TEST(DISABLEDPIByteArray_Tests, operator_shift_right_double){ //хуевый тест
PIByteArray arr(7); PIByteArray arr(7);
const double res = 3341.76422; const double res = 3341.76422;
double v; double v;
arr[0] = 230; arr[0] = 230;
arr[1] = 5; arr[1] = 5;
arr[2] = 216; arr[2] = 216;
arr[3] = 71; arr[3] = 71;
arr[4] = 135; arr[4] = 135;
arr[5] = 27; arr[5] = 27;
arr[6] = 170; arr[6] = 170;
arr[7] = 64; arr[7] = 64;
arr >> v; arr >> v;
ASSERT_EQ(v, res); ASSERT_EQ(v, res);
} }*/
TEST(PIByteArray_Tests, operator_shift_right_ldouble){ TEST(PIByteArray_Tests, operator_shift_right_ldouble){
PIByteArray arr(16); PIByteArray arr(16);
const ldouble res = 334451.761422; const ldouble res = 334451.761422;
ldouble v; ldouble v;
arr[0] = 0; arr[0] = 0;
arr[1] = 144; arr[1] = 144;
arr[2] = 171; arr[2] = 171;
arr[3] = 145; arr[3] = 145;
arr[4] = 93; arr[4] = 93;
arr[5] = 120; arr[5] = 120;
arr[6] = 78; arr[6] = 78;
arr[7] = 163; arr[7] = 163;
arr[8] = 17; arr[8] = 17;
arr[9] = 64; arr[9] = 64;
arr[10] = 0; arr[10] = 0;
arr[11] = 0; arr[11] = 0;
arr[12] = 0; arr[12] = 0;
arr[13] = 0; arr[13] = 0;
arr[14] = 0; arr[14] = 0;
arr[15] = 0; arr[15] = 0;
arr >> v; arr >> v;
ASSERT_EQ(v, res); ASSERT_EQ(v, res);
} }
TEST(PIByteArray_Tests, operator_shift_right_PIFlags){ TEST(PIByteArray_Tests, operator_shift_right_PIFlags){
PIFlags<short> testFlags; PIFlags<short> testFlags;
PIByteArray arr(4); PIByteArray arr(4);
arr[0] = 65; arr[0] = 65;
arr[1] = 0; arr[1] = 0;
arr[2] = 0; arr[2] = 0;
arr[3] = 0; arr[3] = 0;
arr >> testFlags; arr >> testFlags;
PIFlags<short> res = 65; PIFlags<short> res = 65;
ASSERT_EQ(res, testFlags); ASSERT_EQ(res, testFlags);
} }
TEST(PIByteArray_Tests, operator_shift_right_PIBA){ TEST(PIByteArray_Tests, operator_shift_right_PIBA){
PIByteArray arr1; PIByteArray arr1;
PIByteArray arr(7); PIByteArray arr(7);
arr[0] = 3; arr[0] = 3;
arr[1] = 0; arr[1] = 0;
arr[2] = 0; arr[2] = 0;
arr[3] = 0; arr[3] = 0;
arr[4] = 110; arr[4] = 110;
arr[5] = 101; arr[5] = 101;
arr[6] = 119; arr[6] = 119;
arr >> arr1; arr >> arr1;
PIByteArray res((void*)"new", 3); PIByteArray res((void*)"new", 3);
ASSERT_EQ(res, arr1); ASSERT_EQ(res, arr1);
} }
TEST(PIByteArray_Tests, operator_shift_right_RawData){ TEST(PIByteArray_Tests, operator_shift_right_RawData){
PIByteArray arr((void*)"new", 3); PIByteArray arr((void*)"new", 3);
PIByteArray::RawData dat; PIByteArray::RawData dat;
arr >> dat; arr >> dat;
PIByteArray::RawData res((void*)"new", 3); PIByteArray::RawData res((void*)"new", 3);
PIByteArray res_arr; PIByteArray res_arr;
res_arr << res; res_arr << res;
ASSERT_EQ(res_arr, arr); ASSERT_EQ(res_arr, arr);
} }
TEST(PIByteArray_Tests, operator_shift_PIPair){ TEST(PIByteArray_Tests, operator_shift_PIPair){
PIByteArray arr; PIByteArray arr;
PIPair<int, bool> par; PIPair<int, bool> par;
par.first = 43; par.first = 43;
par.second = true; par.second = true;
arr << par; arr << par;
PIByteArray res(5); PIByteArray res(5);
res[0] = 43; res[0] = 43;
res[1] = 0; res[1] = 0;
res[2] = 0; res[2] = 0;
res[3] = 0; res[3] = 0;
res[4] = 1; res[4] = 1;
ASSERT_EQ(res, arr); ASSERT_EQ(res, arr);
} }
TEST(PIByteArray_Tests, operator_shift_PIVector){ TEST(PIByteArray_Tests, operator_shift_PIVector){
PIByteArray arr; PIByteArray arr;
PIVector<char> vect; PIVector<char> vect;
vect.append('n'); vect.append('n');
vect.append('e'); vect.append('e');
vect.append('w'); vect.append('w');
arr << vect; arr << vect;
PIByteArray res(7); PIByteArray res(7);
res[0] = 3; res[0] = 3;
res[1] = 0; res[1] = 0;
res[2] = 0; res[2] = 0;
res[3] = 0; res[3] = 0;
res[4] = 110; res[4] = 110;
res[5] = 101; res[5] = 101;
res[6] = 119; res[6] = 119;
ASSERT_EQ(res, arr); ASSERT_EQ(res, arr);
} }
TEST(PIByteArray_Tests, operator_shift_PIDeque){ TEST(PIByteArray_Tests, operator_shift_PIDeque){
PIByteArray arr; PIByteArray arr;
PIDeque<char> deq; PIDeque<char> deq;
deq.append('n'); deq.append('n');
deq.append('e'); deq.append('e');
deq.append('w'); deq.append('w');
arr << deq; arr << deq;
PIByteArray res(7); PIByteArray res(7);
res[0] = 3; res[0] = 3;
res[1] = 0; res[1] = 0;
res[2] = 0; res[2] = 0;
res[3] = 0; res[3] = 0;
res[4] = 110; res[4] = 110;
res[5] = 101; res[5] = 101;
res[6] = 119; res[6] = 119;
ASSERT_EQ(arr, res); ASSERT_EQ(arr, res);
} }
TEST(PIByteArray_Tests, operator_shift_PIMap){ TEST(PIByteArray_Tests, operator_shift_PIMap){
PIByteArray arr; PIByteArray arr;
PIMap<char, char> mp; PIMap<char, char> mp;
mp['2'] = 'e'; mp['2'] = 'e';
mp['1'] = 'n'; mp['1'] = 'n';
mp['3'] = 'w'; mp['3'] = 'w';
arr << mp; arr << mp;
PIByteArray res(26); PIByteArray res(26);
res[0] = 3; //size res[0] = 3; //size
res[1] = 0; res[1] = 0;
res[2] = 0; res[2] = 0;
res[3] = 0; res[3] = 0;
res[4] = 1; //key index res[4] = 1; //key index
res[5] = 0; res[5] = 0;
res[6] = 0; res[6] = 0;
res[7] = 0; res[7] = 0;
res[8] = 49; //key content res[8] = 49; //key content
res[9] = 0; //key index res[9] = 0; //key index
res[10] = 0; res[10] = 0;
res[11] = 0; res[11] = 0;
res[12] = 0; res[12] = 0;
res[13] = 50; // key content res[13] = 50; // key content
res[14] = 2; //key index res[14] = 2; //key index
res[15] = 0; res[15] = 0;
res[16] = 0; res[16] = 0;
res[17] = 0; res[17] = 0;
res[18] = 51; //key 3 res[18] = 51; //key 3
res[19] = 3; //number content res[19] = 3; //number content
res[20] = 0; res[20] = 0;
res[21] = 0; res[21] = 0;
res[22] = 0; res[22] = 0;
res[23] = 101; //data 'e' res[23] = 101; //data 'e'
res[24] = 110; //data 'n' res[24] = 110; //data 'n'
res[25] = 119; //data 'w' res[25] = 119; //data 'w'
ASSERT_EQ(arr, res); ASSERT_EQ(arr, res);
} }
TEST(PIByteArray_Tests, operator_shift_PIChar){ TEST(PIByteArray_Tests, operator_shift_PIChar){
PIByteArray arr; PIByteArray arr;
PIChar ch = "n"; PIChar ch = "n";
arr << ch; arr << ch;
PIByteArray res(2); PIByteArray res(2);
res[0] = 110; res[0] = 110;
res[1] = 0; res[1] = 0;
ASSERT_EQ(res, arr); ASSERT_EQ(res, arr);
} }
TEST(PIByteArray_Tests, operator_shift_right_PIPair){ TEST(PIByteArray_Tests, operator_shift_right_PIPair){
PIByteArray arr(5); PIByteArray arr(5);
arr[0] = 43; arr[0] = 43;
arr[1] = 0; arr[1] = 0;
arr[2] = 0; arr[2] = 0;
arr[3] = 0; arr[3] = 0;
arr[4] = 1; arr[4] = 1;
PIPair<int, bool> par; PIPair<int, bool> par;
PIPair<int, bool> res; PIPair<int, bool> res;
res.first = 43; res.first = 43;
res.second = true; res.second = true;
arr >> par; arr >> par;
ASSERT_EQ(res, par); ASSERT_EQ(res, par);
} }
TEST(PIByteArray_Tests, operator_shift_right_PIVector){ TEST(PIByteArray_Tests, operator_shift_right_PIVector){
PIByteArray arr(7); PIByteArray arr(7);
arr[0] = 3; arr[0] = 3;
arr[1] = 0; arr[1] = 0;
arr[2] = 0; arr[2] = 0;
arr[3] = 0; arr[3] = 0;
arr[4] = 110; arr[4] = 110;
arr[5] = 101; arr[5] = 101;
arr[6] = 119; arr[6] = 119;
PIVector<char> vec; PIVector<char> vec;
PIVector<char> vect; PIVector<char> vect;
vect.append('n'); vect.append('n');
vect.append('e'); vect.append('e');
vect.append('w'); vect.append('w');
arr >> vec; arr >> vec;
ASSERT_EQ(vec, vect); ASSERT_EQ(vec, vect);
} }
TEST(PIByteArray_Tests, operator_shift_right_PIDeque){ TEST(PIByteArray_Tests, operator_shift_right_PIDeque){
PIDeque<char> deq; PIDeque<char> deq;
PIByteArray arr1(7); PIByteArray arr1(7);
arr1[0] = 3; arr1[0] = 3;
arr1[1] = 0; arr1[1] = 0;
arr1[2] = 0; arr1[2] = 0;
arr1[3] = 0; arr1[3] = 0;
arr1[4] = 110; arr1[4] = 110;
arr1[5] = 101; arr1[5] = 101;
arr1[6] = 119; arr1[6] = 119;
arr1 >> deq; arr1 >> deq;
PIDeque<char> res; PIDeque<char> res;
res.append('n'); res.append('n');
res.append('e'); res.append('e');
res.append('w'); res.append('w');
ASSERT_EQ(deq, res); ASSERT_EQ(deq, res);
} }
TEST(PIByteArray_Tests, operator_shift_right_PIMap){ TEST(PIByteArray_Tests, operator_shift_right_PIMap){
PIByteArray arr(26); PIByteArray arr(26);
arr[0] = 3; //size arr[0] = 3; //size
arr[1] = 0; arr[1] = 0;
arr[2] = 0; arr[2] = 0;
arr[3] = 0; arr[3] = 0;
arr[4] = 1; //key index arr[4] = 1; //key index
arr[5] = 0; arr[5] = 0;
arr[6] = 0; arr[6] = 0;
arr[7] = 0; arr[7] = 0;
arr[8] = 49; //key content arr[8] = 49; //key content
arr[9] = 0; //key index arr[9] = 0; //key index
arr[10] = 0; arr[10] = 0;
arr[11] = 0; arr[11] = 0;
arr[12] = 0; arr[12] = 0;
arr[13] = 50; // key content arr[13] = 50; // key content
arr[14] = 2; //key index arr[14] = 2; //key index
arr[15] = 0; arr[15] = 0;
arr[16] = 0; arr[16] = 0;
arr[17] = 0; arr[17] = 0;
arr[18] = 51; //key 3 arr[18] = 51; //key 3
arr[19] = 3; //number content arr[19] = 3; //number content
arr[20] = 0; arr[20] = 0;
arr[21] = 0; arr[21] = 0;
arr[22] = 0; arr[22] = 0;
arr[23] = 101; //data 'e' arr[23] = 101; //data 'e'
arr[24] = 110; //data 'n' arr[24] = 110; //data 'n'
arr[25] = 119; //data 'w' arr[25] = 119; //data 'w'
PIMap<char, char> mp; PIMap<char, char> mp;
arr >> mp; arr >> mp;
PIMap<char, char> res; PIMap<char, char> res;
res['2'] = 'e'; res['2'] = 'e';
res['1'] = 'n'; res['1'] = 'n';
res['3'] = 'w'; res['3'] = 'w';
ASSERT_EQ(mp, res); ASSERT_EQ(mp, res);
} }
TEST(PIByteArray_Tests, operator_shift_right_PIChar){ TEST(PIByteArray_Tests, operator_shift_right_PIChar){
PIChar ch; PIChar ch;
PIByteArray arr(2); PIByteArray arr(2);
arr[0] = 110; arr[0] = 110;
arr[1] = 0; arr[1] = 0;
arr >> ch; arr >> ch;
PIChar res = "n"; PIChar res = "n";
ASSERT_EQ(res, ch); ASSERT_EQ(res, ch);
} }
TEST(PIByteArray_Tests, operator_shift_PIBitArr){ TEST(PIByteArray_Tests, operator_shift_PIBitArr){
PIBitArray bit(2); PIBitArray bit(2);
bit.setBit(0); bit.setBit(0);
bit.setBit(1); bit.setBit(1);
PIByteArray arr; PIByteArray arr;
arr << bit; arr << bit;
PIByteArray res(9); PIByteArray res(9);
res[0] = 2; res[0] = 2;
res[1] = 0; res[1] = 0;
res[2] = 0; res[2] = 0;
res[3] = 0; res[3] = 0;
res[4] = 1; res[4] = 1;
res[5] = 0; res[5] = 0;
res[6] = 0; res[6] = 0;
res[7] = 0; res[7] = 0;
res[8] = 3; res[8] = 3;
ASSERT_EQ(res, arr); ASSERT_EQ(res, arr);
} }
TEST(PIByteArray_Tests, operator_shift_PIVector2D){ TEST(PIByteArray_Tests, operator_shift_PIVector2D){
PIByteArray arr; PIByteArray arr;
PIVector2D<char> vec2(2,3); PIVector2D<char> vec2(2,3);
vec2.element(0, 0) = 'n'; vec2.element(0, 0) = 'n';
vec2.element(0, 1) = 'e'; vec2.element(0, 1) = 'e';
vec2.element(0, 2) = 'w'; vec2.element(0, 2) = 'w';
vec2.element(1, 0) = 'o'; vec2.element(1, 0) = 'o';
vec2.element(1, 1) = 'l'; vec2.element(1, 1) = 'l';
vec2.element(1, 2) = 'd'; vec2.element(1, 2) = 'd';
arr << vec2; arr << vec2;
PIByteArray res(14); PIByteArray res(14);
res[0] = 2; res[0] = 2;
res[1] = 0; res[1] = 0;
res[2] = 0; res[2] = 0;
res[3] = 0; res[3] = 0;
res[4] = 3; res[4] = 3;
res[5] = 0; res[5] = 0;
res[6] = 0; res[6] = 0;
res[7] = 0; res[7] = 0;
res[8] = 110; res[8] = 110;
res[9] = 101; res[9] = 101;
res[10] = 119; res[10] = 119;
res[11] = 111; res[11] = 111;
res[12] = 108; res[12] = 108;
res[13] = 100; res[13] = 100;
ASSERT_EQ(arr, res); ASSERT_EQ(arr, res);
} }
TEST(PIByteArray_Tests, operator_shift_right_PIBitArr){ TEST(PIByteArray_Tests, operator_shift_right_PIBitArr){
PIBitArray bit; PIBitArray bit;
PIByteArray arr(9); PIByteArray arr(9);
arr[0] = 2; arr[0] = 2;
arr[1] = 0; arr[1] = 0;
arr[2] = 0; arr[2] = 0;
arr[3] = 0; arr[3] = 0;
arr[4] = 1; arr[4] = 1;
arr[5] = 0; arr[5] = 0;
arr[6] = 0; arr[6] = 0;
arr[7] = 0; arr[7] = 0;
arr[8] = 3; arr[8] = 3;
arr >> bit; arr >> bit;
PIBitArray res(2); PIBitArray res(2);
res.setBit(0); res.setBit(0);
res.setBit(1); res.setBit(1);
ASSERT_EQ(res, bit); ASSERT_EQ(res, bit);
} }
TEST(PIByteArray_Tests, operator_shift_right_PIVector2D){ TEST(PIByteArray_Tests, operator_shift_right_PIVector2D){
PIVector2D<char> vec2(2,3); PIVector2D<char> vec2(2,3);
PIByteArray arr(14); PIByteArray arr(14);
arr[0] = 2; arr[0] = 2;
arr[1] = 0; arr[1] = 0;
arr[2] = 0; arr[2] = 0;
arr[3] = 0; arr[3] = 0;
arr[4] = 3; arr[4] = 3;
arr[5] = 0; arr[5] = 0;
arr[6] = 0; arr[6] = 0;
arr[7] = 0; arr[7] = 0;
arr[8] = 110; arr[8] = 110;
arr[9] = 101; arr[9] = 101;
arr[10] = 119; arr[10] = 119;
arr[11] = 111; arr[11] = 111;
arr[12] = 108; arr[12] = 108;
arr[13] = 100; arr[13] = 100;
arr >> vec2; arr >> vec2;
PIVector2D<char> res(2,3); PIVector2D<char> res(2,3);
res.element(0, 0) = 'n'; res.element(0, 0) = 'n';
res.element(0, 1) = 'e'; res.element(0, 1) = 'e';
res.element(0, 2) = 'w'; res.element(0, 2) = 'w';
res.element(1, 0) = 'o'; res.element(1, 0) = 'o';
res.element(1, 1) = 'l'; res.element(1, 1) = 'l';
res.element(1, 2) = 'd'; res.element(1, 2) = 'd';
ASSERT_EQ(vec2.element(0,0), res.element(0,0)); ASSERT_EQ(vec2.element(0,0), res.element(0,0));
ASSERT_EQ(vec2.element(0,1), res.element(0,1)); ASSERT_EQ(vec2.element(0,1), res.element(0,1));
ASSERT_EQ(vec2.element(0,2), res.element(0,2)); ASSERT_EQ(vec2.element(0,2), res.element(0,2));
ASSERT_EQ(vec2.element(1,0), res.element(1,0)); ASSERT_EQ(vec2.element(1,0), res.element(1,0));
ASSERT_EQ(vec2.element(1,1), res.element(1,1)); ASSERT_EQ(vec2.element(1,1), res.element(1,1));
ASSERT_EQ(vec2.element(1,2), res.element(1,2)); ASSERT_EQ(vec2.element(1,2), res.element(1,2));
} }
TEST(PIByteArray_Tests, operator_shift_template){ TEST(PIByteArray_Tests, operator_shift_template){
PIByteArray arr; PIByteArray arr;
char ch = 'n'; char ch = 'n';
arr << ch; arr << ch;
PIByteArray res(1); PIByteArray res(1);
res[0] = 110; res[0] = 110;
ASSERT_EQ(arr, res); ASSERT_EQ(arr, res);
} }
TEST(PIByteArray_Tests, operator_shift_right_template){ TEST(PIByteArray_Tests, operator_shift_right_template){
PIByteArray arr(1); PIByteArray arr(1);
arr[0] = 110; arr[0] = 110;
char ch; char ch;
arr >> ch; arr >> ch;
char res = 'n'; char res = 'n';
ASSERT_EQ(ch, res); ASSERT_EQ(ch, res);
} }
TEST(PIByteArray_Tests, operator_equality){ TEST(PIByteArray_Tests, operator_equality){
PIByteArray arr1((void*)"new", 3); PIByteArray arr1((void*)"new", 3);
PIByteArray arr(3); PIByteArray arr(3);
arr[0] = 110; arr[0] = 110;
arr[1] = 101; arr[1] = 101;
arr[2] = 119; arr[2] = 119;
ASSERT_TRUE(arr1 == arr); ASSERT_TRUE(arr1 == arr);
} }
TEST(PIByteArray_Tests, operator_not_equality){ TEST(PIByteArray_Tests, operator_not_equality){
PIByteArray arr1((void*)"new", 3); PIByteArray arr1((void*)"new", 3);
PIByteArray arr(3); PIByteArray arr(3);
arr[0] = 110; arr[0] = 110;
arr[1] = 101; arr[1] = 101;
arr[2] = 11; arr[2] = 11;
ASSERT_TRUE(arr1 != arr); ASSERT_TRUE(arr1 != arr);
} }
TEST(PIByteArray_Tests, operator_equality_size){ TEST(PIByteArray_Tests, operator_equality_size){
PIByteArray arr1((void*)"new", 3); PIByteArray arr1((void*)"new", 3);
PIByteArray arr(2); PIByteArray arr(2);
arr[0] = 110; arr[0] = 110;
arr[1] = 101; arr[1] = 101;
ASSERT_FALSE(arr1 == arr); ASSERT_FALSE(arr1 == arr);
} }
TEST(PIByteArray_Tests, operator_not_equality_size){ TEST(PIByteArray_Tests, operator_not_equality_size){
PIByteArray arr1((void*)"new", 3); PIByteArray arr1((void*)"new", 3);
PIByteArray arr(2); PIByteArray arr(2);
arr[0] = 110; arr[0] = 110;
arr[1] = 101; arr[1] = 101;
ASSERT_TRUE(arr1 != arr); ASSERT_TRUE(arr1 != arr);
} }
TEST(PIByteArray_Tests, operator_equality_false){ TEST(PIByteArray_Tests, operator_equality_false){
PIByteArray arr1((void*)"new", 3); PIByteArray arr1((void*)"new", 3);
PIByteArray arr(3); PIByteArray arr(3);
arr[0] = 110; arr[0] = 110;
arr[1] = 101; arr[1] = 101;
arr[2] = 11; arr[2] = 11;
ASSERT_FALSE(arr1 == arr); ASSERT_FALSE(arr1 == arr);
} }
TEST(PIByteArray_Tests, operator_not_equality_false){ TEST(PIByteArray_Tests, operator_not_equality_false){
PIByteArray arr1((void*)"new", 3); PIByteArray arr1((void*)"new", 3);
PIByteArray arr(3); PIByteArray arr(3);
arr[0] = 110; arr[0] = 110;
arr[1] = 101; arr[1] = 101;
arr[2] = 119; arr[2] = 119;
ASSERT_FALSE(arr1 != arr); ASSERT_FALSE(arr1 != arr);
} }
TEST(PIByteArray_Tests, pi_hash){ TEST(PIByteArray_Tests, pi_hash){
PIByteArray arr(3); PIByteArray arr(3);
arr[0] = 110; arr[0] = 110;
arr[1] = 101; arr[1] = 101;
arr[2] = 119; arr[2] = 119;
ASSERT_EQ(piHash(arr), 422208903); ASSERT_EQ(piHash(arr), 422208903);
} }
TEST(PIByteArray_Tests, pi_swap){ TEST(PIByteArray_Tests, pi_swap){
PIByteArray arr1((void*)"new", 3); PIByteArray arr1((void*)"new", 3);
PIByteArray arr2((void*)"old", 3); PIByteArray arr2((void*)"old", 3);
piSwap(arr1, arr2); piSwap(arr1, arr2);
PIByteArray arr(3); PIByteArray arr(3);
arr[0] = 110; arr[0] = 110;
arr[1] = 101; arr[1] = 101;
arr[2] = 119; arr[2] = 119;
ASSERT_EQ(arr, arr2); ASSERT_EQ(arr, arr2);
} }
TEST(PIByteArray_Tests, pi_swap_sec){ TEST(PIByteArray_Tests, pi_swap_sec){
PIByteArray arr1((void*)"new", 3); PIByteArray arr1((void*)"new", 3);
PIByteArray arr2((void*)"old", 3); PIByteArray arr2((void*)"old", 3);
piSwap(arr1, arr2); piSwap(arr1, arr2);
PIByteArray arr(3); PIByteArray arr(3);
arr[0] = 111; arr[0] = 111;
arr[1] = 108; arr[1] = 108;
arr[2] = 100; arr[2] = 100;
ASSERT_EQ(arr, arr1); ASSERT_EQ(arr, arr1);
} }

View File

@@ -2,3185 +2,3195 @@
#include "pistring.h" #include "pistring.h"
#include "pistringlist.h" #include "pistringlist.h"
using namespace std;
TEST(PIString_Tests, constructor_empty){
PIString str1;
ASSERT_TRUE(str1.isEmpty());
}
TEST(PIString_Tests, operator_concatenation_pichar){ TEST(PIString_Tests, operator_concatenation_pichar){
PIString str1 = "AB C"; PIString str1 = "AB C";
const PIChar str2 = " "; const PIChar str2 = " ";
str1 += str2; str1 += str2;
PIString res = "AB C "; PIString res = "AB C ";
ASSERT_EQ(str1, res); ASSERT_EQ(str1, res);
} }
TEST(PIString_Tests, operator_concatenation_pichar_zero1){ TEST(PIString_Tests, operator_concatenation_pichar_zero1){
PIString str1 = ""; PIString str1 = "";
const PIChar str2 = "D"; const PIChar str2 = "D";
str1 += str2; str1 += str2;
ASSERT_EQ(str1, "D"); ASSERT_EQ(str1, "D");
} }
TEST(PIString_Tests, operator_concatenation_char){ TEST(PIString_Tests, operator_concatenation_char){
PIString str1 = "AB C"; PIString str1 = "AB C";
const char *str2 = "D D "; const char *str2 = "D D ";
str1 += str2; str1 += str2;
ASSERT_EQ(str1, "AB CD D "); ASSERT_EQ(str1, "AB CD D ");
} }
TEST(PIString_Tests, operator_concatenation_char_zero1){ TEST(PIString_Tests, operator_concatenation_char_zero1){
PIString str1 = ""; PIString str1 = "";
const char *str2 = "D D "; const char *str2 = "D D ";
str1 += str2; str1 += str2;
ASSERT_EQ(str1, "D D "); ASSERT_EQ(str1, "D D ");
} }
TEST(PIString_Tests, operator_concatenation_wchar){ TEST(PIString_Tests, operator_concatenation_wchar){
PIString str1= "AB C"; PIString str1= "AB C";
wchar_t str2[] = L"C"; wchar_t str2[] = L"C";
str1 += str2; str1 += str2;
ASSERT_EQ(str1, "AB CC"); ASSERT_EQ(str1, "AB CC");
} }
TEST(PIString_Tests, operator_concatenation_wchar_zero1){ TEST(PIString_Tests, operator_concatenation_wchar_zero1){
PIString str1 = ""; PIString str1 = "";
wchar_t str2[] = L"C"; wchar_t str2[] = L"C";
str1 += str2; str1 += str2;
ASSERT_EQ(str1, "C"); ASSERT_EQ(str1, "C");
} }
TEST(PIString_Tests, operator_concatenation_pistring){ TEST(PIString_Tests, operator_concatenation_pistring){
PIString str1 = "AB C"; PIString str1 = "AB C";
PIString str2 = " CD "; PIString str2 = " CD ";
str1 += str2; str1 += str2;
ASSERT_EQ(str1, "AB C CD "); ASSERT_EQ(str1, "AB C CD ");
} }
TEST(PIString_Tests, operator_concatenation_pistring_zero1){ TEST(PIString_Tests, operator_concatenation_pistring_zero1){
PIString str1 = ""; PIString str1 = "";
PIString str2 = "D DD"; PIString str2 = "D DD";
str1 += str2; str1 += str2;
ASSERT_EQ(str1, "D DD"); ASSERT_EQ(str1, "D DD");
} }
TEST(PIString_Tests, operator_concatenation_pistring_zero2){ TEST(PIString_Tests, operator_concatenation_pistring_zero2){
PIString str1 = "AB C"; PIString str1 = "AB C";
PIString str2 = ""; PIString str2 = "";
str1 += str2; str1 += str2;
ASSERT_EQ(str1, "AB C"); ASSERT_EQ(str1, "AB C");
} }
TEST(PIString_Tests, operator_concatenation_pistring_zero_zero){ TEST(PIString_Tests, operator_concatenation_pistring_zero_zero){
PIString str1; PIString str1;
PIString str2; PIString str2;
str1 += str2; str1 += str2;
ASSERT_EQ(str1, ""); ASSERT_EQ(str1, "");
} }
TEST(PIString_Tests, operator_concatenation_piByteArray){ TEST(PIString_Tests, operator_concatenation_piByteArray){
PIString str1 = "AB C"; PIString str1 = "AB C";
PIByteArray str2; PIByteArray str2;
str2.append('g'); str2.append('g');
str1 += str2; str1 += str2;
ASSERT_EQ(str1, "AB Cg"); ASSERT_EQ(str1, "AB Cg");
} }
TEST(PIString_Tests, operator_concatenation_piByteArray_zero1){ TEST(PIString_Tests, operator_concatenation_piByteArray_zero1){
PIString str1 = ""; PIString str1 = "";
PIByteArray str2; PIByteArray str2;
str2.append('0'); str2.append('0');
str1 += str2; str1 += str2;
ASSERT_EQ(str1, "0"); ASSERT_EQ(str1, "0");
} }
TEST(PIString_Tests, operator_concatenation_piByteArray_zero2){ TEST(PIString_Tests, operator_concatenation_piByteArray_zero2){
PIString str1 = "AB C"; PIString str1 = "AB C";
PIByteArray str2; PIByteArray str2;
str1 += str2; str1 += str2;
ASSERT_EQ(str1, "AB C"); ASSERT_EQ(str1, "AB C");
} }
TEST(PIString_Tests, operator_concatenation_piByteArray_zero_zero){ TEST(PIString_Tests, operator_concatenation_piByteArray_zero_zero){
PIString str1; PIString str1;
PIByteArray str2; PIByteArray str2;
str1 += str2; str1 += str2;
ASSERT_EQ(str1, ""); ASSERT_EQ(str1, "");
} }
TEST(PIString_Tests, construct_pistring){ TEST(PIString_Tests, construct_pistring){
PIString str1 = "New"; PIString str1 = "New";
ASSERT_EQ(str1, PIString("New")); PIString str(str1);
ASSERT_EQ(str1, str);
} }
TEST(PIString_Tests, construct_pichar){ TEST(PIString_Tests, construct_pichar){
PIChar str1 = 'n'; PIChar str1 = 'n';
PIString res = "n"; PIString res = "n";
ASSERT_EQ(res, PIString(str1)); ASSERT_EQ(res, PIString(str1));
} }
TEST(PIString_Tests, construct_char){ TEST(PIString_Tests, construct_char){
char str1 = 'n'; char str1 = 'n';
PIString res = "n"; PIString res = "n";
ASSERT_EQ(res, PIString(str1)); ASSERT_EQ(res, PIString(str1));
} }
TEST(PIString_Tests, construct_chars){ TEST(PIString_Tests, construct_chars){
char str1[] = "mew"; char str1[] = "mew";
PIString res = "mew"; PIString res = "mew";
ASSERT_EQ(res, PIString(str1)); ASSERT_EQ(res, PIString(str1));
} }
TEST(PIString_Tests, construct_wchar_t){ TEST(PIString_Tests, construct_wchar_t){
wchar_t str1[] = L"gav"; wchar_t str1[] = L"gav";
PIString res = "gav"; PIString res = "gav";
ASSERT_EQ(res, PIString(str1)); ASSERT_EQ(res, PIString(str1));
} }
TEST(PIString_Tests, construct_pibyte_array){ TEST(PIString_Tests, construct_pibyte_array){
PIByteArray str1; PIByteArray str1;
str1.append('m'); str1.append('m');
PIString res = "m"; PIString res = "m";
ASSERT_EQ(res, PIString(str1)); ASSERT_EQ(res, PIString(str1));
} }
TEST(PIString_Tests, construct_pichar_size){ TEST(PIString_Tests, construct_pichar_size){
PIChar *str1 = new PIChar[3]; PIChar *str1 = new PIChar[3];
str1[0] = 'n'; str1[0] = 'n';
str1[1] = 'e'; str1[1] = 'e';
str1[2] = 'w'; str1[2] = 'w';
PIString res = "new"; PIString res = "new";
ASSERT_EQ(res, PIString(str1, 3)); ASSERT_EQ(res, PIString(str1, 3));
} }
TEST(PIString_Tests, construct_char_size){ TEST(PIString_Tests, construct_char_size){
char str1[] = "good"; char str1[] = "good";
PIString res = "good"; PIString res = "good";
ASSERT_EQ(res, PIString(str1, 4)); ASSERT_EQ(res, PIString(str1, 4));
} }
TEST(PIString_Tests, construct_char_len){ TEST(PIString_Tests, construct_char_len){
char str1 = 'n'; char str1 = 'n';
PIString res = "nnn"; PIString res = "nnn";
ASSERT_EQ(res, PIString(3, str1)); ASSERT_EQ(res, PIString(3, str1));
} }
TEST(PIString_Tests, construct_pichar_len){ TEST(PIString_Tests, construct_pichar_len){
PIChar str1 = 'n'; PIChar str1 = 'n';
PIString res = "nnnnn"; PIString res = "nnnnn";
ASSERT_EQ(res, PIString(5, str1)); ASSERT_EQ(res, PIString(5, str1));
} }
TEST(PIString_Tests, operator_symbol){ TEST(PIString_Tests, operator_symbol){
PIString str1 = "testing"; PIString str1 = "testing";
PIChar symbo = "i"; PIChar symbo = "i";
ASSERT_EQ(symbo, str1[4]); ASSERT_EQ(symbo, str1[4]);
} }
TEST(PIString_Tests, operator_compare_pistring_true){ TEST(PIString_Tests, operator_compare_pistring_true){
PIString str1 = "testing"; PIString str1 = "testing";
PIString str2 = "testing"; PIString str2 = "testing";
ASSERT_TRUE(str1 == str2); ASSERT_TRUE(str1 == str2);
} }
TEST(PIString_Tests, operator_compare_pistring_false){ TEST(PIString_Tests, operator_compare_pistring_false){
PIString str1 = "tes"; PIString str1 = "tes";
PIString str2 = "testing"; PIString str2 = "testing";
ASSERT_FALSE(str1 == str2); ASSERT_FALSE(str1 == str2);
} }
TEST(PIString_Tests, operator_compare_pichar_true){ TEST(PIString_Tests, operator_compare_pichar_true){
PIString str1 = "t"; PIString str1 = "t";
PIChar str2 = "t"; PIChar str2 = "t";
ASSERT_TRUE(str1 == str2); ASSERT_TRUE(str1 == str2);
} }
TEST(PIString_Tests, operator_compare_pichar_false){ TEST(PIString_Tests, operator_compare_pichar_false){
PIString str1 = "t"; PIString str1 = "t";
PIChar str2 = "p"; PIChar str2 = "p";
ASSERT_FALSE(str1 == str2); ASSERT_FALSE(str1 == str2);
} }
TEST(PIString_Tests, operator_compare_char_true){ TEST(PIString_Tests, operator_compare_char_true){
PIString str1 = "test"; PIString str1 = "test";
char str2[] = "test"; char str2[] = "test";
ASSERT_TRUE(str1 == str2); ASSERT_TRUE(str1 == str2);
} }
TEST(PIString_Tests, operator_compare_char_false){ TEST(PIString_Tests, operator_compare_char_false){
PIString str1 = "t"; PIString str1 = "t";
char str2[] = "test"; char str2[] = "test";
ASSERT_FALSE(str1 == str2); ASSERT_FALSE(str1 == str2);
} }
TEST(PIString_Tests, operator_encompare_pistring_false){ TEST(PIString_Tests, operator_encompare_pistring_false){
PIString str1 = "testing"; PIString str1 = "testing";
PIString str2 = "testing"; PIString str2 = "testing";
ASSERT_FALSE(str1 != str2); ASSERT_FALSE(str1 != str2);
} }
TEST(PIString_Tests, operator_encompare_pistring_true){ TEST(PIString_Tests, operator_encompare_pistring_true){
PIString str1 = "tes"; PIString str1 = "tes";
PIString str2 = "testing"; PIString str2 = "testing";
ASSERT_TRUE(str1 != str2); ASSERT_TRUE(str1 != str2);
} }
TEST(PIString_Tests, operator_encompare_pichar_false){ TEST(PIString_Tests, operator_encompare_pichar_false){
PIString str1 = "t"; PIString str1 = "t";
PIChar str2 = "t"; PIChar str2 = "t";
ASSERT_FALSE(str1 != str2); ASSERT_FALSE(str1 != str2);
} }
TEST(PIString_Tests, operator_encompare_pichar_true){ TEST(PIString_Tests, operator_encompare_pichar_true){
PIString str1 = "t"; PIString str1 = "t";
PIChar str2 = "p"; PIChar str2 = "p";
ASSERT_TRUE(str1 != str2); ASSERT_TRUE(str1 != str2);
} }
TEST(PIString_Tests, operator_encompare_char_false){ TEST(PIString_Tests, operator_encompare_char_false){
PIString str1 = "test"; PIString str1 = "test";
char str2[] = "test"; char str2[] = "test";
ASSERT_FALSE(str1 != str2); ASSERT_FALSE(str1 != str2);
} }
TEST(PIString_Tests, operator_encompare_char_true){ TEST(PIString_Tests, operator_encompare_char_true){
PIString str1 = "t"; PIString str1 = "t";
char str2[] = "test"; char str2[] = "test";
ASSERT_TRUE(str1 != str2); ASSERT_TRUE(str1 != str2);
} }
TEST(PIString_Tests, operator_less_pistring_true){ TEST(PIString_Tests, operator_less_pistring_true){
PIString str1 = "testin"; PIString str1 = "testin";
PIString str2 = "testing"; PIString str2 = "testing";
ASSERT_TRUE(str1 < str2); ASSERT_TRUE(str1 < str2);
} }
TEST(PIString_Tests, operator_less_pistring_false){ TEST(PIString_Tests, operator_less_pistring_false){
PIString str1 = "testing"; PIString str1 = "testing";
PIString str2 = "testin"; PIString str2 = "testin";
ASSERT_FALSE(str1 < str2); ASSERT_FALSE(str1 < str2);
} }
TEST(PIString_Tests, operator_less_pistring_false_equal){ TEST(PIString_Tests, operator_less_pistring_false_equal){
PIString str1 = "testing"; PIString str1 = "testing";
PIString str2 = "testing"; PIString str2 = "testing";
ASSERT_FALSE(str1 < str2); ASSERT_FALSE(str1 < str2);
} }
TEST(PIString_Tests, operator_less_pichar_true){ TEST(PIString_Tests, operator_less_pichar_true){
PIString str1 = "a"; PIString str1 = "a";
PIChar str2 = "t"; PIChar str2 = "t";
ASSERT_TRUE(str1 < str2); ASSERT_TRUE(str1 < str2);
} }
TEST(PIString_Tests, operator_less_pichar_false){ TEST(PIString_Tests, operator_less_pichar_false){
PIString str1 = "t"; PIString str1 = "t";
PIChar str2 = "a"; PIChar str2 = "a";
ASSERT_FALSE(str1 < str2); ASSERT_FALSE(str1 < str2);
} }
TEST(PIString_Tests, operator_less_pichar_false_equal){ TEST(PIString_Tests, operator_less_pichar_false_equal){
PIString str1 = "t"; PIString str1 = "t";
PIChar str2 = "t"; PIChar str2 = "t";
ASSERT_FALSE(str1 < str2); ASSERT_FALSE(str1 < str2);
} }
TEST(PIString_Tests, operator_less_char_true){ TEST(PIString_Tests, operator_less_char_true){
PIString str1 = "a"; PIString str1 = "a";
char str2[] = "t"; char str2[] = "t";
ASSERT_TRUE(str1 < str2); ASSERT_TRUE(str1 < str2);
} }
TEST(PIString_Tests, operator_less_char_false){ TEST(PIString_Tests, operator_less_char_false){
PIString str1 = "t"; PIString str1 = "t";
char str2[] = "a"; char str2[] = "a";
ASSERT_FALSE(str1 < str2); ASSERT_FALSE(str1 < str2);
} }
TEST(PIString_Tests, operator_less_char_false_equal){ TEST(PIString_Tests, operator_less_char_false_equal){
PIString str1 = "t"; PIString str1 = "t";
char str2[] = "t"; char str2[] = "t";
ASSERT_FALSE(str1 < str2); ASSERT_FALSE(str1 < str2);
} }
TEST(PIString_Tests, operator_more_pistring_true){ TEST(PIString_Tests, operator_more_pistring_true){
PIString str1 = "testin"; PIString str1 = "testin";
PIString str2 = "testing"; PIString str2 = "testing";
ASSERT_TRUE(str2 > str1); ASSERT_TRUE(str2 > str1);
} }
TEST(PIString_Tests, operator_more_pistring_false){ TEST(PIString_Tests, operator_more_pistring_false){
PIString str1 = "testing"; PIString str1 = "testing";
PIString str2 = "testin"; PIString str2 = "testin";
ASSERT_FALSE(str2 > str1); ASSERT_FALSE(str2 > str1);
} }
TEST(PIString_Tests, operator_more_pistring_false_equal){ TEST(PIString_Tests, operator_more_pistring_false_equal){
PIString str1 = "testing"; PIString str1 = "testing";
PIString str2 = "testing"; PIString str2 = "testing";
ASSERT_FALSE(str1 > str2); ASSERT_FALSE(str1 > str2);
} }
TEST(PIString_Tests, operator_more_pichar_true){ TEST(PIString_Tests, operator_more_pichar_true){
PIString str1 = "t"; PIString str1 = "t";
PIChar str2 = "a"; PIChar str2 = "a";
ASSERT_TRUE(str1 > str2); ASSERT_TRUE(str1 > str2);
} }
TEST(PIString_Tests, operator_more_pichar_false){ TEST(PIString_Tests, operator_more_pichar_false){
PIString str1 = "a"; PIString str1 = "a";
PIChar str2 = "t"; PIChar str2 = "t";
ASSERT_FALSE(str1 > str2); ASSERT_FALSE(str1 > str2);
} }
TEST(PIString_Tests, operator_more_pichar_false_equal){ TEST(PIString_Tests, operator_more_pichar_false_equal){
PIString str1 = "t"; PIString str1 = "t";
PIChar str2 = "t"; PIChar str2 = "t";
ASSERT_FALSE(str1 > str2); ASSERT_FALSE(str1 > str2);
} }
TEST(PIString_Tests, operator_more_char_true){ TEST(PIString_Tests, operator_more_char_true){
PIString str1 = "t"; PIString str1 = "t";
char str2[] = "a"; char str2[] = "a";
ASSERT_TRUE(str1 > str2); ASSERT_TRUE(str1 > str2);
} }
TEST(PIString_Tests, operator_more_char_false){ TEST(PIString_Tests, operator_more_char_false){
PIString str1 = "a"; PIString str1 = "a";
char str2[] = "t"; char str2[] = "t";
ASSERT_FALSE(str1 > str2); ASSERT_FALSE(str1 > str2);
} }
TEST(PIString_Tests, operator_more_char_false_equal){ TEST(PIString_Tests, operator_more_char_false_equal){
PIString str1 = "t"; PIString str1 = "t";
char str2[] = "t"; char str2[] = "t";
ASSERT_FALSE(str1 > str2); ASSERT_FALSE(str1 > str2);
} }
TEST(PIString_Tests, operator_less_eq_pistring_true){ TEST(PIString_Tests, operator_less_eq_pistring_true){
PIString str1 = "testin"; PIString str1 = "testin";
PIString str2 = "testing"; PIString str2 = "testing";
ASSERT_TRUE(str1 <= str2); ASSERT_TRUE(str1 <= str2);
} }
TEST(PIString_Tests, operator_less_eq_pistring_false){ TEST(PIString_Tests, operator_less_eq_pistring_false){
PIString str1 = "testing"; PIString str1 = "testing";
PIString str2 = "testin"; PIString str2 = "testin";
ASSERT_FALSE(str1 <= str2); ASSERT_FALSE(str1 <= str2);
} }
TEST(PIString_Tests, operator_less_pistring_true_equal){ TEST(PIString_Tests, operator_less_pistring_true_equal){
PIString str1 = "testing"; PIString str1 = "testing";
PIString str2 = "testing"; PIString str2 = "testing";
ASSERT_TRUE(str1 <= str2); ASSERT_TRUE(str1 <= str2);
} }
TEST(PIString_Tests, operator_less_eq_pichar_true){ TEST(PIString_Tests, operator_less_eq_pichar_true){
PIString str1 = "a"; PIString str1 = "a";
PIChar str2 = "t"; PIChar str2 = "t";
ASSERT_TRUE(str1 <= str2); ASSERT_TRUE(str1 <= str2);
} }
TEST(PIString_Tests, operator_less_eq_pichar_false){ TEST(PIString_Tests, operator_less_eq_pichar_false){
PIString str1 = "t"; PIString str1 = "t";
PIChar str2 = "a"; PIChar str2 = "a";
ASSERT_FALSE(str1 <= str2); ASSERT_FALSE(str1 <= str2);
} }
TEST(PIString_Tests, operator_less_eq_pichar_true_equal){ TEST(PIString_Tests, operator_less_eq_pichar_true_equal){
PIString str1 = "t"; PIString str1 = "t";
PIChar str2 = "t"; PIChar str2 = "t";
ASSERT_TRUE(str1 <= str2); ASSERT_TRUE(str1 <= str2);
} }
TEST(PIString_Tests, operator_less_eq_char_true){ TEST(PIString_Tests, operator_less_eq_char_true){
PIString str1 = "a"; PIString str1 = "a";
char str2[] = "t"; char str2[] = "t";
ASSERT_TRUE(str1 <= str2); ASSERT_TRUE(str1 <= str2);
} }
TEST(PIString_Tests, operator_less_eq_char_false){ TEST(PIString_Tests, operator_less_eq_char_false){
PIString str1 = "t"; PIString str1 = "t";
char str2[] = "a"; char str2[] = "a";
ASSERT_FALSE(str1 <= str2); ASSERT_FALSE(str1 <= str2);
} }
TEST(PIString_Tests, operator_less_eq_char_true_equal){ TEST(PIString_Tests, operator_less_eq_char_true_equal){
PIString str1 = "t"; PIString str1 = "t";
char str2[] = "t"; char str2[] = "t";
ASSERT_TRUE(str1 <= str2); ASSERT_TRUE(str1 <= str2);
} }
TEST(PIString_Tests, operator_more_eq_pistring_true){ TEST(PIString_Tests, operator_more_eq_pistring_true){
PIString str1 = "testin"; PIString str1 = "testin";
PIString str2 = "testing"; PIString str2 = "testing";
ASSERT_TRUE(str2 >= str1); ASSERT_TRUE(str2 >= str1);
} }
TEST(PIString_Tests, operator_more_eq_pistring_false){ TEST(PIString_Tests, operator_more_eq_pistring_false){
PIString str1 = "testing"; PIString str1 = "testing";
PIString str2 = "testin"; PIString str2 = "testin";
ASSERT_FALSE(str2 >= str1); ASSERT_FALSE(str2 >= str1);
} }
TEST(PIString_Tests, operator_more_eq_pistring_true_equal){ TEST(PIString_Tests, operator_more_eq_pistring_true_equal){
PIString str1 = "testing"; PIString str1 = "testing";
PIString str2 = "testing"; PIString str2 = "testing";
ASSERT_TRUE(str1 >= str2); ASSERT_TRUE(str1 >= str2);
} }
TEST(PIString_Tests, operator_more_eq_pichar_true){ TEST(PIString_Tests, operator_more_eq_pichar_true){
PIString str1 = "t"; PIString str1 = "t";
PIChar str2 = "a"; PIChar str2 = "a";
ASSERT_TRUE(str1 >= str2); ASSERT_TRUE(str1 >= str2);
} }
TEST(PIString_Tests, operator_more_eq_pichar_false){ TEST(PIString_Tests, operator_more_eq_pichar_false){
PIString str1 = "a"; PIString str1 = "a";
PIChar str2 = "t"; PIChar str2 = "t";
ASSERT_FALSE(str1 >= str2); ASSERT_FALSE(str1 >= str2);
} }
TEST(PIString_Tests, operator_more_eq_pichar_true_equal){ TEST(PIString_Tests, operator_more_eq_pichar_true_equal){
PIString str1 = "t"; PIString str1 = "t";
PIChar str2 = "t"; PIChar str2 = "t";
ASSERT_TRUE(str1 >= str2); ASSERT_TRUE(str1 >= str2);
} }
TEST(PIString_Tests, operator_more_eq_char_true){ TEST(PIString_Tests, operator_more_eq_char_true){
PIString str1 = "t"; PIString str1 = "t";
char str2[] = "a"; char str2[] = "a";
ASSERT_TRUE(str1 >= str2); ASSERT_TRUE(str1 >= str2);
} }
TEST(PIString_Tests, operator_more_eq_char_false){ TEST(PIString_Tests, operator_more_eq_char_false){
PIString str1 = "a"; PIString str1 = "a";
char str2[] = "t"; char str2[] = "t";
ASSERT_FALSE(str1 >= str2); ASSERT_FALSE(str1 >= str2);
} }
TEST(PIString_Tests, operator_more_eq_char_true_equal){ TEST(PIString_Tests, operator_more_eq_char_true_equal){
PIString str1 = "t"; PIString str1 = "t";
char str2[] = "t"; char str2[] = "t";
ASSERT_TRUE(str1 >= str2); ASSERT_TRUE(str1 >= str2);
} }
TEST(PIString_Tests, operator_shift_pistring){ TEST(PIString_Tests, operator_shift_pistring){
PIString str1 = "shift"; PIString str1 = "shift";
PIString str2 = " good"; PIString str2 = " good";
str1 << str2; str1 << str2;
PIString res = "shift good"; PIString res = "shift good";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, operator_shift_pichar){ TEST(PIString_Tests, operator_shift_pichar){
PIString str1 = "shif"; PIString str1 = "shif";
PIChar str2 = 't'; PIChar str2 = 't';
str1 << str2; str1 << str2;
PIString res = "shift"; PIString res = "shift";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, operator_shift_char){ TEST(PIString_Tests, operator_shift_char){
PIString str1 = "shif"; PIString str1 = "shif";
char str2[] = "t chat"; char str2[] = "t chat";
str1 << str2; str1 << str2;
PIString res = "shift chat"; PIString res = "shift chat";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, operator_shift_wchar_t){ TEST(PIString_Tests, operator_shift_wchar_t){
PIString str1 = "shif"; PIString str1 = "shif";
wchar_t str2[] = L"t cc"; wchar_t str2[] = L"t cc";
str1 << str2; str1 << str2;
PIString res = "shift cc"; PIString res = "shift cc";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, operator_shift_int){ TEST(PIString_Tests, operator_shift_int){
PIString str1 = "shift "; PIString str1 = "shift ";
int numb = -2147483648; int numb = -2147483648;
str1 << numb; str1 << numb;
PIString res = "shift -2147483648"; PIString res = "shift -2147483648";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, operator_shift_uint){ TEST(PIString_Tests, operator_shift_uint){
PIString str1 = "shift "; PIString str1 = "shift ";
uint numb = 4294967295; uint numb = 4294967295;
str1 << numb; str1 << numb;
PIString res = "shift 4294967295"; PIString res = "shift 4294967295";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, operator_shift_short){ TEST(PIString_Tests, operator_shift_short){
PIString str1 = "shift "; PIString str1 = "shift ";
short numb = -32768; short numb = -32768;
str1 << numb; str1 << numb;
PIString res = "shift -32768"; PIString res = "shift -32768";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, operator_shift_ushort){ TEST(PIString_Tests, operator_shift_ushort){
PIString str1 = "shift "; PIString str1 = "shift ";
ushort numb = 65535; ushort numb = 65535;
str1 << numb; str1 << numb;
PIString res = "shift 65535"; PIString res = "shift 65535";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, operator_shift_long){ TEST(PIString_Tests, operator_shift_long){
PIString str1 = "shift "; PIString str1 = "shift ";
long numb = -2147483648; long numb = -2147483648;
str1 << numb; str1 << numb;
PIString res = "shift -2147483648"; PIString res = "shift -2147483648";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, operator_shift_ulong){ TEST(PIString_Tests, operator_shift_ulong){
PIString str1 = "shift "; PIString str1 = "shift ";
ulong numb = 4294967295; ulong numb = 4294967295;
str1 << numb; str1 << numb;
PIString res = "shift 4294967295"; PIString res = "shift 4294967295";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, operator_shift_llong){ TEST(PIString_Tests, operator_shift_llong){
PIString str1 = "shift "; PIString str1 = "shift ";
llong numb = -9223372036854775807; llong numb = -9223372036854775807;
str1 << numb; str1 << numb;
PIString res = "shift -9223372036854775807"; PIString res = "shift -9223372036854775807";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, operator_shift_ullong){ TEST(PIString_Tests, operator_shift_ullong){
PIString str1 = "shift "; PIString str1 = "shift ";
ullong numb = 1844674407370955161; ullong numb = 1844674407370955161;
str1 << numb; str1 << numb;
PIString res = "shift 1844674407370955161"; PIString res = "shift 1844674407370955161";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, operator_shift_float){ TEST(PIString_Tests, operator_shift_float){
PIString str1 = "shift "; PIString str1 = "shift ";
float numb = -67.88999939; float numb = -67.88999939f;
str1 << numb; str1 << numb;
PIString res = "shift -67.88999939"; PIString res = "shift -67.88999939";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, operator_shift_double){ TEST(PIString_Tests, operator_shift_double){
PIString str1 = "shift "; PIString str1 = "shift ";
double numb = 13.34300000; double numb = 13.34300000;
str1 << numb; str1 << numb;
PIString res = "shift 13.34300000"; PIString res = "shift 13.34300000";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, prepend){ TEST(PIString_Tests, prepend){
PIString str1 = "idea"; PIString str1 = "idea";
PIString str2 = "Good "; PIString str2 = "Good ";
str1.prepend(str2); str1.prepend(str2);
PIString res = "Good idea"; PIString res = "Good idea";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, append){ TEST(PIString_Tests, append){
PIString str1 = "Good"; PIString str1 = "Good";
PIString str2 = " idea"; PIString str2 = " idea";
str1.append(str2); str1.append(str2);
PIString res = "Good idea"; PIString res = "Good idea";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, mid){ TEST(PIString_Tests, mid){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = "fo"; PIString res = "fo";
ASSERT_EQ(res, str1.mid(10, 2)); ASSERT_EQ(res, str1.mid(10, 2));
} }
TEST(PIString_Tests, mid_len_0){ TEST(PIString_Tests, mid_len_0){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1.mid(10, 0)); ASSERT_EQ(res, str1.mid(10, 0));
} }
TEST(PIString_Tests, mid_start_more){ TEST(PIString_Tests, mid_start_more){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1.mid(1000, 0)); ASSERT_EQ(res, str1.mid(1000, 0));
} }
TEST(PIString_Tests, mid_len_minus){ TEST(PIString_Tests, mid_len_minus){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = "for new project 144"; PIString res = "for new project 144";
ASSERT_EQ(res, str1.mid(10, -2)); ASSERT_EQ(res, str1.mid(10, -2));
} }
TEST(PIString_Tests, mid_len_more){ TEST(PIString_Tests, mid_len_more){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = "for new project 144"; PIString res = "for new project 144";
ASSERT_EQ(res, str1.mid(10, 100)); ASSERT_EQ(res, str1.mid(10, 100));
} }
TEST(PIString_Tests, subString){ TEST(PIString_Tests, subString){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = "for new project 144"; PIString res = "for new project 144";
ASSERT_EQ(res, str1.mid(10, 46)); ASSERT_EQ(res, str1.mid(10, 46));
} }
TEST(PIString_Tests, mid_minus){ TEST(PIString_Tests, mid_minus){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = "Good idea for new project 144"; PIString res = "Good idea for new project 144";
ASSERT_EQ(res, str1.mid(-10, 47)); ASSERT_EQ(res, str1.mid(-10, 47));
} }
TEST(PIString_Tests, subString_minus){ TEST(PIString_Tests, subString_minus){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = "Go"; PIString res = "Go";
ASSERT_EQ(res, str1.mid(-10, 12)); ASSERT_EQ(res, str1.mid(-10, 12));
} }
TEST(PIString_Tests, left){ TEST(PIString_Tests, left){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = "Go"; PIString res = "Go";
ASSERT_EQ(res, str1.left(2)); ASSERT_EQ(res, str1.left(2));
} }
TEST(PIString_Tests, left_minus){ TEST(PIString_Tests, left_minus){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1.left(-2)); ASSERT_EQ(res, str1.left(-2));
} }
TEST(PIString_Tests, right){ TEST(PIString_Tests, right){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = "44"; PIString res = "44";
ASSERT_EQ(res, str1.right(2)); ASSERT_EQ(res, str1.right(2));
} }
TEST(PIString_Tests, right_minus){ TEST(PIString_Tests, right_minus){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1.right(-2)); ASSERT_EQ(res, str1.right(-2));
} }
TEST(PIString_Tests, cutMid){ TEST(PIString_Tests, cutMid){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = "Good for new project 144"; PIString res = "Good for new project 144";
ASSERT_EQ(res, str1.cutMid(5,5)); ASSERT_EQ(res, str1.cutMid(5,5));
} }
TEST(PIString_Tests, cutMid_len_zero){ TEST(PIString_Tests, cutMid_len_zero){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = "Good idea for new project 144"; PIString res = "Good idea for new project 144";
ASSERT_EQ(res, str1.cutMid(5,0)); ASSERT_EQ(res, str1.cutMid(5,0));
} }
TEST(PIString_Tests, cutMid_len_min){ TEST(PIString_Tests, cutMid_len_min){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = "Good "; PIString res = "Good ";
ASSERT_EQ(res, str1.cutMid(5,-2)); ASSERT_EQ(res, str1.cutMid(5,-2));
} }
TEST(PIString_Tests, cutMid_minus){ TEST(PIString_Tests, cutMid_minus){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = "ood idea for new project 144"; PIString res = "ood idea for new project 144";
ASSERT_EQ(res, str1.cutMid(-5, 6)); ASSERT_EQ(res, str1.cutMid(-5, 6));
} }
TEST(PIString_Tests, cutMid_zero){ TEST(PIString_Tests, cutMid_zero){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = "Good idea for new project 144"; PIString res = "Good idea for new project 144";
ASSERT_EQ(res, str1.cutMid(-5, 5)); ASSERT_EQ(res, str1.cutMid(-5, 5));
} }
TEST(PIString_Tests, cutleft){ TEST(PIString_Tests, cutleft){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = "od idea for new project 144"; PIString res = "od idea for new project 144";
ASSERT_EQ(res, str1.cutLeft(2)); ASSERT_EQ(res, str1.cutLeft(2));
} }
TEST(PIString_Tests, cutleft_minus){ TEST(PIString_Tests, cutleft_minus){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = "Good idea for new project 144"; PIString res = "Good idea for new project 144";
ASSERT_EQ(res, str1.cutLeft(-2)); ASSERT_EQ(res, str1.cutLeft(-2));
} }
TEST(PIString_Tests, cutright){ TEST(PIString_Tests, cutright){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = "Good idea for new project 1"; PIString res = "Good idea for new project 1";
ASSERT_EQ(res, str1.cutRight(2)); ASSERT_EQ(res, str1.cutRight(2));
} }
TEST(PIString_Tests, cutright_minus){ TEST(PIString_Tests, cutright_minus){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = "Good idea for new project 144"; PIString res = "Good idea for new project 144";
ASSERT_EQ(res, str1.cutRight(-2)); ASSERT_EQ(res, str1.cutRight(-2));
} }
TEST(PIString_Tests, trim){ TEST(PIString_Tests, trim){
PIString str1 = " Good idea for new project 144 "; PIString str1 = " Good idea for new project 144 ";
PIString res = "Good idea for new project 144"; PIString res = "Good idea for new project 144";
ASSERT_EQ(res, str1.trim()); ASSERT_EQ(res, str1.trim());
} }
TEST(PIString_Tests, trim_without){ TEST(PIString_Tests, trim_without){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = "Good idea for new project 144"; PIString res = "Good idea for new project 144";
ASSERT_EQ(res, str1.trim()); ASSERT_EQ(res, str1.trim());
} }
TEST(PIString_Tests, trim_link){ TEST(PIString_Tests, trim_link){
PIString str1 = " Good idea for new project 144 "; PIString str1 = " Good idea for new project 144 ";
PIString &str2 = str1.trim(); PIString &str2 = str1.trim();
str1 = "link"; str1 = "link";
PIString res = "link"; PIString res = "link";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, trimmed){ TEST(PIString_Tests, trimmed){
PIString str1 = " Good idea for new project 144 "; PIString str1 = " Good idea for new project 144 ";
PIString res = "Good idea for new project 144"; PIString res = "Good idea for new project 144";
ASSERT_EQ(res, str1.trimmed()); ASSERT_EQ(res, str1.trimmed());
} }
TEST(PIString_Tests, trimmed_without){ TEST(PIString_Tests, trimmed_without){
PIString str1 = "Good idea for new project 144"; PIString str1 = "Good idea for new project 144";
PIString res = "Good idea for new project 144"; PIString res = "Good idea for new project 144";
ASSERT_EQ(res, str1.trimmed()); ASSERT_EQ(res, str1.trimmed());
} }
TEST(PIString_Tests, replace){ TEST(PIString_Tests, replace){
PIString str1 = " Good idea for new project 144 "; PIString str1 = " Good idea for new project 144 ";
PIString res = " Good thin for new project 144 "; PIString res = " Good thin for new project 144 ";
ASSERT_EQ(res, str1.replace(6,4, "thin")); ASSERT_EQ(res, str1.replace(6,4, "thin"));
} }
TEST(PIString_Tests, replace_more){ TEST(PIString_Tests, replace_more){
PIString str1 = " Good idea for new project 144 "; PIString str1 = " Good idea for new project 144 ";
PIString res = " Good thin"; PIString res = " Good thin";
ASSERT_EQ(res, str1.replace(6,100, "thin")); ASSERT_EQ(res, str1.replace(6,100, "thin"));
} }
TEST(PIString_Tests, replace_link){ TEST(PIString_Tests, replace_link){
PIString str1 = " Good idea for new project 144 "; PIString str1 = " Good idea for new project 144 ";
PIString &str2 = str1.replace(6,4, "thin"); PIString &str2 = str1.replace(6,4, "thin");
str1 = "link"; str1 = "link";
PIString res = "link"; PIString res = "link";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, replace_minus){ TEST(PIString_Tests, replace_minus){
PIString str1 = " Good idea for new project 144 "; PIString str1 = " Good idea for new project 144 ";
PIString res = "BAD idea for new project 144 "; PIString res = "BAD idea for new project 144 ";
ASSERT_EQ(res, str1.replace(0, 5, "BAD")); ASSERT_EQ(res, str1.replace(0, 5, "BAD"));
} }
TEST(PIString_Tests, replace_zero){ TEST(PIString_Tests, replace_zero){
PIString str1 = " Good idea for new project 144 "; PIString str1 = " Good idea for new project 144 ";
PIString res = "thin Good idea for new project 144 "; PIString res = "thin Good idea for new project 144 ";
ASSERT_EQ(res, str1.replace(0, 0, "thin")); ASSERT_EQ(res, str1.replace(0, 0, "thin"));
} }
TEST(PIString_Tests, replace_all){ TEST(PIString_Tests, replace_all){
PIString str1 = " Good idea for new project 144 "; PIString str1 = " Good idea for new project 144 ";
PIString res = "BAD"; PIString res = "BAD";
ASSERT_EQ(res, str1.replaced(0, 100, "BAD")); ASSERT_EQ(res, str1.replaced(0, 100, "BAD"));
} }
TEST(PIString_Tests, replaced){ TEST(PIString_Tests, replaced){
PIString str1 = " Good idea for new project 144 "; PIString str1 = " Good idea for new project 144 ";
PIString res = " Good thin for new project 144 "; PIString res = " Good thin for new project 144 ";
ASSERT_EQ(res, str1.replaced(6,4, "thin")); ASSERT_EQ(res, str1.replaced(6,4, "thin"));
} }
TEST(PIString_Tests, replaced_minus){ TEST(PIString_Tests, replaced_minus){
PIString str1 = " Good idea for new project 144 "; PIString str1 = " Good idea for new project 144 ";
PIString res = "BAD idea for new project 144 "; PIString res = "BAD idea for new project 144 ";
ASSERT_EQ(res, str1.replaced(0, 5, "BAD")); ASSERT_EQ(res, str1.replaced(0, 5, "BAD"));
} }
TEST(PIString_Tests, replaced_zero){ TEST(PIString_Tests, replaced_zero){
PIString str1 = " Good idea for new project 144 "; PIString str1 = " Good idea for new project 144 ";
PIString res = "thin Good idea for new project 144 "; PIString res = "thin Good idea for new project 144 ";
ASSERT_EQ(res, str1.replaced(0, 0, "thin")); ASSERT_EQ(res, str1.replaced(0, 0, "thin"));
} }
TEST(PIString_Tests, replaced_all){ TEST(PIString_Tests, replaced_all){
PIString str1 = " Good idea for new project 144 "; PIString str1 = " Good idea for new project 144 ";
PIString res = "thin"; PIString res = "thin";
ASSERT_EQ(res, str1.replaced(0, 100, "thin")); ASSERT_EQ(res, str1.replaced(0, 100, "thin"));
} }
TEST(PIString_Tests, replace_str){ TEST(PIString_Tests, replace_str){
PIString str1 = " Good idea for new Good project 144 "; PIString str1 = " Good idea for new Good project 144 ";
bool ok = 1; bool ok = 1;
str1.replace("Good", "bad", &ok); str1.replace("Good", "bad", &ok);
PIString res = " bad idea for new Good project 144 "; PIString res = " bad idea for new Good project 144 ";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, replace_str_link){ TEST(PIString_Tests, replace_str_link){
PIString str1 = " Good idea for new Good project 144 "; PIString str1 = " Good idea for new Good project 144 ";
bool ok = 1; bool ok = 1;
PIString &str2 = str1.replace("Good", "bad", &ok); PIString &str2 = str1.replace("Good", "bad", &ok);
str1 = "link"; str1 = "link";
PIString res = "link"; PIString res = "link";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, replace_str_zero){ TEST(PIString_Tests, replace_str_zero){
PIString str1 = " Good idea for new Good project 144 "; PIString str1 = " Good idea for new Good project 144 ";
bool ok = 1; bool ok = 1;
str1.replace("", "bad", &ok); str1.replace("", "bad", &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, replace_str_true){ TEST(PIString_Tests, replace_str_true){
PIString str1 = " Good idea for new Good project 144 "; PIString str1 = " Good idea for new Good project 144 ";
bool ok = 1; bool ok = 1;
str1.replace("Good", "bad", &ok); str1.replace("Good", "bad", &ok);
ASSERT_TRUE(ok); ASSERT_TRUE(ok);
} }
TEST(PIString_Tests, replace_str_delete){ TEST(PIString_Tests, replace_str_delete){
PIString str1 = " Good idea for new Good project 144 "; PIString str1 = " Good idea for new Good project 144 ";
bool ok = 1; bool ok = 1;
str1.replace("Good", "", &ok); str1.replace("Good", "", &ok);
PIString res = " idea for new Good project 144 "; PIString res = " idea for new Good project 144 ";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, replaced_str){ TEST(PIString_Tests, replaced_str){
PIString str1 = " Good idea for new Good project 144 "; PIString str1 = " Good idea for new Good project 144 ";
bool ok = 1; bool ok = 1;
PIString str2 = str1.replaced("Good", "bad", &ok); PIString str2 = str1.replaced("Good", "bad", &ok);
PIString res = " bad idea for new Good project 144 "; PIString res = " bad idea for new Good project 144 ";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, replaced_str_zero){ TEST(PIString_Tests, replaced_str_zero){
PIString str1 = " Good idea for new Good project 144 "; PIString str1 = " Good idea for new Good project 144 ";
bool ok = 1; bool ok = 1;
str1.replaced("", "bad", &ok); str1.replaced("", "bad", &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, replaced_str_true){ TEST(PIString_Tests, replaced_str_true){
PIString str1 = " Good idea for new Good project 144 "; PIString str1 = " Good idea for new Good project 144 ";
bool ok = 1; bool ok = 1;
str1.replaced("Good", "bad", &ok); str1.replaced("Good", "bad", &ok);
ASSERT_TRUE(ok); ASSERT_TRUE(ok);
} }
TEST(PIString_Tests, replaced_delete){ TEST(PIString_Tests, replaced_delete){
PIString str1 = " Good idea for new Good project 144 "; PIString str1 = " Good idea for new Good project 144 ";
bool ok = 1; bool ok = 1;
PIString str2 = str1.replaced("Good", "", &ok); PIString str2 = str1.replaced("Good", "", &ok);
PIString res = " idea for new Good project 144 "; PIString res = " idea for new Good project 144 ";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, replaceall){ TEST(PIString_Tests, replaceall){
PIString str1 = " Good idea for new Good project 144 "; PIString str1 = " Good idea for new Good project 144 ";
str1.replaceAll("Good", "bad"); str1.replaceAll("Good", "bad");
PIString res = " bad idea for new bad project 144 "; PIString res = " bad idea for new bad project 144 ";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, replaceall_no_find){ TEST(PIString_Tests, replaceall_no_find){
PIString str1 = " Good idea for new Good project 144 "; PIString str1 = " Good idea for new Good project 144 ";
str1.replaceAll("God", "bad"); str1.replaceAll("God", "bad");
PIString res = " Good idea for new Good project 144 "; PIString res = " Good idea for new Good project 144 ";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, replaceall_str){ TEST(PIString_Tests, replaceall_str){
PIString str1 = " Good idea for new Good project 144 "; PIString str1 = " Good idea for new Good project 144 ";
PIString str2 = str1.replaceAll("Good", "bad"); PIString str2 = str1.replaceAll("Good", "bad");
PIString res = " bad idea for new bad project 144 "; PIString res = " bad idea for new bad project 144 ";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, replaceall_str_no_find){ TEST(PIString_Tests, replaceall_str_no_find){
PIString str1 = " Good idea for new Good project 144 "; PIString str1 = " Good idea for new Good project 144 ";
PIString str2 = str1.replaceAll("God", "bad"); PIString str2 = str1.replaceAll("God", "bad");
PIString res = " Good idea for new Good project 144 "; PIString res = " Good idea for new Good project 144 ";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, replaceall_link){ TEST(PIString_Tests, replaceall_link){
PIString str1 = " Good idea for new Good project 144 "; PIString str1 = " Good idea for new Good project 144 ";
PIString &str2 = str1.replaceAll("Good", "bad"); PIString &str2 = str1.replaceAll("Good", "bad");
PIString res = " bad idea for new bad project 144 "; PIString res = " bad idea for new bad project 144 ";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, replaceall_link_change){ TEST(PIString_Tests, replaceall_link_change){
PIString str1 = " Good idea for new Good project 144 "; PIString str1 = " Good idea for new Good project 144 ";
PIString &str2 = str1.replaceAll("Good", "bad"); PIString &str2 = str1.replaceAll("Good", "bad");
str1 = "link"; str1 = "link";
PIString res = "link"; PIString res = "link";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, repeat){ TEST(PIString_Tests, repeat){
PIString str1 = "string "; PIString str1 = "string ";
PIString str2 = str1.repeat(6); PIString str2 = str1.repeat(6);
PIString res = "string string string string string string "; PIString res = "string string string string string string ";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, repeat_zero){ TEST(PIString_Tests, repeat_zero){
PIString str1 = "string "; PIString str1 = "string ";
PIString str2 = str1.repeat(0); PIString str2 = str1.repeat(0);
PIString res = "string "; PIString res = "string ";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, repeat_link){ TEST(PIString_Tests, repeat_link){
PIString str1 = "string "; PIString str1 = "string ";
PIString &str2 = str1.repeat(6); PIString &str2 = str1.repeat(6);
str1 = "link"; str1 = "link";
PIString res = "link"; PIString res = "link";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, repeated){ TEST(PIString_Tests, repeated){
PIString str1 = "string "; PIString str1 = "string ";
str1.repeat(6); str1.repeat(6);
PIString res = "string string string string string string "; PIString res = "string string string string string string ";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, repeated_zero){ TEST(PIString_Tests, repeated_zero){
PIString str1 = "string "; PIString str1 = "string ";
str1.repeat(0); str1.repeat(0);
PIString res = "string "; PIString res = "string ";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, insert_char){ TEST(PIString_Tests, insert_char){
PIString str1 = "strng "; PIString str1 = "strng ";
char sym = 'i'; char sym = 'i';
str1.insert(3, sym); str1.insert(3, sym);
PIString res = "string "; PIString res = "string ";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, insert_pichar){ TEST(PIString_Tests, insert_pichar){
PIString str1 = "strng "; PIString str1 = "strng ";
PIChar sym = 'i'; PIChar sym = 'i';
str1.insert(3, sym); str1.insert(3, sym);
PIString res = "string "; PIString res = "string ";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, insert_pistring){ TEST(PIString_Tests, insert_pistring){
PIString str1 = "string out"; PIString str1 = "string out";
PIString str2 = " go"; PIString str2 = " go";
str1.insert(6, str2); str1.insert(6, str2);
PIString res = "string go out"; PIString res = "string go out";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, insert_chars){ TEST(PIString_Tests, insert_chars){
PIString str1 = "see boy"; PIString str1 = "see boy";
char str2[] = " big"; char str2[] = " big";
str1.insert(3, str2); str1.insert(3, str2);
PIString res = "see big boy"; PIString res = "see big boy";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, expandRightTo){ TEST(PIString_Tests, expandRightTo){
PIString str1 = "see boy "; PIString str1 = "see boy ";
PIChar symbol = "x"; PIChar symbol = "x";
str1.expandRightTo(11, symbol); str1.expandRightTo(11, symbol);
PIString res = "see boy xxx"; PIString res = "see boy xxx";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, expandRightTo_null){ TEST(PIString_Tests, expandRightTo_null){
PIString str1 = "see boy "; PIString str1 = "see boy ";
PIChar symbol = "x"; PIChar symbol = "x";
str1.expandRightTo(0, symbol); str1.expandRightTo(0, symbol);
PIString res = "see boy "; PIString res = "see boy ";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, expandLeftTo){ TEST(PIString_Tests, expandLeftTo){
PIString str1 = " see boy"; PIString str1 = " see boy";
PIChar symbol = "x"; PIChar symbol = "x";
str1.expandLeftTo(11, symbol); str1.expandLeftTo(11, symbol);
PIString res = "xxx see boy"; PIString res = "xxx see boy";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, expandLeftTo_null){ TEST(PIString_Tests, expandLeftTo_null){
PIString str1 = "see boy "; PIString str1 = "see boy ";
PIChar symbol = "x"; PIChar symbol = "x";
str1.expandLeftTo(0, symbol); str1.expandLeftTo(0, symbol);
PIString res = "see boy "; PIString res = "see boy ";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, quote){ TEST(PIString_Tests, quote){
PIString str1 = "see boy"; PIString str1 = "see boy";
PIChar symbol = " "; PIChar symbol = " ";
str1.quote(symbol); str1.quote(symbol);
PIString res = " see boy "; PIString res = " see boy ";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, quote_link){ TEST(PIString_Tests, quote_link){
PIString str1 = "see boy"; PIString str1 = "see boy";
PIChar symbol = " "; PIChar symbol = " ";
PIString &str2 = str1.quote(symbol); PIString &str2 = str1.quote(symbol);
str1 = "link"; str1 = "link";
PIString res = "link"; PIString res = "link";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, quoted){ TEST(PIString_Tests, quoted){
PIString str1 = "see boy"; PIString str1 = "see boy";
PIChar symbol = " "; PIChar symbol = " ";
PIString str2 = str1.quoted(symbol); PIString str2 = str1.quoted(symbol);
PIString res = " see boy "; PIString res = " see boy ";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, reverse){ TEST(PIString_Tests, reverse){
PIString str1 = "see boy"; PIString str1 = "see boy";
PIString &str2 = str1.reverse(); PIString &str2 = str1.reverse();
PIString res = "yob ees"; PIString res = "yob ees";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, reverse_link){ TEST(PIString_Tests, reverse_link){
PIString str1 = "see boy"; PIString str1 = "see boy";
PIString &str2 = str1.reverse(); PIString &str2 = str1.reverse();
str1 = "yes"; str1 = "yes";
PIString res = "yes"; PIString res = "yes";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, reversed){ TEST(PIString_Tests, reversed){
PIString str1 = "see boy"; PIString str1 = "see boy";
PIString str2 = str1.reversed(); PIString str2 = str1.reversed();
PIString res = "yob ees"; PIString res = "yob ees";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, elide){ TEST(PIString_Tests, elide){
PIString str1 = "BMSTU is best university in space"; PIString str1 = "BMSTU is best university in space";
PIString &str2 = str1.elide(8, 1); PIString &str2 = str1.elide(8, 1);
PIString res = "BMSTU .."; PIString res = "BMSTU ..";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, elide_small){ TEST(PIString_Tests, elide_small){
PIString str1 = "BMSTU is best university in space"; PIString str1 = "BMSTU is best university in space";
PIString &str2 = str1.elide(2, 1); PIString &str2 = str1.elide(2, 1);
PIString res = ".."; PIString res = "..";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, elide_all){ TEST(PIString_Tests, elide_all){
PIString str1 = "BMSTU is best university in space"; PIString str1 = "BMSTU is best university in space";
PIString &str2 = str1.elide(100, 1); PIString &str2 = str1.elide(100, 1);
PIString res = "BMSTU is best university in space"; PIString res = "BMSTU is best university in space";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, elide_link){ TEST(PIString_Tests, elide_link){
PIString str1 = "BMSTU is best university in space"; PIString str1 = "BMSTU is best university in space";
PIString &str2 = str1.elide(8, 1); PIString &str2 = str1.elide(8, 1);
str1 = "space"; str1 = "space";
PIString res = "space"; PIString res = "space";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, elided){ TEST(PIString_Tests, elided){
PIString str1 = "BMSTU is best university in space"; PIString str1 = "BMSTU is best university in space";
PIString str2 = str1.elided(8, 1); PIString str2 = str1.elided(8, 1);
PIString res = "BMSTU .."; PIString res = "BMSTU ..";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takemid){ TEST(PIString_Tests, takemid){
PIString str1 = "BMSTU is best university in space"; PIString str1 = "BMSTU is best university in space";
PIString str2 = str1.takeMid(9, 4); PIString str2 = str1.takeMid(9, 4);
PIString res = "best"; PIString res = "best";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takeleft){ TEST(PIString_Tests, takeleft){
PIString str1 = "BMSTU is best university in space"; PIString str1 = "BMSTU is best university in space";
PIString str2 = str1.takeLeft(5); PIString str2 = str1.takeLeft(5);
PIString res = "BMSTU"; PIString res = "BMSTU";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takeright){ TEST(PIString_Tests, takeright){
PIString str1 = "BMSTU is best university in space"; PIString str1 = "BMSTU is best university in space";
PIString str2 = str1.takeRight(5); PIString str2 = str1.takeRight(5);
PIString res = "space"; PIString res = "space";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takesymbol){ TEST(PIString_Tests, takesymbol){
PIString str1 = "BMSTU is best university in space"; PIString str1 = "BMSTU is best university in space";
PIString str2 = str1.takeSymbol(); PIString str2 = str1.takeSymbol();
PIString res = "B"; PIString res = "B";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takesymbol_with_rubbish){ TEST(PIString_Tests, takesymbol_with_rubbish){
PIString str1 = " \t \n \r BMSTU is best university in space"; PIString str1 = " \t \n \r BMSTU is best university in space";
PIString str2 = str1.takeSymbol(); PIString str2 = str1.takeSymbol();
PIString res = "B"; PIString res = "B";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takesymbol_without){ TEST(PIString_Tests, takesymbol_without){
PIString str1 = " \t \n \r "; PIString str1 = " \t \n \r ";
PIString str2 = str1.takeSymbol(); PIString str2 = str1.takeSymbol();
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takeword){ TEST(PIString_Tests, takeword){
PIString str1 = "BMSTU is best university in space"; PIString str1 = "BMSTU is best university in space";
PIString str2 = str1.takeWord(); PIString str2 = str1.takeWord();
PIString res = "BMSTU"; PIString res = "BMSTU";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takeword_space){ TEST(PIString_Tests, takeword_space){
PIString str1 = " \r\n\tBMSTU is best university in space"; PIString str1 = " \r\n\tBMSTU is best university in space";
PIString str2 = str1.takeWord(); PIString str2 = str1.takeWord();
PIString res = "BMSTU"; PIString res = "BMSTU";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takeword_without_word){ TEST(PIString_Tests, takeword_without_word){
PIString str1 = " \r\n\t"; PIString str1 = " \r\n\t";
PIString str2 = str1.takeWord(); PIString str2 = str1.takeWord();
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takecword){ TEST(PIString_Tests, takecword){
PIString str1 = "_6 BMSTU is best university in space"; PIString str1 = "_6 BMSTU is best university in space";
PIString str2 = str1.takeCWord(); PIString str2 = str1.takeCWord();
PIString res = "_6"; PIString res = "_6";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takecword_space){ TEST(PIString_Tests, takecword_space){
PIString str1 = " \t\r\n_6 BMSTU is best university in space"; PIString str1 = " \t\r\n_6 BMSTU is best university in space";
PIString str2 = str1.takeCWord(); PIString str2 = str1.takeCWord();
PIString res = "_6"; PIString res = "_6";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takecword_space_w){ TEST(PIString_Tests, takecword_space_w){
PIString str1 = " \t\r\n BMSTU is best university in space"; PIString str1 = " \t\r\n BMSTU is best university in space";
PIString str2 = str1.takeCWord(); PIString str2 = str1.takeCWord();
PIString res = "BMSTU"; PIString res = "BMSTU";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takecword_not_cword){ TEST(PIString_Tests, takecword_not_cword){
PIString str1 = " \t\r\n "; PIString str1 = " \t\r\n ";
PIString str2 = str1.takeCWord(); PIString str2 = str1.takeCWord();
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takeline){ TEST(PIString_Tests, takeline){
PIString str1 = "BMSTU is best\n university in space"; PIString str1 = "BMSTU is best\n university in space";
PIString str2 = str1.takeLine(); PIString str2 = str1.takeLine();
PIString res = "BMSTU is best"; PIString res = "BMSTU is best";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takeline_without){ TEST(PIString_Tests, takeline_without){
PIString str1 = "BMSTU is best"; PIString str1 = "BMSTU is best";
PIString str2 = str1.takeLine(); PIString str2 = str1.takeLine();
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takeline_first){ TEST(PIString_Tests, takeline_first){
PIString str1 = "\nBMSTU is best"; PIString str1 = "\nBMSTU is best";
PIString str2 = str1.takeLine(); PIString str2 = str1.takeLine();
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takenumber){ TEST(PIString_Tests, takenumber){
PIString str1 = "6.6"; PIString str1 = "6.6";
PIString str2 = str1.takeNumber(); PIString str2 = str1.takeNumber();
PIString res = "6.6"; PIString res = "6.6";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takenumber_sign){ TEST(PIString_Tests, takenumber_sign){
PIString str1 = "-66"; PIString str1 = "-66";
PIString str2 = str1.takeNumber(); PIString str2 = str1.takeNumber();
PIString res = "-66"; PIString res = "-66";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takenumber_suffix){ TEST(PIString_Tests, takenumber_suffix){
PIString str1 = "66L"; PIString str1 = "66L";
PIString str2 = str1.takeNumber(); PIString str2 = str1.takeNumber();
PIString res = "66L"; PIString res = "66L";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takerange){ TEST(PIString_Tests, takerange){
PIString str1 = "BMSTU is best university in space"; PIString str1 = "BMSTU is best university in space";
PIString str2 = str1.takeRange('B', 'i', ' '); PIString str2 = str1.takeRange('B', 'i', ' ');
PIString res = "MSTU is best un"; PIString res = "MSTU is best un";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takerange_without_shield){ TEST(PIString_Tests, takerange_without_shield){
PIString str1 = "BMSTU is best university in space"; PIString str1 = "BMSTU is best university in space";
PIString str2 = str1.takeRange('B', 'i'); PIString str2 = str1.takeRange('B', 'i');
PIString res = "MSTU "; PIString res = "MSTU ";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takerange_space){ TEST(PIString_Tests, takerange_space){
PIString str1 = " \t\r\nBMSTU is best university in space"; PIString str1 = " \t\r\nBMSTU is best university in space";
PIString str2 = str1.takeRange('B', 'i', ' '); PIString str2 = str1.takeRange('B', 'i', ' ');
PIString res = "MSTU is best un"; PIString res = "MSTU is best un";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, takerange_without_shield_space){ TEST(PIString_Tests, takerange_without_shield_space){
PIString str1 = " \t\r\nBMSTU is best university in space"; PIString str1 = " \t\r\nBMSTU is best university in space";
PIString str2 = str1.takeRange('B', 'i'); PIString str2 = str1.takeRange('B', 'i');
PIString res = "MSTU "; PIString res = "MSTU ";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, inBrackets){ TEST(PIString_Tests, inBrackets){
PIString str1 = "BMSTU is (best) university in space"; PIString str1 = "BMSTU is (best) university in space";
PIString str2 = str1.inBrackets('(', ')'); PIString str2 = str1.inBrackets('(', ')');
PIString res = "best"; PIString res = "best";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, inBrackets_end_start){ TEST(PIString_Tests, inBrackets_end_start){
PIString str1 = "BMSTU )is (best) university in space"; PIString str1 = "BMSTU )is (best) university in space";
PIString str2 = str1.inBrackets('(', ')'); PIString str2 = str1.inBrackets('(', ')');
PIString res = "best"; PIString res = "best";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, inBrackets_without){ TEST(PIString_Tests, inBrackets_without){
PIString str1 = "BMSTU )is (best) university in space"; PIString str1 = "BMSTU )is (best) university in space";
PIString str2 = str1.inBrackets('0', '1'); PIString str2 = str1.inBrackets('0', '1');
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, lenghtascii){ TEST(PIString_Tests, lenghtascii){
PIString str1 = "BMSTU is (best) university in space"; PIString str1 = "BMSTU is (best) university in space";
int size = str1.lengthAscii(); int size = str1.lengthAscii();
ASSERT_EQ(35, size); ASSERT_EQ(35, size);
} }
TEST(PIString_Tests, data){ TEST(PIString_Tests, data){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
const char *data = str1.data(); const char *data = str1.data();
PIString res = "BMSTU is (best) university in space\n"; PIString res = "BMSTU is (best) university in space\n";
ASSERT_EQ(res, data); ASSERT_EQ(res, data);
} }
TEST(PIString_Tests, dataconsole){ TEST(PIString_Tests, dataconsole){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
const char *data = str1.dataConsole(); const char *data = str1.dataConsole();
PIString res = "BMSTU is (best) university in space\n"; PIString res = "BMSTU is (best) university in space\n";
ASSERT_EQ(res, data); ASSERT_EQ(res, data);
} }
TEST(PIString_Tests, dataUTF8){ TEST(PIString_Tests, dataUTF8){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
const char *data = str1.dataUTF8(); const char *data = str1.dataUTF8();
PIString res = "BMSTU is (best) university in space\n"; PIString res = "BMSTU is (best) university in space\n";
ASSERT_EQ(res, data); ASSERT_EQ(res, data);
} }
TEST(PIString_Tests, dataAScii){ TEST(PIString_Tests, dataAScii){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
const char *data = str1.dataAscii(); const char *data = str1.dataAscii();
PIString res = "BMSTU is (best) university in space\n"; PIString res = "BMSTU is (best) university in space\n";
ASSERT_EQ(res, data); ASSERT_EQ(res, data);
} }
TEST(PIString_Tests, hash){ TEST(PIString_Tests, hash){
const PIString str1 = "B"; const PIString str1 = "B";
uint h = str1.hash(); uint h = str1.hash();
ASSERT_EQ(3912571919, h); ASSERT_EQ(3912571919, h);
} }
TEST(PIString_Tests, toByteArray){ TEST(PIString_Tests, toByteArray){
const PIString str1 = "C"; const PIString str1 = "C";
PIByteArray h = str1.toByteArray(); PIByteArray h = str1.toByteArray();
ASSERT_EQ(67, h.at(0)); ASSERT_EQ(67, h.at(0));
} }
TEST(PIString_Tests, toUTF8){ TEST(PIString_Tests, toUTF8){
const PIString str1 = "C"; const PIString str1 = "C";
PIByteArray h = str1.toUTF8(); PIByteArray h = str1.toUTF8();
ASSERT_EQ(67, h.at(0)); ASSERT_EQ(67, h.at(0));
} }
TEST(PIString_Tests, tocharset){ TEST(PIString_Tests, tocharset){
const PIString str1 = "B"; const PIString str1 = "B";
PIByteArray h = str1.toCharset("c"); PIByteArray h = str1.toCharset("c");
ASSERT_EQ(66, h.at(0)); ASSERT_EQ(66, h.at(0));
} }
TEST(PIString_Tests, toUTF8_empty){ TEST(PIString_Tests, toUTF8_empty){
PIString str1; PIString str1;
str1.toUTF8(); str1.toUTF8();
ASSERT_EQ(0, str1.size()); ASSERT_EQ(NULL, str1.size());
} }
TEST(PIString_Tests, tocharset_empty){ TEST(PIString_Tests, tocharset_empty){
PIString str1 = ""; PIString str1 = "";
str1.toCharset("c"); str1.toCharset("c");
ASSERT_EQ(0, str1.size()); ASSERT_EQ(NULL, str1.size());
} }
TEST(PIString_Tests, split){ TEST(PIString_Tests, split){
PIString str1 = " mirrow best mirrow "; PIString str1 = " mirrow best mirrow ";
PIStringList list = str1.split("best"); PIStringList list = str1.split("best");
ASSERT_EQ(list[1], list[0]); ASSERT_EQ(list[1], list[0]);
} }
TEST(PIString_Tests, split_sec){ TEST(PIString_Tests, split_sec){
PIString str1 = " mirrow best detail "; PIString str1 = " mirrow best detail ";
PIStringList list = str1.split("best"); PIStringList list = str1.split("best");
PIString res = " mirrow "; PIString res = " mirrow ";
PIString res2 = " detail "; PIString res2 = " detail ";
ASSERT_EQ(res, list[0]); ASSERT_EQ(res, list[0]);
ASSERT_EQ(list[1], res2); ASSERT_EQ(list[1], res2);
} }
TEST(PIString_Tests, split_empty){ TEST(PIString_Tests, split_empty){
PIString str1 = ""; PIString str1 = "";
PIStringList list = str1.split("best"); PIStringList list = str1.split("best");
ASSERT_EQ(0, list.size()); ASSERT_EQ(NULL, list.size());
} }
TEST(PIString_Tests, split_empty_delim){ TEST(PIString_Tests, split_empty_delim){
PIString str1 = " mirrow best mirrow "; PIString str1 = " mirrow best mirrow ";
PIStringList list = str1.split(""); PIStringList list = str1.split("");
ASSERT_EQ(0, list.size()); ASSERT_EQ(NULL, list.size());
} }
TEST(PIString_Tests, split_not_delim){ TEST(PIString_Tests, split_not_delim){
PIString str1 = " mirrow best mirrow "; PIString str1 = " mirrow best mirrow ";
PIStringList list = str1.split("tr"); PIStringList list = str1.split("tr");
ASSERT_EQ(list[0], " mirrow best mirrow "); ASSERT_EQ(list[0], " mirrow best mirrow ");
} }
TEST(PIString_Tests, toUpperCase){ TEST(PIString_Tests, toUpperCase){
PIString str1 = " miRrow "; PIString str1 = " miRrow ";
PIString str2 = str1.toUpperCase(); PIString str2 = str1.toUpperCase();
PIString res = " MIRROW "; PIString res = " MIRROW ";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, toLowerCase){ TEST(PIString_Tests, toLowerCase){
PIString str1 = " MIrROW "; PIString str1 = " MIrROW ";
PIString str2 = str1.toLowerCase(); PIString str2 = str1.toLowerCase();
PIString res = " mirrow "; PIString res = " mirrow ";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, toNativeDecimalPoints){ TEST(PIString_Tests, toNativeDecimalPoints){
PIString str1 = "4546,878"; PIString str1 = "4546,878";
PIString str2 = str1.toNativeDecimalPoints(); PIString str2 = str1.toNativeDecimalPoints();
PIString res = "4546.878"; PIString res = "4546.878";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, contains_char){ TEST(PIString_Tests, contains_char){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
char s = '\n'; char s = '\n';
ASSERT_TRUE(str1.contains(s)); ASSERT_TRUE(str1.contains(s));
} }
TEST(PIString_Tests, contains_char_false){ TEST(PIString_Tests, contains_char_false){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
char s = '0'; char s = '0';
ASSERT_FALSE(str1.contains(s)); ASSERT_FALSE(str1.contains(s));
} }
TEST(PIString_Tests, contains_picahr){ TEST(PIString_Tests, contains_picahr){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
PIChar s = 'i'; PIChar s = 'i';
ASSERT_TRUE(str1.contains(s)); ASSERT_TRUE(str1.contains(s));
} }
TEST(PIString_Tests, contains_pichar_false){ TEST(PIString_Tests, contains_pichar_false){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
PIChar s = '0'; PIChar s = '0';
ASSERT_FALSE(str1.contains(s)); ASSERT_FALSE(str1.contains(s));
} }
TEST(PIString_Tests, contains_cahrs){ TEST(PIString_Tests, contains_cahrs){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
char s[] = "BMSTU"; char s[] = "BMSTU";
ASSERT_TRUE(str1.contains(s)); ASSERT_TRUE(str1.contains(s));
} }
TEST(PIString_Tests, contains_chars_false){ TEST(PIString_Tests, contains_chars_false){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
char s[] = "out"; char s[] = "out";
ASSERT_FALSE(str1.contains(s)); ASSERT_FALSE(str1.contains(s));
} }
TEST(PIString_Tests, contains_pistring){ TEST(PIString_Tests, contains_pistring){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
PIString s = "univer"; PIString s = "univer";
ASSERT_TRUE(str1.contains(s)); ASSERT_TRUE(str1.contains(s));
} }
TEST(PIString_Tests, contains_pistring_false){ TEST(PIString_Tests, contains_pistring_false){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
PIString s = "new"; PIString s = "new";
ASSERT_FALSE(str1.contains(s)); ASSERT_FALSE(str1.contains(s));
} }
TEST(PIString_Tests, find_char){ TEST(PIString_Tests, find_char){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
char s = 'i'; char s = 'i';
ASSERT_EQ(6, str1.find(s)); ASSERT_EQ(6, str1.find(s));
} }
TEST(PIString_Tests, find_char_start){ TEST(PIString_Tests, find_char_start){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
char s = 'i'; char s = 'i';
ASSERT_EQ(18, str1.find(s, 7)); ASSERT_EQ(18, str1.find(s, 7));
} }
TEST(PIString_Tests, find_char_false){ TEST(PIString_Tests, find_char_false){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
char s = 'o'; char s = 'o';
ASSERT_EQ(-1, str1.find(s)); ASSERT_EQ(-1, str1.find(s));
} }
TEST(PIString_Tests, find_chars){ TEST(PIString_Tests, find_chars){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
char str2[] = "is"; char str2[] = "is";
ASSERT_EQ(6, str1.find(str2)); ASSERT_EQ(6, str1.find(str2));
} }
TEST(PIString_Tests, find_chars_start){ TEST(PIString_Tests, find_chars_start){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
char str2[] = "iv"; char str2[] = "iv";
ASSERT_EQ(18, str1.find(str2, 7)); ASSERT_EQ(18, str1.find(str2, 7));
} }
TEST(PIString_Tests, find_chars_false){ TEST(PIString_Tests, find_chars_false){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
char s[] = "ouc"; char s[] = "ouc";
ASSERT_EQ(-1, str1.find(s)); ASSERT_EQ(-1, str1.find(s));
} }
TEST(PIString_Tests, find_pistring){ TEST(PIString_Tests, find_pistring){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
PIString str2 = "is"; PIString str2 = "is";
ASSERT_EQ(6, str1.find(str2)); ASSERT_EQ(6, str1.find(str2));
} }
TEST(PIString_Tests, find_pistring_start){ TEST(PIString_Tests, find_pistring_start){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
PIString str2 = "iv"; PIString str2 = "iv";
ASSERT_EQ(18, str1.find(str2, 7)); ASSERT_EQ(18, str1.find(str2, 7));
} }
TEST(PIString_Tests, find_pistring_false){ TEST(PIString_Tests, find_pistring_false){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
PIString str2 = "ouc"; PIString str2 = "ouc";
ASSERT_EQ(-1, str1.find(str2)); ASSERT_EQ(-1, str1.find(str2));
} }
TEST(PIString_Tests, find_last_char){ TEST(PIString_Tests, find_last_char){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
char s = 'i'; char s = 'i';
ASSERT_EQ(27, str1.findLast(s)); ASSERT_EQ(27, str1.findLast(s));
} }
TEST(PIString_Tests, find_last_char_start){ TEST(PIString_Tests, find_last_char_start){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
char s = 'i'; char s = 'i';
ASSERT_EQ(27, str1.findLast(s, 20)); ASSERT_EQ(27, str1.findLast(s, 20));
} }
TEST(PIString_Tests, find_last_char_false){ TEST(PIString_Tests, find_last_char_false){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
char s = 'o'; char s = 'o';
ASSERT_EQ(-1, str1.findLast(s)); ASSERT_EQ(-1, str1.findLast(s));
} }
TEST(PIString_Tests, find_last_chars){ TEST(PIString_Tests, find_last_chars){
PIString str1 = "BMSTU is (best) university in is space\n"; PIString str1 = "BMSTU is (best) university in is space\n";
char str2[] = "is"; char str2[] = "is";
ASSERT_EQ(30, str1.findLast(str2)); ASSERT_EQ(30, str1.findLast(str2));
} }
TEST(PIString_Tests, find_last_chars_start){ TEST(PIString_Tests, find_last_chars_start){
PIString str1 = "BMSTU is (best) university in iv space\n"; PIString str1 = "BMSTU is (best) university in iv space\n";
char str2[] = "iv"; char str2[] = "iv";
ASSERT_EQ(30, str1.findLast(str2, 25)); ASSERT_EQ(30, str1.findLast(str2, 25));
} }
TEST(PIString_Tests, find_last_chars_false){ TEST(PIString_Tests, find_last_chars_false){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
char str2[] = "ouc"; char str2[] = "ouc";
ASSERT_EQ(-1, str1.findLast(str2)); ASSERT_EQ(-1, str1.findLast(str2));
} }
TEST(PIString_Tests, find_last_pistring){ TEST(PIString_Tests, find_last_pistring){
PIString str1 = "BMSTU is (best) university in is space\n"; PIString str1 = "BMSTU is (best) university in is space\n";
PIString str2 = "is"; PIString str2 = "is";
ASSERT_EQ(30, str1.findLast(str2)); ASSERT_EQ(30, str1.findLast(str2));
} }
TEST(PIString_Tests, find_last_pistring_start){ TEST(PIString_Tests, find_last_pistring_start){
PIString str1 = "BMSTU is (best) university in iv space\n"; PIString str1 = "BMSTU is (best) university in iv space\n";
PIString str2 = "iv"; PIString str2 = "iv";
ASSERT_EQ(30, str1.findLast(str2, 10)); ASSERT_EQ(30, str1.findLast(str2, 10));
} }
TEST(PIString_Tests, find_last_pistring_false){ TEST(PIString_Tests, find_last_pistring_false){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
PIString str2 = "ouc"; PIString str2 = "ouc";
ASSERT_EQ(-1, str1.findLast(str2)); ASSERT_EQ(-1, str1.findLast(str2));
} }
TEST(PIString_Tests, find_word){ TEST(PIString_Tests, find_word){
PIString str1 = "BMSTU is (best) university in iv space\n"; PIString str1 = "BMSTU is (best) university in iv space\n";
PIString str2 = "university"; PIString str2 = "university";
ASSERT_EQ(16, str1.findWord(str2)); ASSERT_EQ(16, str1.findWord(str2));
} }
TEST(PIString_Tests, find_word_start){ TEST(PIString_Tests, find_word_start){
PIString str1 = "BMSTU is (best) university in iv space\n"; PIString str1 = "BMSTU is (best) university in iv space\n";
PIString str2 = "university"; PIString str2 = "university";
ASSERT_EQ(16, str1.findWord(str2, 10)); ASSERT_EQ(16, str1.findWord(str2, 10));
} }
TEST(PIString_Tests, find_word_space_before){ TEST(PIString_Tests, find_word_space_before){
PIString str1 = "BMSTU is (best) university in iv space\n"; PIString str1 = "BMSTU is (best) university in iv space\n";
PIString str2 = " university"; PIString str2 = " university";
ASSERT_EQ(-1, str1.findWord(str2, 10)); ASSERT_EQ(-1, str1.findWord(str2, 10));
} }
TEST(PIString_Tests, find_word_space_after){ TEST(PIString_Tests, find_word_space_after){
PIString str1 = "BMSTU is (best) university in iv space\n"; PIString str1 = "BMSTU is (best) university in iv space\n";
PIString str2 = "university "; PIString str2 = "university ";
ASSERT_EQ(-1, str1.findWord(str2, 10)); ASSERT_EQ(-1, str1.findWord(str2, 10));
} }
TEST(PIString_Tests, find_word_digit_before){ TEST(PIString_Tests, find_word_digit_before){
PIString str1 = "BMSTU is (best) _university_ in iv space\n"; PIString str1 = "BMSTU is (best) _university_ in iv space\n";
PIString str2 = "_university"; PIString str2 = "_university";
ASSERT_EQ(-1, str1.findWord(str2, 10)); ASSERT_EQ(-1, str1.findWord(str2, 10));
} }
TEST(PIString_Tests, find_word_digit_after){ TEST(PIString_Tests, find_word_digit_after){
PIString str1 = "BMSTU is (best) _university_ in iv space\n"; PIString str1 = "BMSTU is (best) _university_ in iv space\n";
PIString str2 = "university_"; PIString str2 = "university_";
ASSERT_EQ(-1, str1.findWord(str2, 10)); ASSERT_EQ(-1, str1.findWord(str2, 10));
} }
TEST(PIString_Tests, find_word_false){ TEST(PIString_Tests, find_word_false){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
PIString str2 = "university"; PIString str2 = "university";
ASSERT_EQ(-1, str1.findWord(str2, 37)); ASSERT_EQ(-1, str1.findWord(str2, 37));
} }
TEST(PIString_Tests, find_cword){ TEST(PIString_Tests, find_cword){
PIString str1 = "BMSTU is (best) university in iv space\n"; PIString str1 = "BMSTU is (best) university in iv space\n";
PIString str2 = "university"; PIString str2 = "university";
ASSERT_EQ(16, str1.findCWord(str2)); ASSERT_EQ(16, str1.findCWord(str2));
} }
TEST(PIString_Tests, find_cword_start){ TEST(PIString_Tests, find_cword_start){
PIString str1 = "BMSTU is (best) university in iv space\n"; PIString str1 = "BMSTU is (best) university in iv space\n";
PIString str2 = "university"; PIString str2 = "university";
ASSERT_EQ(16, str1.findCWord(str2, 10)); ASSERT_EQ(16, str1.findCWord(str2, 10));
} }
TEST(PIString_Tests, find_cword_space_before){ TEST(PIString_Tests, find_cword_space_before){
PIString str1 = "BMSTU is (best) university in iv space\n"; PIString str1 = "BMSTU is (best) university in iv space\n";
PIString str2 = " university"; PIString str2 = " university";
ASSERT_EQ(15, str1.findCWord(str2, 10)); ASSERT_EQ(15, str1.findCWord(str2, 10));
} }
TEST(PIString_Tests, find_cword_space_after){ TEST(PIString_Tests, find_cword_space_after){
PIString str1 = "BMSTU is (best) university in iv space\n"; PIString str1 = "BMSTU is (best) university in iv space\n";
PIString str2 = "university "; PIString str2 = "university ";
ASSERT_EQ(-1, str1.findCWord(str2, 10)); ASSERT_EQ(-1, str1.findCWord(str2, 10));
} }
TEST(PIString_Tests, find_cword_digit_before){ TEST(PIString_Tests, find_cword_digit_before){
PIString str1 = "BMSTU is (best) _university_ in iv space\n"; PIString str1 = "BMSTU is (best) _university_ in iv space\n";
PIString str2 = "_university"; PIString str2 = "_university";
ASSERT_EQ(-1, str1.findCWord(str2, 10)); ASSERT_EQ(-1, str1.findCWord(str2, 10));
} }
TEST(PIString_Tests, find_cword_digit_after){ TEST(PIString_Tests, find_cword_digit_after){
PIString str1 = "BMSTU is (best) _university_ in iv space\n"; PIString str1 = "BMSTU is (best) _university_ in iv space\n";
PIString str2 = "university_"; PIString str2 = "university_";
ASSERT_EQ(-1, str1.findCWord(str2, 10)); ASSERT_EQ(-1, str1.findCWord(str2, 10));
} }
TEST(PIString_Tests, find_cword_false){ TEST(PIString_Tests, find_cword_false){
PIString str1 = "BMSTU is (best) university in space\n"; PIString str1 = "BMSTU is (best) university in space\n";
PIString str2 = "university"; PIString str2 = "university";
ASSERT_EQ(-1, str1.findCWord(str2, 37)); ASSERT_EQ(-1, str1.findCWord(str2, 37));
} }
TEST(PIString_Tests, find_range){ TEST(PIString_Tests, find_range){
PIString str1 = "A very strong programmer wrote this code"; PIString str1 = "A very strong programmer wrote this code";
PIChar start = "v"; PIChar start = "v";
PIChar end = "g"; PIChar end = "g";
ASSERT_EQ(3, str1.findRange(start, end, "n", 1)); ASSERT_EQ(3, str1.findRange(start, end, "n", 1));
} }
TEST(PIString_Tests, find_range_len){ TEST(PIString_Tests, find_range_len){
PIString str1 = "A very strong programmer wrote this code"; PIString str1 = "A very strong programmer wrote this code";
PIChar start = "v"; PIChar start = "v";
PIChar end = "g"; PIChar end = "g";
int len; int len;
str1.findRange(start, end, "n", 1, &len); str1.findRange(start, end, "n", 1, &len);
ASSERT_EQ(14, len); ASSERT_EQ(14, len);
} }
TEST(PIString_Tests, find_range_len_without_shield){ TEST(PIString_Tests, find_range_len_without_shield){
PIString str1 = "A very strong programmer wrote this code"; PIString str1 = "A very strong programmer wrote this code";
PIChar start = "v"; PIChar start = "v";
PIChar end = "g"; PIChar end = "g";
int len; int len;
str1.findRange(start, end, "/", 1, &len); str1.findRange(start, end, "/", 1, &len);
ASSERT_EQ(9, len); ASSERT_EQ(9, len);
} }
TEST(PIString_Tests, find_range_start){ TEST(PIString_Tests, find_range_start){
PIString str1 = "A very strong programmer wrote this code"; PIString str1 = "A very strong programmer wrote this code";
PIChar start = "g"; PIChar start = "g";
PIChar end = "o"; PIChar end = "o";
int len; int len;
str1.findRange(start, end, " ", 17, &len); str1.findRange(start, end, " ", 17, &len);
ASSERT_EQ(9, len); ASSERT_EQ(9, len);
} }
TEST(PIString_Tests, find_range_eq){ TEST(PIString_Tests, find_range_eq){
PIString str1 = "A very strong programmer wrote this code"; PIString str1 = "A very strong programmer wrote this code";
PIChar start = "v"; PIChar start = "v";
PIChar end = "v"; PIChar end = "v";
int len; int len;
str1.findRange(start, end, "n", 1, &len); str1.findRange(start, end, "n", 1, &len);
ASSERT_EQ(0, len); ASSERT_EQ(NULL, len);
} }
TEST(PIString_Tests, find_range_trim){ TEST(PIString_Tests, find_range_trim){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
PIChar start = "A"; PIChar start = "A";
PIChar end = "v"; PIChar end = "v";
int len; int len;
ASSERT_EQ(2, str1.findRange(start, end, "n", 0, &len)); ASSERT_EQ(2, str1.findRange(start, end, "n", 0, &len));
} }
TEST(PIString_Tests, find_any){ TEST(PIString_Tests, find_any){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
PIString str2 = "doip"; PIString str2 = "doip";
ASSERT_EQ(11, str1.findAny(str2, 0)); ASSERT_EQ(11, str1.findAny(str2, 0));
} }
TEST(PIString_Tests, find_any_not){ TEST(PIString_Tests, find_any_not){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
PIString str2 = "q"; PIString str2 = "q";
ASSERT_EQ(-1, str1.findAny(str2, 0)); ASSERT_EQ(-1, str1.findAny(str2, 0));
} }
TEST(PIString_Tests, find_any_start){ TEST(PIString_Tests, find_any_start){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
PIString str2 = "doip"; PIString str2 = "doip";
ASSERT_EQ(15, str1.findAny(str2, 12)); ASSERT_EQ(15, str1.findAny(str2, 12));
} }
TEST(PIString_Tests, find_any_chars){ TEST(PIString_Tests, find_any_chars){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
char str2[] = "doip"; char str2[] = "doip";
ASSERT_EQ(11, str1.findAny(str2, 0)); ASSERT_EQ(11, str1.findAny(str2, 0));
} }
TEST(PIString_Tests, find_any_chars_not){ TEST(PIString_Tests, find_any_chars_not){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
char str2[] = "q"; char str2[] = "q";
ASSERT_EQ(-1, str1.findAny(str2, 0)); ASSERT_EQ(-1, str1.findAny(str2, 0));
} }
TEST(PIString_Tests, find_any_chars_start){ TEST(PIString_Tests, find_any_chars_start){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
char str2[] = "doip"; char str2[] = "doip";
ASSERT_EQ(15, str1.findAny(str2, 12)); ASSERT_EQ(15, str1.findAny(str2, 12));
} }
TEST(PIString_Tests, find_any_last){ TEST(PIString_Tests, find_any_last){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
PIString str2 = "doip"; PIString str2 = "doip";
ASSERT_EQ(39, str1.findAnyLast(str2, 0)); ASSERT_EQ(39, str1.findAnyLast(str2, 0));
} }
TEST(PIString_Tests, find_any_last_not){ TEST(PIString_Tests, find_any_last_not){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
PIString str2 = "q"; PIString str2 = "q";
ASSERT_EQ(-1, str1.findAnyLast(str2, 0)); ASSERT_EQ(-1, str1.findAnyLast(str2, 0));
} }
TEST(PIString_Tests, find_any_last_start){ TEST(PIString_Tests, find_any_last_start){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
PIString str2 = "doip"; PIString str2 = "doip";
ASSERT_EQ(39, str1.findAnyLast(str2, 12)); ASSERT_EQ(39, str1.findAnyLast(str2, 12));
} }
TEST(PIString_Tests, find_any_last_chars){ TEST(PIString_Tests, find_any_last_chars){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
char str2[] = "doip"; char str2[] = "doip";
ASSERT_EQ(39, str1.findAnyLast(str2, 0)); ASSERT_EQ(39, str1.findAnyLast(str2, 0));
} }
TEST(PIString_Tests, find_any_last_chars_not){ TEST(PIString_Tests, find_any_last_chars_not){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
char str2[] = "q"; char str2[] = "q";
ASSERT_EQ(-1, str1.findAnyLast(str2, 0)); ASSERT_EQ(-1, str1.findAnyLast(str2, 0));
} }
TEST(PIString_Tests, find_any_last_chars_start){ TEST(PIString_Tests, find_any_last_chars_start){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
char str2[] = "doip"; char str2[] = "doip";
ASSERT_EQ(39, str1.findAnyLast(str2, 12)); ASSERT_EQ(39, str1.findAnyLast(str2, 12));
} }
TEST(PIString_Tests, entries){ TEST(PIString_Tests, entries){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
PIChar c = "A"; PIChar c = "A";
ASSERT_EQ(1, str1.entries(c)); ASSERT_EQ(1, str1.entries(c));
} }
TEST(PIString_Tests, entries_char){ TEST(PIString_Tests, entries_char){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
char c = 'A'; char c = 'A';
ASSERT_EQ(1, str1.entries(c)); ASSERT_EQ(1, str1.entries(c));
} }
TEST(PIString_Tests, starts_with){ TEST(PIString_Tests, starts_with){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
PIString str2 = " A very"; PIString str2 = " A very";
ASSERT_TRUE(str1.startsWith(str2)); ASSERT_TRUE(str1.startsWith(str2));
} }
TEST(PIString_Tests, starts_with_false){ TEST(PIString_Tests, starts_with_false){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
PIString str2 = " A veru"; PIString str2 = " A veru";
ASSERT_FALSE(str1.startsWith(str2)); ASSERT_FALSE(str1.startsWith(str2));
} }
TEST(PIString_Tests, ends_with){ TEST(PIString_Tests, ends_with){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
PIString str2 = " code"; PIString str2 = " code";
ASSERT_TRUE(str1.endsWith(str2)); ASSERT_TRUE(str1.endsWith(str2));
} }
TEST(PIString_Tests, ends_with_false){ TEST(PIString_Tests, ends_with_false){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
PIString str2 = "c code"; PIString str2 = "c code";
ASSERT_FALSE(str1.endsWith(str2)); ASSERT_FALSE(str1.endsWith(str2));
} }
TEST(PIString_Tests, length){ TEST(PIString_Tests, length){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
ASSERT_EQ(41, str1.length()); ASSERT_EQ(41, str1.length());
} }
TEST(PIString_Tests, is_empty_false){ TEST(PIString_Tests, is_empty_false){
PIString str1 = " A very strong programmer wrote this code"; PIString str1 = " A very strong programmer wrote this code";
ASSERT_FALSE(str1.isEmpty()); ASSERT_FALSE(str1.isEmpty());
} }
TEST(PIString_Tests, is_empty_true){ TEST(PIString_Tests, is_empty_true){
PIString str1 = ""; PIString str1 = "";
ASSERT_TRUE(str1.isEmpty()); ASSERT_TRUE(str1.isEmpty());
} }
TEST(PIString_Tests, to_bool){ TEST(PIString_Tests, to_bool){
PIString str1 = "1"; PIString str1 = "1";
ASSERT_TRUE(str1.toBool()); ASSERT_TRUE(str1.toBool());
} }
TEST(PIString_Tests, to_bool_yes){ TEST(PIString_Tests, to_bool_yes){
PIString str1 = "yes"; PIString str1 = "yes";
ASSERT_TRUE(str1.toBool()); ASSERT_TRUE(str1.toBool());
} }
TEST(PIString_Tests, to_bool_false){ TEST(PIString_Tests, to_bool_false){
PIString str1 = "no"; PIString str1 = "no";
ASSERT_FALSE(str1.toBool()); ASSERT_FALSE(str1.toBool());
} }
TEST(PIString_Tests, to_bool_false_zero){ TEST(PIString_Tests, to_bool_false_zero){
PIString str1 = "0"; PIString str1 = "0";
ASSERT_FALSE(str1.toBool()); ASSERT_FALSE(str1.toBool());
} }
TEST(PIString_Tests, to_char){ TEST(PIString_Tests, to_char){
PIString str1 = "A very strong programmer wrote this code"; PIString str1 = "A very strong programmer wrote this code";
ASSERT_EQ(65, str1.toChar()); ASSERT_EQ(65, str1.toChar());
} }
TEST(PIString_Tests, to_short){ TEST(PIString_Tests, to_short){
PIString str1 = "133"; PIString str1 = "133";
ASSERT_EQ(133, str1.toShort(-1)); ASSERT_EQ(133, str1.toShort(-1));
} }
TEST(PIString_Tests, to_short_0x){ TEST(PIString_Tests, to_short_0x){
PIString str1 = "0x133"; PIString str1 = "0x133";
ASSERT_EQ(307, str1.toShort(-1)); ASSERT_EQ(307, str1.toShort(-1));
} }
TEST(PIString_Tests, to_short_false){ TEST(PIString_Tests, to_short_false){
PIString str1 = "0x133"; PIString str1 = "0x133";
bool ok; bool ok;
str1.toShort(1, &ok); str1.toShort(1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, to_short_false_base){ TEST(PIString_Tests, to_short_false_base){
PIString str1 = "7"; PIString str1 = "7";
bool ok; bool ok;
str1.toShort(6, &ok); str1.toShort(6, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, to_short_neg){ TEST(PIString_Tests, to_short_neg){
PIString str1 = "-7"; PIString str1 = "-7";
bool ok; bool ok;
ASSERT_EQ(-7, str1.toShort(10, &ok)); ASSERT_EQ(-7, str1.toShort(10, &ok));
} }
TEST(PIString_Tests, to_ushort){ TEST(PIString_Tests, to_ushort){
PIString str1 = "133.1"; PIString str1 = "133.1";
ASSERT_EQ(133, str1.toUShort(-1)); ASSERT_EQ(133, str1.toUShort(-1));
} }
TEST(PIString_Tests, to_ushort_0x){ TEST(PIString_Tests, to_ushort_0x){
PIString str1 = "0x133"; PIString str1 = "0x133";
ASSERT_EQ(307, str1.toUShort(-1)); ASSERT_EQ(307, str1.toUShort(-1));
} }
TEST(PIString_Tests, to_ushort_false){ TEST(PIString_Tests, to_ushort_false){
PIString str1 = "0x133"; PIString str1 = "0x133";
bool ok; bool ok;
str1.toUShort(1, &ok); str1.toUShort(1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, to_ushort_false_base){ TEST(PIString_Tests, to_ushort_false_base){
PIString str1 = "7"; PIString str1 = "7";
bool ok; bool ok;
str1.toUShort(6, &ok); str1.toUShort(6, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, to_ushort_neg){ TEST(PIString_Tests, to_ushort_neg){
PIString str1 = "-7"; PIString str1 = "-7";
bool ok; bool ok;
ASSERT_EQ(65529, str1.toUShort(10, &ok)); ASSERT_EQ(65529, str1.toUShort(10, &ok));
} }
TEST(PIString_Tests, to_int){ TEST(PIString_Tests, to_int){
PIString str1 = "133"; PIString str1 = "133";
ASSERT_EQ(133, str1.toInt(-1)); ASSERT_EQ(133, str1.toInt(-1));
} }
TEST(PIString_Tests, to_int_0x){ TEST(PIString_Tests, to_int_0x){
PIString str1 = "0x133"; PIString str1 = "0x133";
ASSERT_EQ(307, str1.toInt(-1)); ASSERT_EQ(307, str1.toInt(-1));
} }
TEST(PIString_Tests, to_int_false){ TEST(PIString_Tests, to_int_false){
PIString str1 = "0x133"; PIString str1 = "0x133";
bool ok; bool ok;
str1.toInt(1, &ok); str1.toInt(1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, to_int_false_base){ TEST(PIString_Tests, to_int_false_base){
PIString str1 = "7"; PIString str1 = "7";
bool ok; bool ok;
str1.toInt(6, &ok); str1.toInt(6, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, to_int_neg){ TEST(PIString_Tests, to_int_neg){
PIString str1 = "-7"; PIString str1 = "-7";
bool ok; bool ok;
ASSERT_EQ(-7, str1.toShort(10, &ok)); ASSERT_EQ(-7, str1.toShort(10, &ok));
} }
TEST(PIString_Tests, to_uint){ TEST(PIString_Tests, to_uint){
PIString str1 = "133.1"; PIString str1 = "133.1";
ASSERT_EQ(133, str1.toUInt(-1)); ASSERT_EQ(133, str1.toUInt(-1));
} }
TEST(PIString_Tests, to_uint_0x){ TEST(PIString_Tests, to_uint_0x){
PIString str1 = "0x133"; PIString str1 = "0x133";
ASSERT_EQ(307, str1.toUInt(-1)); ASSERT_EQ(307, str1.toUInt(-1));
} }
TEST(PIString_Tests, to_uint_false){ TEST(PIString_Tests, to_uint_false){
PIString str1 = "0x133"; PIString str1 = "0x133";
bool ok; bool ok;
str1.toUInt(1, &ok); str1.toUInt(1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, to_uint_false_base){ TEST(PIString_Tests, to_uint_false_base){
PIString str1 = "7"; PIString str1 = "7";
bool ok; bool ok;
str1.toUInt(6, &ok); str1.toUInt(6, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, to_uint_neg){ TEST(PIString_Tests, to_uint_neg){
PIString str1 = "-7"; PIString str1 = "-7";
bool ok; bool ok;
ASSERT_EQ(4294967289, str1.toUInt(10, &ok)); ASSERT_EQ(4294967289, str1.toUInt(10, &ok));
} }
TEST(PIString_Tests, to_long){ TEST(PIString_Tests, to_long){
PIString str1 = "133"; PIString str1 = "133";
ASSERT_EQ(133, str1.toLong(-1)); ASSERT_EQ(133, str1.toLong(-1));
} }
TEST(PIString_Tests, to_long_0x){ TEST(PIString_Tests, to_long_0x){
PIString str1 = "0x133"; PIString str1 = "0x133";
ASSERT_EQ(307, str1.toLong(-1)); ASSERT_EQ(307, str1.toLong(-1));
} }
TEST(PIString_Tests, to_long_false){ TEST(PIString_Tests, to_long_false){
PIString str1 = "0x133"; PIString str1 = "0x133";
bool ok; bool ok;
str1.toLong(1, &ok); str1.toLong(1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, to_long_false_base){ TEST(PIString_Tests, to_long_false_base){
PIString str1 = "7"; PIString str1 = "7";
bool ok; bool ok;
str1.toLong(6, &ok); str1.toLong(6, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, to_long_neg){ TEST(PIString_Tests, to_long_neg){
PIString str1 = "-7"; PIString str1 = "-7";
bool ok; bool ok;
ASSERT_EQ(-7, str1.toLong(10, &ok)); ASSERT_EQ(-7, str1.toLong(10, &ok));
} }
TEST(PIString_Tests, to_ulong){ TEST(PIString_Tests, to_ulong){
PIString str1 = "133.1"; PIString str1 = "133.1";
ASSERT_EQ(133, str1.toULong(-1)); ASSERT_EQ(133, str1.toULong(-1));
} }
TEST(PIString_Tests, to_ulong_0x){ TEST(PIString_Tests, to_ulong_0x){
PIString str1 = "0x133"; PIString str1 = "0x133";
ASSERT_EQ(307, str1.toULong(-1)); ASSERT_EQ(307, str1.toULong(-1));
} }
TEST(PIString_Tests, to_ulong_false){ TEST(PIString_Tests, to_ulong_false){
PIString str1 = "0x133"; PIString str1 = "0x133";
bool ok; bool ok;
str1.toULong(1, &ok); str1.toULong(1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, to_ulong_false_base){ TEST(PIString_Tests, to_ulong_false_base){
PIString str1 = "7"; PIString str1 = "7";
bool ok; bool ok;
str1.toULong(6, &ok); str1.toULong(6, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, to_ulong_neg){ TEST(PIString_Tests, to_ulong_neg){
PIString str1 = "-7"; PIString str1 = "-7";
bool ok; bool ok;
ASSERT_EQ(4294967289, str1.toULong(10, &ok)); ASSERT_EQ(4294967289, str1.toULong(10, &ok));
} }
TEST(PIString_Tests, to_llong){ TEST(PIString_Tests, to_llong){
PIString str1 = "133"; PIString str1 = "133";
ASSERT_EQ(133, str1.toLLong(-1)); ASSERT_EQ(133, str1.toLLong(-1));
} }
TEST(PIString_Tests, to_llong_0x){ TEST(PIString_Tests, to_llong_0x){
PIString str1 = "0x133"; PIString str1 = "0x133";
ASSERT_EQ(307, str1.toLLong(-1)); ASSERT_EQ(307, str1.toLLong(-1));
} }
TEST(PIString_Tests, to_llong_false){ TEST(PIString_Tests, to_llong_false){
PIString str1 = "0x133"; PIString str1 = "0x133";
bool ok; bool ok;
str1.toLLong(1, &ok); str1.toLLong(1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, to_llong_false_base){ TEST(PIString_Tests, to_llong_false_base){
PIString str1 = "7"; PIString str1 = "7";
bool ok; bool ok;
str1.toLLong(6, &ok); str1.toLLong(6, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, to_llong_neg){ TEST(PIString_Tests, to_llong_neg){
PIString str1 = "-7"; PIString str1 = "-7";
bool ok; bool ok;
ASSERT_EQ(-7, str1.toLLong(10, &ok)); ASSERT_EQ(-7, str1.toLLong(10, &ok));
} }
TEST(PIString_Tests, to_ullong){ TEST(PIString_Tests, to_ullong){
PIString str1 = "133.1"; PIString str1 = "133.1";
ASSERT_EQ(133, str1.toULLong(-1)); ASSERT_EQ(133, str1.toULLong(-1));
} }
TEST(PIString_Tests, to_ullong_0x){ TEST(PIString_Tests, to_ullong_0x){
PIString str1 = "0x133"; PIString str1 = "0x133";
ASSERT_EQ(307, str1.toULLong(-1)); ASSERT_EQ(307, str1.toULLong(-1));
} }
TEST(PIString_Tests, to_ullong_false){ TEST(PIString_Tests, to_ullong_false){
PIString str1 = "0x133"; PIString str1 = "0x133";
bool ok; bool ok;
str1.toULLong(1, &ok); str1.toULLong(1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, to_ullong_false_base){ TEST(PIString_Tests, to_ullong_false_base){
PIString str1 = "7"; PIString str1 = "7";
bool ok; bool ok;
str1.toULLong(6, &ok); str1.toULLong(6, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, to_float){ TEST(PIString_Tests, to_float){
PIString str1 = "-7765,54"; PIString str1 = "-7765,54";
float f = -7765.54; float f = -7765.54f;
ASSERT_EQ(f, str1.toFloat()); ASSERT_EQ(f, str1.toFloat());
} }
TEST(PIString_Tests, to_double){ TEST(PIString_Tests, to_double){
PIString str1 = "-7765,54656"; PIString str1 = "-7765,54656";
double f = -7765.54656; double f = -7765.54656;
ASSERT_EQ(f, str1.toDouble()); ASSERT_EQ(f, str1.toDouble());
} }
TEST(PIString_Tests, to_ldouble){ TEST(DISABLED_PIString_Tests, to_ldouble){
PIString str1 = "-7765,54656"; PIString str1 = "-7765,55";
ldouble f = -7765.54656; ldouble f = -7765.55l;
ASSERT_EQ(f, str1.toLDouble()); ASSERT_TRUE(f == str1.toLDouble());
} }
TEST(PIString_Tests, setNumber){ TEST(PIString_Tests, setNumber){
PIString str1 = " String"; PIString str1 = " String";
const short val = 131; const short val = 131;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
PIString res = "131"; PIString res = "131";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_zero){ TEST(PIString_Tests, setNumber_zero){
PIString str1 = " String"; PIString str1 = " String";
const short val = 0; const short val = 0;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
PIString res = "0"; PIString res = "0";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_false_base){ TEST(PIString_Tests, setNumber_false_base){
PIString str1 = " String"; PIString str1 = " String";
const short val = 131; const short val = 131;
bool ok; bool ok;
str1.setNumber(val, 1, &ok); str1.setNumber(val, 1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, setNumber_true){ TEST(PIString_Tests, setNumber_true){
PIString str1 = " String"; PIString str1 = " String";
const short val = 131; const short val = 131;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
ASSERT_TRUE(ok); ASSERT_TRUE(ok);
} }
TEST(PIString_Tests, setNumber_false_base_str){ TEST(PIString_Tests, setNumber_false_base_str){
PIString str1 = " String"; PIString str1 = " String";
const short val = 131; const short val = 131;
bool ok; bool ok;
str1.setNumber(val, 1, &ok); str1.setNumber(val, 1, &ok);
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_base_minus){ TEST(PIString_Tests, setNumber_base_minus){
PIString str1 = " String"; PIString str1 = " String";
const short val = -10; const short val = -10;
bool ok; bool ok;
str1.setNumber(val, 16, &ok); str1.setNumber(val, 16, &ok);
PIString res = "-A"; PIString res = "-A";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_ushort){ TEST(PIString_Tests, setNumber_ushort){
PIString str1 = " String"; PIString str1 = " String";
const ushort val = 131; const ushort val = 131;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
PIString res = "131"; PIString res = "131";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_ushort_true){ TEST(PIString_Tests, setNumber_ushort_true){
PIString str1 = " String"; PIString str1 = " String";
const ushort val = 131; const ushort val = 131;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
ASSERT_TRUE(ok); ASSERT_TRUE(ok);
} }
TEST(PIString_Tests, setNumber_ushort_zero){ TEST(PIString_Tests, setNumber_ushort_zero){
PIString str1 = " String"; PIString str1 = " String";
const ushort val = 0; const ushort val = 0;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
PIString res = "0"; PIString res = "0";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_ushort_false_base){ TEST(PIString_Tests, setNumber_ushort_false_base){
PIString str1 = " String"; PIString str1 = " String";
const ushort val = 131; const ushort val = 131;
bool ok; bool ok;
str1.setNumber(val, 1, &ok); str1.setNumber(val, 1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, setNumber_ushort_false_base_str){ TEST(PIString_Tests, setNumber_ushort_false_base_str){
PIString str1 = " String"; PIString str1 = " String";
const ushort val = 131; const ushort val = 131;
bool ok; bool ok;
str1.setNumber(val, 1, &ok); str1.setNumber(val, 1, &ok);
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_ushort_base_minus){ TEST(PIString_Tests, setNumber_ushort_base_minus){
PIString str1 = " String"; PIString str1 = " String";
const ushort val = 10; const ushort val = 10;
bool ok; bool ok;
str1.setNumber(val, 16, &ok); str1.setNumber(val, 16, &ok);
PIString res = "A"; PIString res = "A";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_int){ TEST(PIString_Tests, setNumber_int){
PIString str1 = " String"; PIString str1 = " String";
const int val = 131; const int val = 131;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
PIString res = "131"; PIString res = "131";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_int_zero){ TEST(PIString_Tests, setNumber_int_zero){
PIString str1 = " String"; PIString str1 = " String";
const int val = 0; const int val = 0;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
PIString res = "0"; PIString res = "0";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_int_false_base){ TEST(PIString_Tests, setNumber_int_false_base){
PIString str1 = " String"; PIString str1 = " String";
const int val = 131; const int val = 131;
bool ok; bool ok;
str1.setNumber(val, 1, &ok); str1.setNumber(val, 1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, setNumber_int_true){ TEST(PIString_Tests, setNumber_int_true){
PIString str1 = " String"; PIString str1 = " String";
const int val = 131; const int val = 131;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
ASSERT_TRUE(ok); ASSERT_TRUE(ok);
} }
TEST(PIString_Tests, setNumber_int_false_base_str){ TEST(PIString_Tests, setNumber_int_false_base_str){
PIString str1 = " String"; PIString str1 = " String";
const int val = 131; const int val = 131;
bool ok; bool ok;
str1.setNumber(val, 1, &ok); str1.setNumber(val, 1, &ok);
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_int_base_minus){ TEST(PIString_Tests, setNumber_int_base_minus){
PIString str1 = " String"; PIString str1 = " String";
const int val = -10; const int val = -10;
bool ok; bool ok;
str1.setNumber(val, 16, &ok); str1.setNumber(val, 16, &ok);
PIString res = "-A"; PIString res = "-A";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_uint){ TEST(PIString_Tests, setNumber_uint){
PIString str1 = " String"; PIString str1 = " String";
const uint val = 131; const uint val = 131;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
PIString res = "131"; PIString res = "131";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_uint_true){ TEST(PIString_Tests, setNumber_uint_true){
PIString str1 = " String"; PIString str1 = " String";
const uint val = 131; const uint val = 131;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
ASSERT_TRUE(ok); ASSERT_TRUE(ok);
} }
TEST(PIString_Tests, setNumber_uintt_zero){ TEST(PIString_Tests, setNumber_uintt_zero){
PIString str1 = " String"; PIString str1 = " String";
const uint val = 0; const uint val = 0;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
PIString res = "0"; PIString res = "0";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_uint_false_base){ TEST(PIString_Tests, setNumber_uint_false_base){
PIString str1 = " String"; PIString str1 = " String";
const uint val = 131; const uint val = 131;
bool ok; bool ok;
str1.setNumber(val, 1, &ok); str1.setNumber(val, 1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, setNumber_uint_false_base_str){ TEST(PIString_Tests, setNumber_uint_false_base_str){
PIString str1 = " String"; PIString str1 = " String";
const uint val = 131; const uint val = 131;
bool ok; bool ok;
str1.setNumber(val, 1, &ok); str1.setNumber(val, 1, &ok);
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_uint_base_minus){ TEST(PIString_Tests, setNumber_uint_base_minus){
PIString str1 = " String"; PIString str1 = " String";
const uint val = 10; const uint val = 10;
bool ok; bool ok;
str1.setNumber(val, 16, &ok); str1.setNumber(val, 16, &ok);
PIString res = "A"; PIString res = "A";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_long){ TEST(PIString_Tests, setNumber_long){
PIString str1 = " String"; PIString str1 = " String";
const long val = 131; const long val = 131;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
PIString res = "131"; PIString res = "131";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_long_zero){ TEST(PIString_Tests, setNumber_long_zero){
PIString str1 = " String"; PIString str1 = " String";
const long val = 0; const long val = 0;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
PIString res = "0"; PIString res = "0";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_long_false_base){ TEST(PIString_Tests, setNumber_long_false_base){
PIString str1 = " String"; PIString str1 = " String";
const long val = 131; const long val = 131;
bool ok; bool ok;
str1.setNumber(val, 1, &ok); str1.setNumber(val, 1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, setNumber_long_true){ TEST(PIString_Tests, setNumber_long_true){
PIString str1 = " String"; PIString str1 = " String";
const long val = 131; const long val = 131;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
ASSERT_TRUE(ok); ASSERT_TRUE(ok);
} }
TEST(PIString_Tests, setNumber_long_false_base_str){ TEST(PIString_Tests, setNumber_long_false_base_str){
PIString str1 = " String"; PIString str1 = " String";
const long val = 131; const long val = 131;
bool ok; bool ok;
str1.setNumber(val, 1, &ok); str1.setNumber(val, 1, &ok);
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_long_base_minus){ TEST(PIString_Tests, setNumber_long_base_minus){
PIString str1 = " String"; PIString str1 = " String";
const long val = -10; const long val = -10;
bool ok; bool ok;
str1.setNumber(val, 16, &ok); str1.setNumber(val, 16, &ok);
PIString res = "-A"; PIString res = "-A";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_ulong){ TEST(PIString_Tests, setNumber_ulong){
PIString str1 = " String"; PIString str1 = " String";
const ulong val = 131; const ulong val = 131;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
PIString res = "131"; PIString res = "131";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_ulong_true){ TEST(PIString_Tests, setNumber_ulong_true){
PIString str1 = " String"; PIString str1 = " String";
const ulong val = 131; const ulong val = 131;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
ASSERT_TRUE(ok); ASSERT_TRUE(ok);
} }
TEST(PIString_Tests, setNumber_ulong_zero){ TEST(PIString_Tests, setNumber_ulong_zero){
PIString str1 = " String"; PIString str1 = " String";
const ulong val = 0; const ulong val = 0;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
PIString res = "0"; PIString res = "0";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_ulong_false_base){ TEST(PIString_Tests, setNumber_ulong_false_base){
PIString str1 = " String"; PIString str1 = " String";
const ulong val = 131; const ulong val = 131;
bool ok; bool ok;
str1.setNumber(val, 1, &ok); str1.setNumber(val, 1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, setNumber_ulong_false_base_str){ TEST(PIString_Tests, setNumber_ulong_false_base_str){
PIString str1 = " String"; PIString str1 = " String";
const ulong val = 131; const ulong val = 131;
bool ok; bool ok;
str1.setNumber(val, 1, &ok); str1.setNumber(val, 1, &ok);
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_ulong_base_minus){ TEST(PIString_Tests, setNumber_ulong_base_minus){
PIString str1 = " String"; PIString str1 = " String";
const ulong val = 10; const ulong val = 10;
bool ok; bool ok;
str1.setNumber(val, 16, &ok); str1.setNumber(val, 16, &ok);
PIString res = "A"; PIString res = "A";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_llong){ TEST(PIString_Tests, setNumber_llong){
PIString str1 = " String"; PIString str1 = " String";
const llong val = 131; const llong val = 131;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
PIString res = "131"; PIString res = "131";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_llong_zero){ TEST(PIString_Tests, setNumber_llong_zero){
PIString str1 = " String"; PIString str1 = " String";
const llong val = 0; const llong val = 0;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
PIString res = "0"; PIString res = "0";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_llong_false_base){ TEST(PIString_Tests, setNumber_llong_false_base){
PIString str1 = " String"; PIString str1 = " String";
const llong val = 131; const llong val = 131;
bool ok; bool ok;
str1.setNumber(val, 1, &ok); str1.setNumber(val, 1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, setNumber_llong_true){ TEST(PIString_Tests, setNumber_llong_true){
PIString str1 = " String"; PIString str1 = " String";
const llong val = 131; const llong val = 131;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
ASSERT_TRUE(ok); ASSERT_TRUE(ok);
} }
TEST(PIString_Tests, setNumber_llong_false_base_str){ TEST(PIString_Tests, setNumber_llong_false_base_str){
PIString str1 = " String"; PIString str1 = " String";
const llong val = 131; const llong val = 131;
bool ok; bool ok;
str1.setNumber(val, 1, &ok); str1.setNumber(val, 1, &ok);
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_llong_base_minus){ TEST(PIString_Tests, setNumber_llong_base_minus){
PIString str1 = " String"; PIString str1 = " String";
const llong val = -10; const llong val = -10;
bool ok; bool ok;
str1.setNumber(val, 16, &ok); str1.setNumber(val, 16, &ok);
PIString res = "-A"; PIString res = "-A";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_ullong){ TEST(PIString_Tests, setNumber_ullong){
PIString str1 = " String"; PIString str1 = " String";
const ullong val = 131; const ullong val = 131;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
PIString res = "131"; PIString res = "131";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_ullong_true){ TEST(PIString_Tests, setNumber_ullong_true){
PIString str1 = " String"; PIString str1 = " String";
const ullong val = 131; const ullong val = 131;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
ASSERT_TRUE(ok); ASSERT_TRUE(ok);
} }
TEST(PIString_Tests, setNumber_ullong_zero){ TEST(PIString_Tests, setNumber_ullong_zero){
PIString str1 = " String"; PIString str1 = " String";
const ullong val = 0; const ullong val = 0;
bool ok; bool ok;
str1.setNumber(val, 10, &ok); str1.setNumber(val, 10, &ok);
PIString res = "0"; PIString res = "0";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_ullong_false_base){ TEST(PIString_Tests, setNumber_ullong_false_base){
PIString str1 = " String"; PIString str1 = " String";
const ullong val = 131; const ullong val = 131;
bool ok; bool ok;
str1.setNumber(val, 1, &ok); str1.setNumber(val, 1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, setNumber_ullong_false_base_str){ TEST(PIString_Tests, setNumber_ullong_false_base_str){
PIString str1 = " String"; PIString str1 = " String";
const ullong val = 131; const ullong val = 131;
bool ok; bool ok;
str1.setNumber(val, 1, &ok); str1.setNumber(val, 1, &ok);
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_ullong_base_minus){ TEST(PIString_Tests, setNumber_ullong_base_minus){
PIString str1 = " String"; PIString str1 = " String";
const ullong val = 10; const ullong val = 10;
bool ok; bool ok;
str1.setNumber(val, 16, &ok); str1.setNumber(val, 16, &ok);
PIString res = "A"; PIString res = "A";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_float){ TEST(PIString_Tests, setNumber_float){
PIString str1 = " String"; PIString str1 = " String";
const float val = 131.132; const float val = 131.132f;
str1.setNumber(val, 'f', 3); str1.setNumber(val, 'f', 3);
PIString res = "131.132"; PIString res = "131.132";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_double){ TEST(PIString_Tests, setNumber_double){
PIString str1 = " String"; PIString str1 = " String";
const double val = 131.1324334; const double val = 131.1324334;
str1.setNumber(val, 'f', 7); str1.setNumber(val, 'f', 7);
PIString res = "131.1324334"; PIString res = "131.1324334";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setNumber_ldouble){ TEST(DISABLED_PIString_Tests, setNumber_ldouble){
PIString str1 = " String"; PIString str1 = " String";
const ldouble val = 131.1324334; const ldouble val = 131.1324334l;
str1.setNumber(val, 'f', 7); str1.setNumber(val, 'f', 7);
PIString res = "131.1324334"; PIString res = "131.1324334";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, setReadableSize){ TEST(PIString_Tests, setReadableSize){
PIString str1 = " ITELMA"; PIString str1 = " ITELMA";
PIString res = "1023 B"; PIString res = "1023 B";
ASSERT_EQ(res, str1.setReadableSize(1023)); ASSERT_EQ(res, str1.setReadableSize(1023));
} }
TEST(PIString_Tests, setReadableSize_kb){ TEST(PIString_Tests, setReadableSize_kb){
PIString str1 = " ITELMA"; PIString str1 = " ITELMA";
PIString res = "1.0 kB"; PIString res = "1.0 kB";
ASSERT_EQ(res, str1.setReadableSize(1024)); ASSERT_EQ(res, str1.setReadableSize(1024));
} }
TEST(PIString_Tests, setReadableSize_mb){ TEST(PIString_Tests, setReadableSize_mb){
PIString str1 = " ITELMA"; PIString str1 = " ITELMA";
PIString res = "1.0 MB"; PIString res = "1.0 MB";
ASSERT_EQ(res, str1.setReadableSize(1024*1024)); ASSERT_EQ(res, str1.setReadableSize(1024*1024));
} }
TEST(PIString_Tests, setReadableSize_gb){ TEST(PIString_Tests, setReadableSize_gb){
PIString str1 = " ITELMA"; PIString str1 = " ITELMA";
PIString res = "1.0 GB"; PIString res = "1.0 GB";
ASSERT_EQ(res, str1.setReadableSize(1024*1024*1024)); ASSERT_EQ(res, str1.setReadableSize(1024*1024*1024));
} }
TEST(PIString_Tests, setReadableSize_tb){ TEST(PIString_Tests, setReadableSize_tb){
PIString str1 = " ITELMA"; PIString str1 = " ITELMA";
llong val = 99999999999999; llong val = 99999999999999;
PIString res = "90.9 TB"; PIString res = "90.9 TB";
ASSERT_EQ(res, str1.setReadableSize(val)); ASSERT_EQ(res, str1.setReadableSize(val));
} }
TEST(PIString_Tests, setReadableSize_pb){ TEST(PIString_Tests, setReadableSize_pb){
PIString str1 = " ITELMA"; PIString str1 = " ITELMA";
llong val = 999999999999999999; llong val = 999999999999999999;
PIString res = "888.1 PB"; PIString res = "888.1 PB";
ASSERT_EQ(res, str1.setReadableSize(val)); ASSERT_EQ(res, str1.setReadableSize(val));
} }
TEST(PIString_Tests, fromNumber){ TEST(PIString_Tests, fromNumber){
PIString str1 = " String"; PIString str1 = " String";
const short val = 131; const short val = 131;
bool ok; bool ok;
PIString res = "131"; PIString res = "131";
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
} }
TEST(PIString_Tests, fromNumberr_zero){ TEST(PIString_Tests, fromNumberr_zero){
PIString str1 = " String"; PIString str1 = " String";
const short val = 0; const short val = 0;
bool ok; bool ok;
PIString res = "0"; PIString res = "0";
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
} }
TEST(PIString_Tests, fromNumber_false_base){ TEST(PIString_Tests, fromNumber_false_base){
PIString str1 = " String"; PIString str1 = " String";
const short val = 131; const short val = 131;
bool ok; bool ok;
str1.fromNumber(val, 1, &ok); str1.fromNumber(val, 1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, fromNumber_true){ TEST(PIString_Tests, fromNumber_true){
PIString str1 = " String"; PIString str1 = " String";
const short val = 131; const short val = 131;
bool ok; bool ok;
str1.fromNumber(val, 10, &ok); str1.fromNumber(val, 10, &ok);
ASSERT_TRUE(ok); ASSERT_TRUE(ok);
} }
TEST(PIString_Tests, fromNumber_false_base_str){ TEST(PIString_Tests, fromNumber_false_base_str){
PIString str1 = " String"; PIString str1 = " String";
const short val = 131; const short val = 131;
bool ok; bool ok;
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
} }
TEST(PIString_Tests, fromNumber_base_minus){ TEST(PIString_Tests, fromNumber_base_minus){
PIString str1 = " String"; PIString str1 = " String";
const short val = -10; const short val = -10;
bool ok; bool ok;
PIString res = "-A"; PIString res = "-A";
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
} }
TEST(PIString_Tests, fromNumber_ushort){ TEST(PIString_Tests, fromNumber_ushort){
PIString str1 = " String"; PIString str1 = " String";
const ushort val = 131; const ushort val = 131;
bool ok; bool ok;
PIString res = "131"; PIString res = "131";
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
} }
TEST(PIString_Tests, fromNumber_ushort_true){ TEST(PIString_Tests, fromNumber_ushort_true){
PIString str1 = " String"; PIString str1 = " String";
const ushort val = 131; const ushort val = 131;
bool ok; bool ok;
str1.fromNumber(val, 10, &ok); str1.fromNumber(val, 10, &ok);
ASSERT_TRUE(ok); ASSERT_TRUE(ok);
} }
TEST(PIString_Tests, fromNumber_ushort_zero){ TEST(PIString_Tests, fromNumber_ushort_zero){
PIString str1 = " String"; PIString str1 = " String";
const ushort val = 0; const ushort val = 0;
bool ok; bool ok;
PIString res = "0"; PIString res = "0";
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
} }
TEST(PIString_Tests, fromNumber_ushort_false_base){ TEST(PIString_Tests, fromNumber_ushort_false_base){
PIString str1 = " String"; PIString str1 = " String";
const ushort val = 131; const ushort val = 131;
bool ok; bool ok;
str1.fromNumber(val, 1, &ok); str1.fromNumber(val, 1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, fromNumber_ushort_false_base_str){ TEST(PIString_Tests, fromNumber_ushort_false_base_str){
PIString str1 = " String"; PIString str1 = " String";
const ushort val = 131; const ushort val = 131;
bool ok; bool ok;
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
} }
TEST(PIString_Tests, fromNumber_ushort_base_minus){ TEST(PIString_Tests, fromNumber_ushort_base_minus){
PIString str1 = " String"; PIString str1 = " String";
const ushort val = 10; const ushort val = 10;
bool ok; bool ok;
PIString res = "A"; PIString res = "A";
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
} }
TEST(PIString_Tests, fromNumber_int){ TEST(PIString_Tests, fromNumber_int){
PIString str1 = " String"; PIString str1 = " String";
const int val = 131; const int val = 131;
bool ok; bool ok;
PIString res = "131"; PIString res = "131";
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
} }
TEST(PIString_Tests, fromNumber_int_zero){ TEST(PIString_Tests, fromNumber_int_zero){
PIString str1 = " String"; PIString str1 = " String";
const int val = 0; const int val = 0;
bool ok; bool ok;
PIString res = "0"; PIString res = "0";
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
} }
TEST(PIString_Tests, fromNumber_int_false_base){ TEST(PIString_Tests, fromNumber_int_false_base){
PIString str1 = " String"; PIString str1 = " String";
const int val = 131; const int val = 131;
bool ok; bool ok;
str1.fromNumber(val, 1, &ok); str1.fromNumber(val, 1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, fromNumber_int_true){ TEST(PIString_Tests, fromNumber_int_true){
PIString str1 = " String"; PIString str1 = " String";
const int val = 131; const int val = 131;
bool ok; bool ok;
str1.fromNumber(val, 10, &ok); str1.fromNumber(val, 10, &ok);
ASSERT_TRUE(ok); ASSERT_TRUE(ok);
} }
TEST(PIString_Tests, fromNumber_int_false_base_str){ TEST(PIString_Tests, fromNumber_int_false_base_str){
PIString str1 = " String"; PIString str1 = " String";
const int val = 131; const int val = 131;
bool ok; bool ok;
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
} }
TEST(PIString_Tests, fromNumber_int_base_minus){ TEST(PIString_Tests, fromNumber_int_base_minus){
PIString str1 = " String"; PIString str1 = " String";
const int val = -10; const int val = -10;
bool ok; bool ok;
PIString res = "-A"; PIString res = "-A";
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
} }
TEST(PIString_Tests, fromNumber_uint){ TEST(PIString_Tests, fromNumber_uint){
PIString str1 = " String"; PIString str1 = " String";
const uint val = 131; const uint val = 131;
bool ok; bool ok;
PIString res = "131"; PIString res = "131";
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
} }
TEST(PIString_Tests, fromNumber_uint_true){ TEST(PIString_Tests, fromNumber_uint_true){
PIString str1 = " String"; PIString str1 = " String";
const uint val = 131; const uint val = 131;
bool ok; bool ok;
str1.fromNumber(val, 10, &ok); str1.fromNumber(val, 10, &ok);
ASSERT_TRUE(ok); ASSERT_TRUE(ok);
} }
TEST(PIString_Tests, fromNumber_uintt_zero){ TEST(PIString_Tests, fromNumber_uintt_zero){
PIString str1 = " String"; PIString str1 = " String";
const uint val = 0; const uint val = 0;
bool ok; bool ok;
PIString res = "0"; PIString res = "0";
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
} }
TEST(PIString_Tests, fromNumber_uint_false_base){ TEST(PIString_Tests, fromNumber_uint_false_base){
PIString str1 = " String"; PIString str1 = " String";
const uint val = 131; const uint val = 131;
bool ok; bool ok;
str1.fromNumber(val, 1, &ok); str1.fromNumber(val, 1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, fromNumber_uint_false_base_str){ TEST(PIString_Tests, fromNumber_uint_false_base_str){
PIString str1 = " String"; PIString str1 = " String";
const uint val = 131; const uint val = 131;
bool ok; bool ok;
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
} }
TEST(PIString_Tests, fromNumber_uint_base_minus){ TEST(PIString_Tests, fromNumber_uint_base_minus){
PIString str1 = " String"; PIString str1 = " String";
const uint val = 10; const uint val = 10;
bool ok; bool ok;
PIString res = "A"; PIString res = "A";
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
} }
TEST(PIString_Tests, fromNumber_long){ TEST(PIString_Tests, fromNumber_long){
PIString str1 = " String"; PIString str1 = " String";
const long val = 131; const long val = 131;
bool ok; bool ok;
PIString res = "131"; PIString res = "131";
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
} }
TEST(PIString_Tests, fromNumber_long_zero){ TEST(PIString_Tests, fromNumber_long_zero){
PIString str1 = " String"; PIString str1 = " String";
const long val = 0; const long val = 0;
bool ok; bool ok;
PIString res = "0"; PIString res = "0";
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
} }
TEST(PIString_Tests, fromNumber_long_false_base){ TEST(PIString_Tests, fromNumber_long_false_base){
PIString str1 = " String"; PIString str1 = " String";
const long val = 131; const long val = 131;
bool ok; bool ok;
str1.fromNumber(val, 1, &ok); str1.fromNumber(val, 1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, fromNumber_long_true){ TEST(PIString_Tests, fromNumber_long_true){
PIString str1 = " String"; PIString str1 = " String";
const long val = 131; const long val = 131;
bool ok; bool ok;
str1.fromNumber(val, 10, &ok); str1.fromNumber(val, 10, &ok);
ASSERT_TRUE(ok); ASSERT_TRUE(ok);
} }
TEST(PIString_Tests, fromNumber_long_false_base_str){ TEST(PIString_Tests, fromNumber_long_false_base_str){
PIString str1 = " String"; PIString str1 = " String";
const long val = 131; const long val = 131;
bool ok; bool ok;
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
} }
TEST(PIString_Tests, fromNumber_long_base_minus){ TEST(PIString_Tests, fromNumber_long_base_minus){
PIString str1 = " String"; PIString str1 = " String";
const long val = -10; const long val = -10;
bool ok; bool ok;
PIString res = "-A"; PIString res = "-A";
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
} }
TEST(PIString_Tests, fromNumber_ulong){ TEST(PIString_Tests, fromNumber_ulong){
PIString str1 = " String"; PIString str1 = " String";
const ulong val = 131; const ulong val = 131;
bool ok; bool ok;
PIString res = "131"; PIString res = "131";
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
} }
TEST(PIString_Tests, fromNumber_ulong_true){ TEST(PIString_Tests, fromNumber_ulong_true){
PIString str1 = " String"; PIString str1 = " String";
const ulong val = 131; const ulong val = 131;
bool ok; bool ok;
str1.fromNumber(val, 10, &ok); str1.fromNumber(val, 10, &ok);
ASSERT_TRUE(ok); ASSERT_TRUE(ok);
} }
TEST(PIString_Tests, fromNumber_ulong_zero){ TEST(PIString_Tests, fromNumber_ulong_zero){
PIString str1 = " String"; PIString str1 = " String";
const ulong val = 0; const ulong val = 0;
bool ok; bool ok;
PIString res = "0"; PIString res = "0";
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
} }
TEST(PIString_Tests, fromNumber_ulong_false_base){ TEST(PIString_Tests, fromNumber_ulong_false_base){
PIString str1 = " String"; PIString str1 = " String";
const ulong val = 131; const ulong val = 131;
bool ok; bool ok;
str1.fromNumber(val, 1, &ok); str1.fromNumber(val, 1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, fromNumber_ulong_false_base_str){ TEST(PIString_Tests, fromNumber_ulong_false_base_str){
PIString str1 = " String"; PIString str1 = " String";
const ulong val = 131; const ulong val = 131;
bool ok; bool ok;
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
} }
TEST(PIString_Tests, fromNumber_ulong_base_minus){ TEST(PIString_Tests, fromNumber_ulong_base_minus){
PIString str1 = " String"; PIString str1 = " String";
const ulong val = 10; const ulong val = 10;
bool ok; bool ok;
PIString res = "A"; PIString res = "A";
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
} }
TEST(PIString_Tests, fromNumber_llong){ TEST(PIString_Tests, fromNumber_llong){
PIString str1 = " String"; PIString str1 = " String";
const llong val = 131; const llong val = 131;
bool ok; bool ok;
PIString res = "131"; PIString res = "131";
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
} }
TEST(PIString_Tests, fromNumber_llong_zero){ TEST(PIString_Tests, fromNumber_llong_zero){
PIString str1 = " String"; PIString str1 = " String";
const llong val = 0; const llong val = 0;
bool ok; bool ok;
PIString res = "0"; PIString res = "0";
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
} }
TEST(PIString_Tests, fromNumber_llong_false_base){ TEST(PIString_Tests, fromNumber_llong_false_base){
PIString str1 = " String"; PIString str1 = " String";
const llong val = 131; const llong val = 131;
bool ok; bool ok;
str1.fromNumber(val, 1, &ok); str1.fromNumber(val, 1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, fromNumber_llong_true){ TEST(PIString_Tests, fromNumber_llong_true){
PIString str1 = " String"; PIString str1 = " String";
const llong val = 131; const llong val = 131;
bool ok; bool ok;
str1.fromNumber(val, 10, &ok); str1.fromNumber(val, 10, &ok);
ASSERT_TRUE(ok); ASSERT_TRUE(ok);
} }
TEST(PIString_Tests, fromNumber_llong_false_base_str){ TEST(PIString_Tests, fromNumber_llong_false_base_str){
PIString str1 = " String"; PIString str1 = " String";
const llong val = 131; const llong val = 131;
bool ok; bool ok;
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
} }
TEST(PIString_Tests, fromNumber_llong_base_minus){ TEST(PIString_Tests, fromNumber_llong_base_minus){
PIString str1 = " String"; PIString str1 = " String";
const llong val = -10; const llong val = -10;
bool ok; bool ok;
PIString res = "-A"; PIString res = "-A";
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
} }
TEST(PIString_Tests, fromNumber_ullong){ TEST(PIString_Tests, fromNumber_ullong){
PIString str1 = " String"; PIString str1 = " String";
const ullong val = 131; const ullong val = 131;
bool ok; bool ok;
PIString res = "131"; PIString res = "131";
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
} }
TEST(PIString_Tests, fromNumber_ullong_true){ TEST(PIString_Tests, fromNumber_ullong_true){
PIString str1 = " String"; PIString str1 = " String";
const ullong val = 131; const ullong val = 131;
bool ok; bool ok;
str1.fromNumber(val, 10, &ok); str1.fromNumber(val, 10, &ok);
ASSERT_TRUE(ok); ASSERT_TRUE(ok);
} }
TEST(PIString_Tests, fromNumber_ullong_zero){ TEST(PIString_Tests, fromNumber_ullong_zero){
PIString str1 = " String"; PIString str1 = " String";
const ullong val = 0; const ullong val = 0;
bool ok; bool ok;
PIString res = "0"; PIString res = "0";
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
} }
TEST(PIString_Tests, fromNumber_ullong_false_base){ TEST(PIString_Tests, fromNumber_ullong_false_base){
PIString str1 = " String"; PIString str1 = " String";
const ullong val = 131; const ullong val = 131;
bool ok; bool ok;
str1.fromNumber(val, 1, &ok); str1.fromNumber(val, 1, &ok);
ASSERT_FALSE(ok); ASSERT_FALSE(ok);
} }
TEST(PIString_Tests, fromNumber_ullong_false_base_str){ TEST(PIString_Tests, fromNumber_ullong_false_base_str){
PIString str1 = " String"; PIString str1 = " String";
const ullong val = 131; const ullong val = 131;
bool ok; bool ok;
PIString res = ""; PIString res = "";
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
} }
TEST(PIString_Tests, fromNumber_ullong_base_minus){ TEST(PIString_Tests, fromNumber_ullong_base_minus){
PIString str1 = " String"; PIString str1 = " String";
const ullong val = 10; const ullong val = 10;
bool ok; bool ok;
PIString res = "A"; PIString res = "A";
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok)); ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
} }
TEST(PIString_Tests, fromNumber_float){ TEST(PIString_Tests, fromNumber_float){
PIString str1 = " String"; PIString str1 = " String";
const float val = 131.132; const float val = 131.132f;
PIString res = "131.132"; PIString res = "131.132";
ASSERT_EQ(res, str1.fromNumber(val, 'f', 3)); ASSERT_EQ(res, str1.fromNumber(val, 'f', 3));
} }
TEST(PIString_Tests, fromNumber_double){ TEST(PIString_Tests, fromNumber_double){
PIString str1 = " String"; PIString str1 = " String";
const double val = 131.1324334; const double val = 131.1324334;
PIString res = "131.1324334"; PIString res = "131.1324334";
ASSERT_EQ(res, str1.fromNumber(val, 'f', 7)); ASSERT_EQ(res, str1.fromNumber(val, 'f', 7));
} }
TEST(PIString_Tests, fromNumber_ldouble){ TEST(PIString_Tests, fromNumber_ldouble){
PIString str1 = " String"; PIString str1 = " String";
const ldouble val = 131.1324334; const ldouble val = 131.1324334l;
PIString res = "131.1324334"; PIString res = "131.1324334";
ASSERT_EQ(res, str1.fromNumber(val, 'f', 7)); ASSERT_EQ(res, str1.fromNumber(val, 'f', 7));
} }
TEST(PIString_Tests, fromBool_true){ TEST(PIString_Tests, fromBool_true){
PIString str1; PIString str1;
bool val = true; bool val = true;
PIString res = "true"; PIString res = "true";
ASSERT_EQ(res, str1.fromBool(val)); ASSERT_EQ(res, str1.fromBool(val));
} }
TEST(PIString_Tests, fromBool_false){ TEST(PIString_Tests, fromBool_false){
PIString str1; PIString str1;
bool val = false; bool val = false;
PIString res = "false"; PIString res = "false";
ASSERT_EQ(res, str1.fromBool(val)); ASSERT_EQ(res, str1.fromBool(val));
} }
TEST(PIString_Tests, from_Console){ TEST(PIString_Tests, from_Console){
PIString str1; PIString str1;
char s[] = "true boy"; char s[] = "true boy";
PIString res = "true boy"; PIString res = "true boy";
ASSERT_EQ(res, str1.fromConsole(s)); ASSERT_EQ(res, str1.fromConsole(s));
} }
TEST(PIString_Tests, from_System){ TEST(PIString_Tests, from_System){
PIString str1; PIString str1;
char s[] = "true boy"; char s[] = "true boy";
PIString res = "true boy"; PIString res = "true boy";
ASSERT_EQ(res, str1.fromSystem(s)); ASSERT_EQ(res, str1.fromSystem(s));
} }
TEST(PIString_Tests, from_UTF8){ TEST(PIString_Tests, from_UTF8){
PIString str1; PIString str1;
char s[] = "true boy"; char s[] = "true boy";
PIString res = "true boy"; PIString res = "true boy";
ASSERT_EQ(res, str1.fromUTF8(s)); ASSERT_EQ(res, str1.fromUTF8(s));
} }
TEST(PIString_Tests, from_UTF8_ba){ TEST(PIString_Tests, from_UTF8_ba){
PIString str1; PIString str1;
PIByteArray s; PIByteArray s;
s.append('t'); s.append('t');
s.append('r'); s.append('r');
s.append('u'); s.append('u');
s.append('e'); s.append('e');
PIString res = "true"; PIString res = "true";
ASSERT_EQ(res, str1.fromUTF8(s)); ASSERT_EQ(res, str1.fromUTF8(s));
} }
TEST(PIString_Tests, from_Ascii){ TEST(PIString_Tests, from_Ascii){
PIString str1; PIString str1;
char s[] = "true boy"; char s[] = "true boy";
PIString res = "true boy"; PIString res = "true boy";
ASSERT_EQ(res, str1.fromAscii(s)); ASSERT_EQ(res, str1.fromAscii(s));
} }
TEST(PIString_Tests, from_Codepage){ TEST(PIString_Tests, from_Codepage){
PIString str1 = "Nul"; PIString str1 = "Nul";
char s[] = "true"; char s[] = "true";
char c[] = "utf8"; char c[] = "utf8";
PIString str2 = str1.fromCodepage(s, c); PIString str2 = str1.fromCodepage(s, c);
PIString res = "true"; PIString res = "true";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, ReadableSize){ TEST(PIString_Tests, ReadableSize){
PIString str1 = " ITELMA"; PIString str1 = " ITELMA";
PIString res = "1023 B"; PIString res = "1023 B";
ASSERT_EQ(res, str1.readableSize(1023)); ASSERT_EQ(res, str1.readableSize(1023));
} }
TEST(PIString_Tests, readableSize_kb){ TEST(PIString_Tests, readableSize_kb){
PIString str1 = " ITELMA"; PIString str1 = " ITELMA";
PIString res = "1.0 kB"; PIString res = "1.0 kB";
ASSERT_EQ(res, str1.readableSize(1024)); ASSERT_EQ(res, str1.readableSize(1024));
} }
TEST(PIString_Tests, readableSize_mb){ TEST(PIString_Tests, readableSize_mb){
PIString str1 = " ITELMA"; PIString str1 = " ITELMA";
PIString res = "1.0 MB"; PIString res = "1.0 MB";
ASSERT_EQ(res, str1.readableSize(1024*1024)); ASSERT_EQ(res, str1.readableSize(1024*1024));
} }
TEST(PIString_Tests, readableSize_gb){ TEST(PIString_Tests, readableSize_gb){
PIString str1 = " ITELMA"; PIString str1 = " ITELMA";
PIString res = "1.0 GB"; PIString res = "1.0 GB";
ASSERT_EQ(res, str1.readableSize(1024*1024*1024)); ASSERT_EQ(res, str1.readableSize(1024*1024*1024));
} }
TEST(PIString_Tests, readableSize_tb){ TEST(PIString_Tests, readableSize_tb){
PIString str1 = " ITELMA"; PIString str1 = " ITELMA";
llong val = 99999999999999; llong val = 99999999999999;
PIString res = "90.9 TB"; PIString res = "90.9 TB";
ASSERT_EQ(res, str1.readableSize(val)); ASSERT_EQ(res, str1.readableSize(val));
} }
TEST(PIString_Tests, readableSize_pb){ TEST(PIString_Tests, readableSize_pb){
PIString str1 = " ITELMA"; PIString str1 = " ITELMA";
llong val = 999999999999999999; llong val = 999999999999999999;
PIString res = "888.1 PB"; PIString res = "888.1 PB";
ASSERT_EQ(res, str1.readableSize(val)); ASSERT_EQ(res, str1.readableSize(val));
} }
TEST(PIString_Tests, removeAll_char){ TEST(PIString_Tests, removeAll_char){
PIString str1 = "A very strong programmer wrote this code"; PIString str1 = "A very strong programmer wrote this code";
char v = ' '; char v = ' ';
PIString res = "Averystrongprogrammerwrotethiscode"; PIString res = "Averystrongprogrammerwrotethiscode";
ASSERT_EQ(res, str1.removeAll(v)); ASSERT_EQ(res, str1.removeAll(v));
} }
TEST(PIString_Tests, removeAll_pistring){ TEST(PIString_Tests, removeAll_pistring){
PIString str1 = "A very strong programmer wrote this code"; PIString str1 = "A very strong programmer wrote this code";
PIString v = "very strong "; PIString v = "very strong ";
PIString res = "A programmer wrote this code"; PIString res = "A programmer wrote this code";
ASSERT_EQ(res, str1.removeAll(v)); ASSERT_EQ(res, str1.removeAll(v));
} }
TEST(PIString_Tests, operator_ba_pstr){ TEST(PIString_Tests, operator_ba_pstr){
PIString str1 = '1'; PIString str1 = '1';
PIByteArray s; PIByteArray s;
s << str1; s << str1;
PIString res = "010000003100"; PIString res = "010000003100";
ASSERT_EQ(res, s.toHex()); ASSERT_EQ(res, s.toHex());
} }
TEST(PIString_Tests, operator_pstr_ba){ TEST(PIString_Tests, operator_pstr_ba){
PIString str1 = "1"; PIString str1 = "1";
PIByteArray s; PIByteArray s;
s.append('t'); s.append('t');
s.append('r'); s.append('r');
s.append('u'); s.append('u');
s.append('e'); s.append('e');
str1 << s; str1 << s;
PIString res = "1true"; PIString res = "1true";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }
TEST(PIString_Tests, operator_plus_pstr_pstr){ TEST(PIString_Tests, operator_plus_pstr_pstr){
PIString str1 = "first "; PIString str1 = "first ";
PIString str2 = "second"; PIString str2 = "second";
PIString res = "first second"; PIString res = "first second";
ASSERT_EQ(res, str1 + str2); ASSERT_EQ(res, str1 + str2);
} }
TEST(PIString_Tests, operator_plus_pstr_chars){ TEST(PIString_Tests, operator_plus_pstr_chars){
PIString str1 = "first "; PIString str1 = "first ";
char str2[] = "second"; char str2[] = "second";
PIString res = "first second"; PIString res = "first second";
ASSERT_EQ(res, str1 + str2); ASSERT_EQ(res, str1 + str2);
} }
TEST(PIString_Tests, operator_plus_chars_pstr){ TEST(PIString_Tests, operator_plus_chars_pstr){
PIString str1 = "first"; PIString str1 = "first";
char str2[] = "second "; char str2[] = "second ";
PIString res = "second first"; PIString res = "second first";
ASSERT_EQ(res, str2 + str1); ASSERT_EQ(res, str2 + str1);
} }
TEST(PIString_Tests, version_Compare){ TEST(PIString_Tests, version_Compare){
ASSERT_EQ(-1, versionCompare("1.0.0_rc2-999", "1.0.1_rc2-999")); ASSERT_EQ(-1, versionCompare("1.0.0_rc2-999", "1.0.1_rc2-999"));
} }
TEST(PIString_Tests, version_Compare_eq){ TEST(PIString_Tests, version_Compare_eq){
ASSERT_EQ(0, versionCompare(".2-alpha", "0.2_alpha")); ASSERT_EQ(NULL, versionCompare(".2-alpha", "0.2_alpha"));
} }
TEST(PIString_Tests, version_Compare_more){ TEST(PIString_Tests, version_Compare_more){
ASSERT_EQ(1, versionCompare("1.0.0", "0.9.2")); ASSERT_EQ(1, versionCompare("1.0.0", "0.9.2"));
} }
TEST(PIString_Tests, version_Compare_component){ TEST(PIString_Tests, version_Compare_component){
ASSERT_EQ(0, versionCompare("1.0.0_r1", "1.0.0", 3)); ASSERT_EQ(NULL, versionCompare("1.0.0_r1", "1.0.0", 3));
} }
TEST(PIString_Tests, version_Normalize){ TEST(PIString_Tests, version_Normalize){
PIString str1 = "first second"; PIString str1 = "first second";
PIString res = "0.0_first second"; PIString res = "0.0_first second";
ASSERT_EQ(res, versionNormalize(str1)); ASSERT_EQ(res, versionNormalize(str1));
} }
TEST(PIString_Tests, pi_Hash){ TEST(PIString_Tests, pi_Hash){
PIString str1 = "first"; PIString str1 = "first";
ASSERT_EQ(898448032, piHash(str1)); ASSERT_EQ(898448032, piHash(str1));
} }
TEST(PIString_Tests, pi_Swap){ TEST(PIString_Tests, pi_Swap){
PIString str1 = "first"; PIString str1 = "first";
PIString str2 = "second"; PIString str2 = "second";
piSwap(str1, str2); piSwap(str1, str2);
PIString res = "first"; PIString res = "first";
ASSERT_EQ(res, str2); ASSERT_EQ(res, str2);
} }
TEST(PIString_Tests, piSwap_sec){ TEST(PIString_Tests, piSwap_sec){
PIString str1 = "first"; PIString str1 = "first";
PIString str2 = "second"; PIString str2 = "second";
piSwap(str1, str2); piSwap(str1, str2);
PIString res = "second"; PIString res = "second";
ASSERT_EQ(res, str1); ASSERT_EQ(res, str1);
} }