error correction
This commit is contained in:
@@ -4,555 +4,592 @@
|
||||
using namespace std;
|
||||
|
||||
TEST(PIStringList_Tests, construct_empty){
|
||||
PIStringList lis;
|
||||
ASSERT_TRUE(lis.isEmpty());
|
||||
PIStringList lis;
|
||||
ASSERT_TRUE(lis.isEmpty());
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, construct_one_str_size){
|
||||
PIString str1 = "first string";
|
||||
PIStringList lis {str1};
|
||||
ASSERT_EQ(lis.length(),1);
|
||||
TEST(PIStringList_Tests, construct_one_str_length){
|
||||
PIString str1 = "first string";
|
||||
PIStringList lis (str1);
|
||||
ASSERT_EQ(lis.length(),1);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, construct_one_str_data){
|
||||
PIString str1 = "first string";
|
||||
PIStringList lis {str1};
|
||||
ASSERT_EQ(str1, lis[0]);
|
||||
PIString str1 = "first string";
|
||||
PIStringList lis (str1);
|
||||
ASSERT_EQ(str1, lis[0]);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, construct_one_str_rvalue_size){
|
||||
PIString str1 = "first string";
|
||||
PIStringList lis {"first string"};
|
||||
ASSERT_EQ(lis.length(), 1);
|
||||
TEST(PIStringList_Tests, construct_one_str_move_length){
|
||||
PIString str1 = "first string";
|
||||
PIStringList lis (move(str1));
|
||||
ASSERT_EQ(lis.length(), 1);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, construct_one_str_rvalue_data){
|
||||
PIString str1 = "first string";
|
||||
PIStringList lis {"first string"};
|
||||
ASSERT_EQ(str1, lis[0]);
|
||||
TEST(PIStringList_Tests, construct_one_str_move_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str = str1;
|
||||
PIStringList lis (move(str));
|
||||
ASSERT_EQ(str1, lis[0]);
|
||||
}
|
||||
TEST(PIStringList_Tests, construct_two_str_size){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIStringList lis {str1, str2};
|
||||
ASSERT_EQ(lis.length(), 2);
|
||||
TEST(PIStringList_Tests, construct_two_str_length){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIStringList lis (str1, str2);
|
||||
ASSERT_EQ(lis.length(), 2);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, construct_two_str_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIStringList lis {str1, str2};
|
||||
ASSERT_EQ(str1, lis[0]);
|
||||
ASSERT_EQ(str2, lis[1]);
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIStringList lis (str1, str2);
|
||||
ASSERT_EQ(str1, lis[0]);
|
||||
ASSERT_EQ(str2, lis[1]);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, construct_two_str_rvalue_size){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIStringList lis {"first string", "second string"};
|
||||
ASSERT_EQ(lis.length(), 2);
|
||||
TEST(PIStringList_Tests, construct_two_str_move_length){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIStringList lis (move(str1), move(str2));
|
||||
ASSERT_EQ(lis.length(), 2);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, construct_two_str_rvalue_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIStringList lis {"first string", "second string"};
|
||||
ASSERT_EQ(str1, lis[0]);
|
||||
ASSERT_EQ(lis[1], str2);
|
||||
TEST(PIStringList_Tests, construct_two_str_move_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str1_res = str1;
|
||||
PIString str2_res = 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){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIStringList lis {str1, str2, str3};
|
||||
ASSERT_EQ(lis.length(),3);
|
||||
TEST(PIStringList_Tests, construct_three_str_length){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIStringList lis (str1, str2, str3);
|
||||
ASSERT_EQ(lis.length(),3);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, construct_three_str_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIStringList lis {str1, str2, str3};
|
||||
ASSERT_EQ(lis[0], str1);
|
||||
ASSERT_EQ(lis[1], str2);
|
||||
ASSERT_EQ(lis[2], str3);
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIStringList lis (str1, str2, str3);
|
||||
ASSERT_EQ(lis[0], str1);
|
||||
ASSERT_EQ(lis[1], str2);
|
||||
ASSERT_EQ(lis[2], str3);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, construct_three_str_rvalue_size){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIStringList lis {"first string", "second string", "third string"};
|
||||
ASSERT_EQ(lis.length(), 3);
|
||||
TEST(PIStringList_Tests, construct_three_str_move_length){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIStringList lis (move(str1), move(str2), move(str3));
|
||||
ASSERT_EQ(lis.length(), 3);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, construct_three_str_rvalue_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIStringList lis {"first string", "second string", "third string"};
|
||||
ASSERT_EQ(lis[0], str1);
|
||||
ASSERT_EQ(lis[1], str2);
|
||||
ASSERT_EQ(lis[2], str3);
|
||||
TEST(PIStringList_Tests, construct_three_str_move_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str1_res = str1;
|
||||
PIString str2_res = str2;
|
||||
PIString str3_res = 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){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
ASSERT_EQ(lis.length(), 4);
|
||||
TEST(PIStringList_Tests, construct_four_str_length){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis (str1, str2, str3, str4);
|
||||
ASSERT_EQ(lis.length(), 4);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, construct_four_str_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
ASSERT_EQ(lis[0], str1);
|
||||
ASSERT_EQ(lis[1], str2);
|
||||
ASSERT_EQ(lis[2], str3);
|
||||
ASSERT_EQ(lis[3], str4);
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis (str1, str2, str3, str4);
|
||||
ASSERT_EQ(lis[0], str1);
|
||||
ASSERT_EQ(lis[1], str2);
|
||||
ASSERT_EQ(lis[2], str3);
|
||||
ASSERT_EQ(lis[3], str4);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, construct_four_str_rvalue_size){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {"first string", "second string", "third string", "fourth string"};
|
||||
ASSERT_EQ(lis.length(), 4);
|
||||
TEST(PIStringList_Tests, construct_four_str_move_length){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis (move(str1), move(str2), move(str3), move(str4));
|
||||
ASSERT_EQ(lis.length(), 4);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, construct_four_str_rvalue){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {"first string", "second string", "third string", "fourth string"};
|
||||
ASSERT_EQ(lis[0], str1);
|
||||
ASSERT_EQ(lis[1], str2);
|
||||
ASSERT_EQ(lis[2], str3);
|
||||
ASSERT_EQ(lis[3], str4);
|
||||
TEST(PIStringList_Tests, construct_four_str_move_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 (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){
|
||||
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_std_initializer_list_length){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {"first string", "second string", "third string", "fourth string", "fourth string"};
|
||||
ASSERT_EQ(lis.length(), 5);
|
||||
}
|
||||
|
||||
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){
|
||||
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[0], str1);
|
||||
ASSERT_EQ(list[1], str2);
|
||||
ASSERT_EQ(list[2], str3);
|
||||
ASSERT_EQ(list[3], str4);
|
||||
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[0], str1);
|
||||
ASSERT_EQ(list[1], str2);
|
||||
ASSERT_EQ(list[2], str3);
|
||||
ASSERT_EQ(list[3], str4);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, construct_list_rvalue_size){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {"first string", "second string", "third string", "fourth string"};
|
||||
PIStringList list {move(lis)};
|
||||
ASSERT_EQ(list.length(), 4);
|
||||
TEST(PIStringList_Tests, construct_list_move_length){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {"first string", "second string", "third string", "fourth string"};
|
||||
PIStringList list (move(lis));
|
||||
ASSERT_EQ(list.length(), 4);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, construct_list_rvalue_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {"first string", "second string", "third string", "fourth string"};
|
||||
PIStringList list {move(lis)};
|
||||
ASSERT_EQ(list[0], str1);
|
||||
ASSERT_EQ(list[1], str2);
|
||||
ASSERT_EQ(list[2], str3);
|
||||
ASSERT_EQ(list[3], str4);
|
||||
TEST(PIStringList_Tests, construct_list_move_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {"first string", "second string", "third string", "fourth string"};
|
||||
PIStringList list (move(lis));
|
||||
ASSERT_EQ(list[0], str1);
|
||||
ASSERT_EQ(list[1], str2);
|
||||
ASSERT_EQ(list[2], str3);
|
||||
ASSERT_EQ(list[3], str4);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, construct_pivect_size){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIVector<PIString> vect;
|
||||
vect.append(str1);
|
||||
vect.append(str2);
|
||||
vect.append(str3);
|
||||
vect.append(str4);
|
||||
PIStringList list {vect};
|
||||
ASSERT_EQ(list.length(), 4);
|
||||
TEST(PIStringList_Tests, construct_pivect_length){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIVector<PIString> vect;
|
||||
vect.append(str1);
|
||||
vect.append(str2);
|
||||
vect.append(str3);
|
||||
vect.append(str4);
|
||||
PIStringList list (vect);
|
||||
ASSERT_EQ(list.length(), 4);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, construct_pivect_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIVector<PIString> vect;
|
||||
vect.append(str1);
|
||||
vect.append(str2);
|
||||
vect.append(str3);
|
||||
vect.append(str4);
|
||||
PIStringList list {vect};
|
||||
ASSERT_EQ(list[0], str1);
|
||||
ASSERT_EQ(list[1], str2);
|
||||
ASSERT_EQ(list[2], str3);
|
||||
ASSERT_EQ(list[3], str4);
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIVector<PIString> vect;
|
||||
vect.append(str1);
|
||||
vect.append(str2);
|
||||
vect.append(str3);
|
||||
vect.append(str4);
|
||||
PIStringList list (vect);
|
||||
ASSERT_EQ(list[0], str1);
|
||||
ASSERT_EQ(list[1], str2);
|
||||
ASSERT_EQ(list[2], str3);
|
||||
ASSERT_EQ(list[3], str4);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, construct_list_pideq_size){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIDeque<PIString> deq;
|
||||
deq.append(str1);
|
||||
deq.append(str2);
|
||||
deq.append(str3);
|
||||
deq.append(str4);
|
||||
PIStringList list {deq};
|
||||
ASSERT_EQ(list.length(), 4);
|
||||
TEST(PIStringList_Tests, construct_list_pideq_length){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIDeque<PIString> deq;
|
||||
deq.append(str1);
|
||||
deq.append(str2);
|
||||
deq.append(str3);
|
||||
deq.append(str4);
|
||||
PIStringList list (deq);
|
||||
ASSERT_EQ(list.length(), 4);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, construct_list_pideq_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIDeque<PIString> deq;
|
||||
deq.append(str1);
|
||||
deq.append(str2);
|
||||
deq.append(str3);
|
||||
deq.append(str4);
|
||||
PIStringList list {deq};
|
||||
ASSERT_EQ(list[0], str1);
|
||||
ASSERT_EQ(list[1], str2);
|
||||
ASSERT_EQ(list[2], str3);
|
||||
ASSERT_EQ(list[3], str4);
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIDeque<PIString> deq;
|
||||
deq.append(str1);
|
||||
deq.append(str2);
|
||||
deq.append(str3);
|
||||
deq.append(str4);
|
||||
PIStringList list (deq);
|
||||
ASSERT_EQ(list[0], str1);
|
||||
ASSERT_EQ(list[1], str2);
|
||||
ASSERT_EQ(list[2], str3);
|
||||
ASSERT_EQ(list[3], str4);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, join){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIString del = ", ";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
ASSERT_EQ(lis.join(del), "first string, second string, third string, fourth string");
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIString del = ", ";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
ASSERT_EQ(lis.join(del), "first string, second string, third string, fourth string");
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, remove_strings_size){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "string";
|
||||
PIString val = "string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.removeStrings(val);
|
||||
ASSERT_EQ(lis.length(), 2);
|
||||
TEST(PIStringList_Tests, remove_strings_length){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "string";
|
||||
PIString val = "string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.removeStrings(val);
|
||||
ASSERT_EQ(lis.length(), 2);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, remove_strings_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "string";
|
||||
PIString val = "string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.removeStrings(val);
|
||||
ASSERT_EQ(lis[0], "first string");
|
||||
ASSERT_EQ(lis[1], "third string");
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "string";
|
||||
PIString val = "string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.removeStrings(val);
|
||||
ASSERT_EQ(lis[0], "first string");
|
||||
ASSERT_EQ(lis[1], "third string");
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, remove_size){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.remove(2);
|
||||
ASSERT_EQ(lis.length(), 3);
|
||||
TEST(PIStringList_Tests, remove_length){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.remove(2);
|
||||
ASSERT_EQ(lis.length(), 3);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, remove_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.remove(2);
|
||||
ASSERT_EQ(lis[0], "first string");
|
||||
ASSERT_EQ(lis[1], "second string");
|
||||
ASSERT_EQ(lis[2], "fourth string");
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.remove(2);
|
||||
ASSERT_EQ(lis[0], "first string");
|
||||
ASSERT_EQ(lis[1], "second string");
|
||||
ASSERT_EQ(lis[2], "fourth string");
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, remove_count_size){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.remove(2,2);
|
||||
ASSERT_EQ(lis.length(), 2);
|
||||
TEST(PIStringList_Tests, remove_count_length){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.remove(2,2);
|
||||
ASSERT_EQ(lis.length(), 2);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, remove_count_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.remove(2,2);
|
||||
ASSERT_EQ(lis[0], "first string");
|
||||
ASSERT_EQ(lis[1], "second string");
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.remove(2,2);
|
||||
ASSERT_EQ(lis[0], "first string");
|
||||
ASSERT_EQ(lis[1], "second string");
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, remove_Duplicates_size){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "first string";
|
||||
PIString str4 = "second string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.removeDuplicates();
|
||||
ASSERT_EQ(lis.length(), 2);
|
||||
TEST(PIStringList_Tests, remove_Duplicates_length){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "first string";
|
||||
PIString str4 = "second string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.removeDuplicates();
|
||||
ASSERT_EQ(lis.length(), 2);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, remove_Duplicates_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "first string";
|
||||
PIString str4 = "second string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.removeDuplicates();
|
||||
ASSERT_EQ(lis[0], "first string");
|
||||
ASSERT_EQ(lis[1], "second string");
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "first string";
|
||||
PIString str4 = "second string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.removeDuplicates();
|
||||
ASSERT_EQ(lis[0], "first string");
|
||||
ASSERT_EQ(lis[1], "second string");
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, trim_size){
|
||||
PIString str1 = " first string ";
|
||||
PIString str2 = "second string ";
|
||||
PIString str3 = " third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.trim();
|
||||
ASSERT_EQ(lis.length(), 4);
|
||||
TEST(PIStringList_Tests, trim_length){
|
||||
PIString str1 = " first string ";
|
||||
PIString str2 = "second string ";
|
||||
PIString str3 = " third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.trim();
|
||||
ASSERT_EQ(lis.length(), 4);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, trim_data){
|
||||
PIString str1 = " first string ";
|
||||
PIString str2 = "second string ";
|
||||
PIString str3 = " third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.trim();
|
||||
ASSERT_EQ(lis[0], "first string");
|
||||
ASSERT_EQ(lis[1], "second string");
|
||||
ASSERT_EQ(lis[2], "third string");
|
||||
ASSERT_EQ(lis[3], "fourth string");
|
||||
PIString str1 = " first string ";
|
||||
PIString str2 = "second string ";
|
||||
PIString str3 = " third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
lis.trim();
|
||||
ASSERT_EQ(lis[0], "first string");
|
||||
ASSERT_EQ(lis[1], "second string");
|
||||
ASSERT_EQ(lis[2], "third string");
|
||||
ASSERT_EQ(lis[3], "fourth string");
|
||||
}
|
||||
TEST(PIStringList_Tests, content_size){
|
||||
PIString str1 = " first string ";
|
||||
PIString str2 = "second string ";
|
||||
PIString str3 = " third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
ASSERT_EQ(lis.contentSize(), 54);
|
||||
PIString str1 = " first string ";
|
||||
PIString str2 = "second string ";
|
||||
PIString str3 = " third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
ASSERT_EQ(lis.contentSize(), 54);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, operator_compare){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
PIStringList lis1 {"first string", "second string", "third string", "fourth string"};
|
||||
ASSERT_TRUE(lis == lis1);
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
PIStringList lis1 {"first string", "second string", "third string", "fourth string"};
|
||||
ASSERT_TRUE(lis == lis1);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, operator_compare_false){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
PIStringList lis1 {"first string", "second string", "third string", "fourth string"};
|
||||
ASSERT_FALSE(lis == lis1);
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
PIStringList lis1 {"first string", "second string", "third string", "fourth string"};
|
||||
ASSERT_FALSE(lis == lis1);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, operator_compare_size){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3};
|
||||
PIStringList lis1 {"first string", "second string", "third string", "fourth string"};
|
||||
ASSERT_FALSE(lis == lis1);
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3};
|
||||
PIStringList lis1 {"first string", "second string", "third string", "fourth string"};
|
||||
ASSERT_FALSE(lis == lis1);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, operator_compare_unequal
|
||||
|
||||
){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
PIStringList lis1 {"first string", "second string", "third string", "fourth string"};
|
||||
ASSERT_FALSE(lis != lis1);
|
||||
TEST(PIStringList_Tests, operator_compare_unequal){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
PIStringList lis1 {"first string", "second string", "third string", "fourth string"};
|
||||
ASSERT_FALSE(lis != lis1);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, operator_compare_unequal_false){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
PIStringList lis1 {"first string", "second string", "third string", "fourth string"};
|
||||
ASSERT_TRUE(lis != lis1);
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
PIStringList lis1 {"first string", "second string", "third string", "fourth string"};
|
||||
ASSERT_TRUE(lis != lis1);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, operator_compare_unequal_size){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3};
|
||||
PIStringList lis1 {"first string", "second string", "third string", "fourth string"};
|
||||
ASSERT_TRUE(lis != lis1);
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "third string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3};
|
||||
PIStringList lis1 {"first string", "second string", "third string", "fourth string"};
|
||||
ASSERT_TRUE(lis != lis1);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, operator_assignment_size){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
PIStringList lis1 = lis;
|
||||
ASSERT_EQ(lis1.length(), 4);
|
||||
TEST(PIStringList_Tests, operator_assignment_length){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
PIStringList lis1;
|
||||
lis1 = lis;
|
||||
ASSERT_EQ(lis1.length(), 4);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, operator_assignment_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
PIStringList lis1 = lis;
|
||||
ASSERT_EQ(lis1[0], str1);
|
||||
ASSERT_EQ(lis1[1], str2);
|
||||
ASSERT_EQ(lis1[2], str3);
|
||||
ASSERT_EQ(lis1[3], str4);
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3, str4};
|
||||
PIStringList lis1;
|
||||
lis1 = lis;
|
||||
ASSERT_EQ(lis1[0], str1);
|
||||
ASSERT_EQ(lis1[1], str2);
|
||||
ASSERT_EQ(lis1[2], str3);
|
||||
ASSERT_EQ(lis1[3], str4);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, operator_shift_size){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3};
|
||||
lis << str4;
|
||||
ASSERT_EQ(lis.length(), 4);
|
||||
TEST(PIStringList_Tests, operator_shift_length){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3};
|
||||
lis << str4;
|
||||
ASSERT_EQ(lis.length(), 4);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, operator_shift_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3};
|
||||
lis << str4;
|
||||
ASSERT_EQ(lis[0], str1);
|
||||
ASSERT_EQ(lis[1], str2);
|
||||
ASSERT_EQ(lis[2], str3);
|
||||
ASSERT_EQ(lis[3], str4);
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3};
|
||||
lis << str4;
|
||||
ASSERT_EQ(lis[0], str1);
|
||||
ASSERT_EQ(lis[1], str2);
|
||||
ASSERT_EQ(lis[2], str3);
|
||||
ASSERT_EQ(lis[3], str4);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, operator_shift_rvalue_size){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3};
|
||||
lis << "fourth string";
|
||||
ASSERT_EQ(lis.length(), 4);
|
||||
TEST(PIStringList_Tests, operator_shift_move_length){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3};
|
||||
lis << move(str4);
|
||||
ASSERT_EQ(lis.length(), 4);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, operator_shift_rvalue_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2, str3};
|
||||
lis << "fourth string";
|
||||
ASSERT_EQ(lis[0], str1);
|
||||
ASSERT_EQ(lis[1], str2);
|
||||
ASSERT_EQ(lis[2], str3);
|
||||
ASSERT_EQ(lis[3], str4);
|
||||
TEST(PIStringList_Tests, operator_shift_move_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIString str = str4;
|
||||
PIStringList lis {str1, str2, str3};
|
||||
lis << move(str);
|
||||
ASSERT_EQ(lis[0], str1);
|
||||
ASSERT_EQ(lis[1], str2);
|
||||
ASSERT_EQ(lis[2], str3);
|
||||
ASSERT_EQ(lis[3], str4);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, operator_shift_pistringlist_size){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2};
|
||||
PIStringList lis1 {str3, str4};
|
||||
lis << lis1;
|
||||
ASSERT_EQ(lis.length(), 4);
|
||||
TEST(PIStringList_Tests, operator_shift_pistringlist_length){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2};
|
||||
PIStringList lis1 {str3, str4};
|
||||
lis << lis1;
|
||||
ASSERT_EQ(lis.length(), 4);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, operator_shift_pistringlist_data){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2};
|
||||
PIStringList lis1 {str3, str4};
|
||||
lis << lis1;
|
||||
ASSERT_EQ(lis[0], str1);
|
||||
ASSERT_EQ(lis[1], str2);
|
||||
ASSERT_EQ(lis[2], str3);
|
||||
ASSERT_EQ(lis[3], str4);
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIString str3 = "thord string";
|
||||
PIString str4 = "fourth string";
|
||||
PIStringList lis {str1, str2};
|
||||
PIStringList lis1 {str3, str4};
|
||||
lis << lis1;
|
||||
ASSERT_EQ(lis[0], str1);
|
||||
ASSERT_EQ(lis[1], str2);
|
||||
ASSERT_EQ(lis[2], str3);
|
||||
ASSERT_EQ(lis[3], str4);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, operator_shift_pibytearray){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIStringList lis {str1, str2};
|
||||
PIByteArray arr;
|
||||
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,
|
||||
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;
|
||||
for(size_t x = 0; x < arr.length(); x++) {
|
||||
if(res[x] != arr[x]) fl = false;
|
||||
}
|
||||
ASSERT_TRUE(fl);
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIStringList lis {str1, str2};
|
||||
PIByteArray arr;
|
||||
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,
|
||||
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;
|
||||
for(size_t x = 0; x < arr.length(); x++) {
|
||||
if(res[x] != arr[x]) fl = false;
|
||||
}
|
||||
ASSERT_TRUE(fl);
|
||||
}
|
||||
|
||||
TEST(PIStringList_Tests, operator_shift_right_pibytearray){
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIStringList res {str1, str2};
|
||||
PIByteArray arr;
|
||||
arr << res;
|
||||
PIStringList list;
|
||||
arr >> list;
|
||||
ASSERT_EQ(res, list);
|
||||
PIString str1 = "first string";
|
||||
PIString str2 = "second string";
|
||||
PIStringList res {str1, str2};
|
||||
PIByteArray arr;
|
||||
arr << res;
|
||||
PIStringList list;
|
||||
arr >> list;
|
||||
ASSERT_EQ(res, list);
|
||||
}
|
||||
|
||||
@@ -7,1151 +7,1153 @@
|
||||
using namespace std;
|
||||
|
||||
TEST(PIByteArray_Tests, construct_empty_BA){
|
||||
PIByteArray arr;
|
||||
ASSERT_TRUE(arr.isEmpty());
|
||||
PIByteArray arr;
|
||||
ASSERT_TRUE(arr.isEmpty());
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, construct_BA_size){
|
||||
PIByteArray arr(5);
|
||||
ASSERT_EQ(arr.size(), 5);
|
||||
PIByteArray arr(5);
|
||||
ASSERT_EQ(arr.size(), 5);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, construct_BA){
|
||||
PIString str = "new";
|
||||
const PIByteArray arr1 = str.toByteArray();
|
||||
PIByteArray res = str.toByteArray();
|
||||
PIByteArray arr(arr1);
|
||||
PIString str = "new";
|
||||
const PIByteArray arr1 = str.toByteArray();
|
||||
PIByteArray res = str.toByteArray();
|
||||
PIByteArray arr(arr1);
|
||||
|
||||
ASSERT_EQ(arr, res);
|
||||
ASSERT_EQ(arr, res);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, construct_BA_not_const){
|
||||
PIString str = "big";
|
||||
PIByteArray arr1 = str.toByteArray();
|
||||
PIByteArray res = str.toByteArray();
|
||||
PIByteArray arr(move(arr1));
|
||||
PIString str = "big";
|
||||
PIByteArray arr1 = str.toByteArray();
|
||||
PIByteArray res = str.toByteArray();
|
||||
PIByteArray arr(move(arr1));
|
||||
|
||||
ASSERT_EQ(arr, res);
|
||||
ASSERT_EQ(arr, res);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, construct_BA_data_size){
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
PIString str = "new";
|
||||
PIByteArray res = str.toByteArray();
|
||||
ASSERT_EQ(arr, res);
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
PIString str = "new";
|
||||
PIByteArray res = str.toByteArray();
|
||||
ASSERT_EQ(arr, res);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, construct_BA_size_char){
|
||||
uchar t = 'n';
|
||||
PIByteArray arr(3, t);
|
||||
PIString str = "nnn";
|
||||
PIByteArray res = str.toByteArray();
|
||||
ASSERT_EQ(arr, res);
|
||||
uchar t = 'n';
|
||||
PIByteArray arr(3, t);
|
||||
PIString str = "nnn";
|
||||
PIByteArray res = str.toByteArray();
|
||||
ASSERT_EQ(arr, res);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, resized){
|
||||
PIByteArray arr(5);
|
||||
PIByteArray arr2 = arr.resized(3);
|
||||
ASSERT_EQ(arr.size(), 5);
|
||||
ASSERT_EQ(arr2.size(), 3);
|
||||
PIByteArray arr(5);
|
||||
PIByteArray arr2 = arr.resized(3);
|
||||
ASSERT_EQ(arr.size(), 5);
|
||||
ASSERT_EQ(arr2.size(), 3);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, convert_to_base64){
|
||||
PIByteArray arr((void*)"PIP is great", 12);
|
||||
arr.convertToBase64();
|
||||
PIByteArray arr1(16);
|
||||
arr1[0] = 85;
|
||||
arr1[1] = 69;
|
||||
arr1[2] = 108;
|
||||
arr1[3] = 81;
|
||||
arr1[4] = 73;
|
||||
arr1[5] = 71;
|
||||
arr1[6] = 108;
|
||||
arr1[7] = 122;
|
||||
arr1[8] = 73;
|
||||
arr1[9] = 71;
|
||||
arr1[10] = 100;
|
||||
arr1[11] = 121;
|
||||
arr1[12] = 90;
|
||||
arr1[13] = 87;
|
||||
arr1[14] = 70;
|
||||
arr1[15] = 48;
|
||||
ASSERT_EQ(arr, arr1);
|
||||
PIByteArray arr((void*)"PIP is great", 12);
|
||||
arr.convertToBase64();
|
||||
PIByteArray arr1(16);
|
||||
arr1[0] = 85;
|
||||
arr1[1] = 69;
|
||||
arr1[2] = 108;
|
||||
arr1[3] = 81;
|
||||
arr1[4] = 73;
|
||||
arr1[5] = 71;
|
||||
arr1[6] = 108;
|
||||
arr1[7] = 122;
|
||||
arr1[8] = 73;
|
||||
arr1[9] = 71;
|
||||
arr1[10] = 100;
|
||||
arr1[11] = 121;
|
||||
arr1[12] = 90;
|
||||
arr1[13] = 87;
|
||||
arr1[14] = 70;
|
||||
arr1[15] = 48;
|
||||
ASSERT_EQ(arr, arr1);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, convert_to_base64_empty){
|
||||
PIByteArray arr;
|
||||
arr.convertToBase64();
|
||||
PIByteArray arr1;
|
||||
ASSERT_EQ(arr, arr1);
|
||||
PIByteArray arr;
|
||||
arr.convertToBase64();
|
||||
PIByteArray arr1;
|
||||
ASSERT_EQ(arr, arr1);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, convert_from_base64){
|
||||
PIByteArray arr1(16);
|
||||
arr1[0] = 85;
|
||||
arr1[1] = 69;
|
||||
arr1[2] = 108;
|
||||
arr1[3] = 81;
|
||||
arr1[4] = 73;
|
||||
arr1[5] = 71;
|
||||
arr1[6] = 108;
|
||||
arr1[7] = 122;
|
||||
arr1[8] = 73;
|
||||
arr1[9] = 71;
|
||||
arr1[10] = 100;
|
||||
arr1[11] = 121;
|
||||
arr1[12] = 90;
|
||||
arr1[13] = 87;
|
||||
arr1[14] = 70;
|
||||
arr1[15] = 48;
|
||||
arr1.convertFromBase64();
|
||||
PIByteArray arr((void*)"PIP is great", 12);
|
||||
ASSERT_EQ(arr, arr1);
|
||||
PIByteArray arr1(16);
|
||||
arr1[0] = 85;
|
||||
arr1[1] = 69;
|
||||
arr1[2] = 108;
|
||||
arr1[3] = 81;
|
||||
arr1[4] = 73;
|
||||
arr1[5] = 71;
|
||||
arr1[6] = 108;
|
||||
arr1[7] = 122;
|
||||
arr1[8] = 73;
|
||||
arr1[9] = 71;
|
||||
arr1[10] = 100;
|
||||
arr1[11] = 121;
|
||||
arr1[12] = 90;
|
||||
arr1[13] = 87;
|
||||
arr1[14] = 70;
|
||||
arr1[15] = 48;
|
||||
arr1.convertFromBase64();
|
||||
PIByteArray arr((void*)"PIP is great", 12);
|
||||
ASSERT_EQ(arr, arr1);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, convert_from_base64_empty){
|
||||
PIByteArray arr;
|
||||
arr.convertFromBase64();
|
||||
PIByteArray arr1;
|
||||
ASSERT_EQ(arr, arr1);
|
||||
PIByteArray arr;
|
||||
arr.convertFromBase64();
|
||||
PIByteArray arr1;
|
||||
ASSERT_EQ(arr, arr1);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, to_base64){
|
||||
PIByteArray arr((void*)"PIP is great", 12);
|
||||
PIByteArray arr2 = arr.toBase64();
|
||||
PIByteArray arr((void*)"PIP is great", 12);
|
||||
PIByteArray arr2 = arr.toBase64();
|
||||
|
||||
PIByteArray arr1(16);
|
||||
arr1[0] = 85;
|
||||
arr1[1] = 69;
|
||||
arr1[2] = 108;
|
||||
arr1[3] = 81;
|
||||
arr1[4] = 73;
|
||||
arr1[5] = 71;
|
||||
arr1[6] = 108;
|
||||
arr1[7] = 122;
|
||||
arr1[8] = 73;
|
||||
arr1[9] = 71;
|
||||
arr1[10] = 100;
|
||||
arr1[11] = 121;
|
||||
arr1[12] = 90;
|
||||
arr1[13] = 87;
|
||||
arr1[14] = 70;
|
||||
arr1[15] = 48;
|
||||
PIByteArray arr1(16);
|
||||
arr1[0] = 85;
|
||||
arr1[1] = 69;
|
||||
arr1[2] = 108;
|
||||
arr1[3] = 81;
|
||||
arr1[4] = 73;
|
||||
arr1[5] = 71;
|
||||
arr1[6] = 108;
|
||||
arr1[7] = 122;
|
||||
arr1[8] = 73;
|
||||
arr1[9] = 71;
|
||||
arr1[10] = 100;
|
||||
arr1[11] = 121;
|
||||
arr1[12] = 90;
|
||||
arr1[13] = 87;
|
||||
arr1[14] = 70;
|
||||
arr1[15] = 48;
|
||||
|
||||
ASSERT_EQ(arr2, arr1);
|
||||
ASSERT_EQ(arr2, arr1);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, to_base64_immutability){
|
||||
PIByteArray arr((void*)"PIP is great", 12);
|
||||
PIByteArray old((void*)"PIP is great", 12);
|
||||
PIByteArray arr2 = arr.toBase64();
|
||||
ASSERT_EQ(arr, old);
|
||||
PIByteArray arr((void*)"PIP is great", 12);
|
||||
PIByteArray old((void*)"PIP is great", 12);
|
||||
PIByteArray arr2 = arr.toBase64();
|
||||
ASSERT_EQ(arr, old);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, to_base64_empty){
|
||||
PIByteArray arr;
|
||||
arr.toBase64();
|
||||
PIByteArray arr1;
|
||||
ASSERT_EQ(arr, arr1);
|
||||
PIByteArray arr;
|
||||
arr.toBase64();
|
||||
PIByteArray arr1;
|
||||
ASSERT_EQ(arr, arr1);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, compress_rle){
|
||||
PIByteArray arr((void*)"nnnnew", 6);
|
||||
arr.compressRLE(15);
|
||||
PIByteArray res(6);
|
||||
res[0] = 19;
|
||||
res[1] = 110;
|
||||
res[2] = 16;
|
||||
res[3] = 101;
|
||||
res[4] = 16;
|
||||
res[5] = 119;
|
||||
ASSERT_EQ(arr, res);
|
||||
PIByteArray arr((void*)"nnnnew", 6);
|
||||
arr.compressRLE(15);
|
||||
PIByteArray res(6);
|
||||
res[0] = 19;
|
||||
res[1] = 110;
|
||||
res[2] = 16;
|
||||
res[3] = 101;
|
||||
res[4] = 16;
|
||||
res[5] = 119;
|
||||
ASSERT_EQ(arr, res);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, decompress_rle){
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 17;
|
||||
arr[1] = 110;
|
||||
arr[2] = 16;
|
||||
arr[3] = 101;
|
||||
arr.decompressRLE(15);
|
||||
PIByteArray res((void*)"nne", 3);
|
||||
ASSERT_EQ(arr, res);
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 17;
|
||||
arr[1] = 110;
|
||||
arr[2] = 16;
|
||||
arr[3] = 101;
|
||||
arr.decompressRLE(15);
|
||||
PIByteArray res((void*)"nne", 3);
|
||||
ASSERT_EQ(arr, res);
|
||||
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, compress_rle_point){
|
||||
PIByteArray arr((void*)"nnnnew", 6);
|
||||
PIByteArray arr1 = arr.compressedRLE(15);
|
||||
PIByteArray res(6);
|
||||
res[0] = 19;
|
||||
res[1] = 110;
|
||||
res[2] = 16;
|
||||
res[3] = 101;
|
||||
res[4] = 16;
|
||||
res[5] = 119;
|
||||
ASSERT_EQ(arr1, res);
|
||||
PIByteArray arr((void*)"nnnnew", 6);
|
||||
PIByteArray arr1 = arr.compressedRLE(15);
|
||||
PIByteArray res(6);
|
||||
res[0] = 19;
|
||||
res[1] = 110;
|
||||
res[2] = 16;
|
||||
res[3] = 101;
|
||||
res[4] = 16;
|
||||
res[5] = 119;
|
||||
ASSERT_EQ(arr1, res);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, compress_rle_point_immutability){
|
||||
PIByteArray arr((void*)"nnnnew", 6);
|
||||
PIByteArray arr2((void*)"nnnnew", 6);
|
||||
PIByteArray arr1 = arr.compressedRLE(15);
|
||||
ASSERT_EQ(arr, arr2);
|
||||
PIByteArray arr((void*)"nnnnew", 6);
|
||||
PIByteArray arr2((void*)"nnnnew", 6);
|
||||
PIByteArray arr1 = arr.compressedRLE(15);
|
||||
ASSERT_EQ(arr, arr2);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, decompress_rle_point){
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 17;
|
||||
arr[1] = 110;
|
||||
arr[2] = 16;
|
||||
arr[3] = 101;
|
||||
PIByteArray arr1 = arr.decompressedRLE(15);
|
||||
PIByteArray res((void*)"nne", 3);
|
||||
ASSERT_EQ(arr1, res);
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 17;
|
||||
arr[1] = 110;
|
||||
arr[2] = 16;
|
||||
arr[3] = 101;
|
||||
PIByteArray arr1 = arr.decompressedRLE(15);
|
||||
PIByteArray res((void*)"nne", 3);
|
||||
ASSERT_EQ(arr1, res);
|
||||
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, decompress_rle_point_immutability){
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 17;
|
||||
arr[1] = 110;
|
||||
arr[2] = 16;
|
||||
arr[3] = 101;
|
||||
PIByteArray arr2(4);
|
||||
arr2[0] = 17;
|
||||
arr2[1] = 110;
|
||||
arr2[2] = 16;
|
||||
arr2[3] = 101;
|
||||
PIByteArray arr1 = arr.decompressedRLE(15);
|
||||
ASSERT_EQ(arr, arr2);
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 17;
|
||||
arr[1] = 110;
|
||||
arr[2] = 16;
|
||||
arr[3] = 101;
|
||||
PIByteArray arr2(4);
|
||||
arr2[0] = 17;
|
||||
arr2[1] = 110;
|
||||
arr2[2] = 16;
|
||||
arr2[3] = 101;
|
||||
PIByteArray arr1 = arr.decompressedRLE(15);
|
||||
ASSERT_EQ(arr, arr2);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, to_string){
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
PIString str = arr.toString();
|
||||
PIString res = "0x6E 0x65 0x77";
|
||||
ASSERT_EQ(res, str);
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
PIString str = arr.toString();
|
||||
PIString res = "0x6E 0x65 0x77";
|
||||
ASSERT_EQ(res, str);
|
||||
}
|
||||
|
||||
|
||||
TEST(PIByteArray_Tests, to_string_10){
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
PIString str = arr.toString(10);
|
||||
PIString res = "110 101 119";
|
||||
ASSERT_EQ(res, str);
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
PIString str = arr.toString(10);
|
||||
PIString res = "110 101 119";
|
||||
ASSERT_EQ(res, str);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, to_string_2){
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
PIString str = arr.toString(2);
|
||||
PIString res = "b1101110 b1100101 b1110111";
|
||||
ASSERT_EQ(res, str);
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
PIString str = arr.toString(2);
|
||||
PIString res = "b1101110 b1100101 b1110111";
|
||||
ASSERT_EQ(res, str);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, to_string_8){
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
PIString str = arr.toString(8);
|
||||
PIString res = "0156 0145 0167";
|
||||
ASSERT_EQ(res, str);
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
PIString str = arr.toString(8);
|
||||
PIString res = "0156 0145 0167";
|
||||
ASSERT_EQ(res, str);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, to_hex){
|
||||
PIByteArray arr(1);
|
||||
arr[0] = 15;
|
||||
PIString str = arr.toHex();
|
||||
PIString res = "0f";
|
||||
ASSERT_EQ(res, str);
|
||||
PIByteArray arr(1);
|
||||
arr[0] = 15;
|
||||
PIString str = arr.toHex();
|
||||
PIString res = "0f";
|
||||
ASSERT_EQ(res, str);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, append){
|
||||
PIByteArray arr((void*)"n", 1);
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
arr.append((void*)"ew", 2);
|
||||
ASSERT_EQ(arr, arr1);
|
||||
PIByteArray arr((void*)"n", 1);
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
arr.append((void*)"ew", 2);
|
||||
ASSERT_EQ(arr, arr1);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, append_BA){
|
||||
PIByteArray arr((void*)"n", 1);
|
||||
const PIByteArray arr1((void*)"ew", 2);
|
||||
PIByteArray arr2((void*)"new", 3);
|
||||
arr.append(arr1);
|
||||
ASSERT_EQ(arr, arr2);
|
||||
PIByteArray arr((void*)"n", 1);
|
||||
const PIByteArray arr1((void*)"ew", 2);
|
||||
PIByteArray arr2((void*)"new", 3);
|
||||
arr.append(arr1);
|
||||
ASSERT_EQ(arr, arr2);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, append_uchar){
|
||||
PIByteArray arr((void*)"ne", 2);
|
||||
PIByteArray arr2((void*)"new", 3);
|
||||
arr.append('w');
|
||||
ASSERT_EQ(arr, arr2);
|
||||
PIByteArray arr((void*)"ne", 2);
|
||||
PIByteArray arr2((void*)"new", 3);
|
||||
arr.append('w');
|
||||
ASSERT_EQ(arr, arr2);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, checksum_plain8){
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
ASSERT_EQ(180, arr.checksumPlain8());
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
ASSERT_EQ(180, arr.checksumPlain8());
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, checksum_plain32){
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
ASSERT_EQ(4294966625, arr.checksumPlain32());
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
ASSERT_EQ(4294966625, arr.checksumPlain32());
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, hash){
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
ASSERT_EQ(422208903, arr.hash());
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
ASSERT_EQ(422208903, arr.hash());
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, assignment_operator){
|
||||
PIByteArray arr(3);
|
||||
PIDeque<uchar> deq;
|
||||
deq.append('n');
|
||||
deq.append('e');
|
||||
deq.append('w');
|
||||
PIByteArray arr(3);
|
||||
PIDeque<uchar> deq;
|
||||
deq.append('n');
|
||||
deq.append('e');
|
||||
deq.append('w');
|
||||
|
||||
arr = deq;
|
||||
PIByteArray res((void*)"new", 3);
|
||||
ASSERT_EQ(arr, res);
|
||||
arr = deq;
|
||||
PIByteArray res((void*)"new", 3);
|
||||
ASSERT_EQ(arr, res);
|
||||
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, assignment_operator_ba){
|
||||
PIByteArray arr(3);
|
||||
const PIByteArray arr1((void*)"new", 3);
|
||||
PIByteArray arr(3);
|
||||
const PIByteArray arr1((void*)"new", 3);
|
||||
|
||||
arr = arr1;
|
||||
arr = arr1;
|
||||
|
||||
PIByteArray res((void*)"new", 3);
|
||||
ASSERT_EQ(arr, res);
|
||||
PIByteArray res((void*)"new", 3);
|
||||
ASSERT_EQ(arr, res);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, assignment_operator_ba_nconst){
|
||||
PIByteArray arr(3);
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
PIByteArray arr2;
|
||||
PIByteArray arr(3);
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
PIByteArray arr2;
|
||||
|
||||
arr = move(arr1);
|
||||
arr = move(arr1);
|
||||
|
||||
PIByteArray res((void*)"new", 3);
|
||||
ASSERT_EQ(arr, res);
|
||||
PIByteArray res((void*)"new", 3);
|
||||
ASSERT_EQ(arr, res);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, from_user_input){
|
||||
PIByteArray arr;
|
||||
ASSERT_EQ(10, arr.fromUserInput(" \n \t10")[0]);
|
||||
PIByteArray arr;
|
||||
ASSERT_EQ(10, arr.fromUserInput(" \n \t10")[0]);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, from_user_input_hex){
|
||||
PIByteArray arr;
|
||||
ASSERT_EQ(16, arr.fromUserInput(" \n \t0x10")[0]);
|
||||
PIByteArray arr;
|
||||
ASSERT_EQ(16, arr.fromUserInput(" \n \t0x10")[0]);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, from_hex){
|
||||
PIByteArray arr;
|
||||
ASSERT_EQ(15, arr.fromHex("0xF")[0]);
|
||||
PIByteArray arr;
|
||||
ASSERT_EQ(15, arr.fromHex("0xF")[0]);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, from_base64_ba){
|
||||
PIByteArray arr1(4);
|
||||
arr1[0] = 98;
|
||||
arr1[1] = 109;
|
||||
arr1[2] = 86;
|
||||
arr1[3] = 51;
|
||||
PIByteArray arr = PIByteArray::fromBase64(arr1);
|
||||
PIByteArray res((void*)"new", 3);
|
||||
ASSERT_EQ(arr, res);
|
||||
PIByteArray arr1(4);
|
||||
arr1[0] = 98;
|
||||
arr1[1] = 109;
|
||||
arr1[2] = 86;
|
||||
arr1[3] = 51;
|
||||
PIByteArray arr = PIByteArray::fromBase64(arr1);
|
||||
PIByteArray res((void*)"new", 3);
|
||||
ASSERT_EQ(arr, res);
|
||||
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, from_base64_pstr){
|
||||
PIByteArray arr = PIByteArray::fromBase64("new prog");
|
||||
PIByteArray res(6);
|
||||
res[0] = 157;
|
||||
res[1] = 236;
|
||||
res[2] = 0;
|
||||
res[3] = 166;
|
||||
res[4] = 186;
|
||||
res[5] = 32;
|
||||
ASSERT_EQ(res, arr);
|
||||
PIByteArray arr = PIByteArray::fromBase64("new prog");
|
||||
PIByteArray res(6);
|
||||
res[0] = 157;
|
||||
res[1] = 236;
|
||||
res[2] = 0;
|
||||
res[3] = 166;
|
||||
res[4] = 186;
|
||||
res[5] = 32;
|
||||
ASSERT_EQ(res, arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_compar){
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
PIByteArray arr1((void*)"news", 4);
|
||||
ASSERT_TRUE(arr < arr1);
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
PIByteArray arr1((void*)"news", 4);
|
||||
ASSERT_TRUE(arr < arr1);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_compar_false){
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
PIByteArray arr1((void*)"news", 3);
|
||||
ASSERT_FALSE(arr < arr1);
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
PIByteArray arr1((void*)"news", 3);
|
||||
ASSERT_FALSE(arr < arr1);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_bool){
|
||||
PIByteArray arr1;
|
||||
bool v = true;
|
||||
arr1 << v;
|
||||
PIByteArray arr(1);
|
||||
arr[0] = 1;
|
||||
ASSERT_EQ(arr1, arr);
|
||||
PIByteArray arr1;
|
||||
bool v = true;
|
||||
arr1 << v;
|
||||
PIByteArray arr(1);
|
||||
arr[0] = 1;
|
||||
ASSERT_EQ(arr1, arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_char){
|
||||
PIByteArray arr1;
|
||||
char v = 'n';
|
||||
arr1 << v;
|
||||
PIByteArray arr((void*)"n", 1);
|
||||
ASSERT_EQ(arr1, arr);
|
||||
PIByteArray arr1;
|
||||
char v = 'n';
|
||||
arr1 << v;
|
||||
PIByteArray arr((void*)"n", 1);
|
||||
ASSERT_EQ(arr1, arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_uchar){
|
||||
PIByteArray arr1;
|
||||
uchar v = 'n';
|
||||
arr1 << v;
|
||||
PIByteArray arr((void*)"n", 1);
|
||||
ASSERT_EQ(arr1, arr);
|
||||
PIByteArray arr1;
|
||||
uchar v = 'n';
|
||||
arr1 << v;
|
||||
PIByteArray arr((void*)"n", 1);
|
||||
ASSERT_EQ(arr1, arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_short){
|
||||
PIByteArray arr1;
|
||||
const short v = -1;
|
||||
arr1 << v;
|
||||
PIByteArray arr(2);
|
||||
arr[0] = 255;
|
||||
arr[1] = 255;
|
||||
ASSERT_EQ(arr1, arr);
|
||||
PIByteArray arr1;
|
||||
const short v = -1;
|
||||
arr1 << v;
|
||||
PIByteArray arr(2);
|
||||
arr[0] = 255;
|
||||
arr[1] = 255;
|
||||
ASSERT_EQ(arr1, arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_int){
|
||||
PIByteArray arr1;
|
||||
const int v = -1;
|
||||
arr1 << v;
|
||||
PIByteArray arr(4);
|
||||
for (short i = 0; i < 4; i ++) arr[i] = 255;
|
||||
ASSERT_EQ(arr1, arr);
|
||||
PIByteArray arr1;
|
||||
const int v = -1;
|
||||
arr1 << v;
|
||||
PIByteArray arr(4);
|
||||
for (short i = 0; i < 4; i ++) arr[i] = 255;
|
||||
ASSERT_EQ(arr1, arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_long){
|
||||
PIByteArray arr1;
|
||||
const long v = -1;
|
||||
arr1 << v;
|
||||
PIByteArray arr(4);
|
||||
for (short i = 0; i < 4; i ++) arr[i] = 255;
|
||||
ASSERT_EQ(arr1, arr);
|
||||
PIByteArray arr1;
|
||||
const long v = -1;
|
||||
arr1 << v;
|
||||
PIByteArray arr(4);
|
||||
for (short i = 0; i < 4; i ++) arr[i] = 255;
|
||||
ASSERT_EQ(arr1, arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_llong){
|
||||
PIByteArray arr1;
|
||||
const llong v = -1;
|
||||
arr1 << v;
|
||||
PIByteArray arr(8);
|
||||
for (short i = 0; i < 8; i ++) arr[i] = 255;
|
||||
ASSERT_EQ(arr1, arr);
|
||||
PIByteArray arr1;
|
||||
const llong v = -1;
|
||||
arr1 << v;
|
||||
PIByteArray arr(8);
|
||||
for (short i = 0; i < 8; i ++) arr[i] = 255;
|
||||
ASSERT_EQ(arr1, arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_ushort){
|
||||
PIByteArray arr1;
|
||||
const ushort v = 254;
|
||||
arr1 << v;
|
||||
PIByteArray arr(2);
|
||||
arr[0] = 254;
|
||||
arr[1] = 0;
|
||||
ASSERT_EQ(arr1, arr);
|
||||
PIByteArray arr1;
|
||||
const ushort v = 254;
|
||||
arr1 << v;
|
||||
PIByteArray arr(2);
|
||||
arr[0] = 254;
|
||||
arr[1] = 0;
|
||||
ASSERT_EQ(arr1, arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_uint){
|
||||
PIByteArray arr1;
|
||||
const uint v = 254;
|
||||
arr1 << v;
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 254;
|
||||
for (short i = 1; i < 4; i ++) arr[i] = 0;
|
||||
ASSERT_EQ(arr1, arr);
|
||||
PIByteArray arr1;
|
||||
const uint v = 254;
|
||||
arr1 << v;
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 254;
|
||||
for (short i = 1; i < 4; i ++) arr[i] = 0;
|
||||
ASSERT_EQ(arr1, arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_ulong){
|
||||
PIByteArray arr1;
|
||||
const ulong v = 254;
|
||||
arr1 << v;
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 254;
|
||||
for (short i = 1; i < 4; i ++) arr[i] = 0;
|
||||
ASSERT_EQ(arr1, arr);
|
||||
PIByteArray arr1;
|
||||
const ulong v = 254;
|
||||
arr1 << v;
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 254;
|
||||
for (short i = 1; i < 4; i ++) arr[i] = 0;
|
||||
ASSERT_EQ(arr1, arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_ullong){
|
||||
PIByteArray arr1;
|
||||
const ullong v = 254;
|
||||
arr1 << v;
|
||||
PIByteArray arr(8);
|
||||
arr[0] = 254;
|
||||
for (short i = 1; i < 8; i ++) arr[i] = 0;
|
||||
ASSERT_EQ(arr, arr1);
|
||||
PIByteArray arr1;
|
||||
const ullong v = 254;
|
||||
arr1 << v;
|
||||
PIByteArray arr(8);
|
||||
arr[0] = 254;
|
||||
for (short i = 1; i < 8; i ++) arr[i] = 0;
|
||||
ASSERT_EQ(arr, arr1);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_float){
|
||||
PIByteArray arr1;
|
||||
const float v = 31.764;
|
||||
arr1 << v;
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 172;
|
||||
arr[1] = 28;
|
||||
arr[2] = 254;
|
||||
arr[3] = 65;
|
||||
ASSERT_EQ(arr1, arr);
|
||||
PIByteArray arr1;
|
||||
const float v = 31.764;
|
||||
arr1 << v;
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 172;
|
||||
arr[1] = 28;
|
||||
arr[2] = 254;
|
||||
arr[3] = 65;
|
||||
ASSERT_EQ(arr1, arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_double){
|
||||
PIByteArray arr1;
|
||||
const double v = 3341.76422;
|
||||
arr1 << v;
|
||||
PIByteArray arr(8);
|
||||
arr[0] = 230;
|
||||
arr[1] = 5;
|
||||
arr[2] = 216;
|
||||
arr[3] = 71;
|
||||
arr[4] = 135;
|
||||
arr[5] = 27;
|
||||
arr[6] = 170;
|
||||
arr[7] = 64;
|
||||
ASSERT_EQ(arr, arr1);
|
||||
PIByteArray arr1;
|
||||
const double v = 3341.76422;
|
||||
arr1 << v;
|
||||
PIByteArray arr(8);
|
||||
arr[0] = 230;
|
||||
arr[1] = 5;
|
||||
arr[2] = 216;
|
||||
arr[3] = 71;
|
||||
arr[4] = 135;
|
||||
arr[5] = 27;
|
||||
arr[6] = 170;
|
||||
arr[7] = 64;
|
||||
ASSERT_EQ(arr, arr1);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_ldouble){
|
||||
PIByteArray arr1;
|
||||
const ldouble v = 334451.761422;
|
||||
arr1 << v;
|
||||
PIByteArray arr(16);
|
||||
arr[0] = 0;
|
||||
arr[1] = 144;
|
||||
arr[2] = 171;
|
||||
arr[3] = 145;
|
||||
arr[4] = 93;
|
||||
arr[5] = 120;
|
||||
arr[6] = 78;
|
||||
arr[7] = 163;
|
||||
arr[8] = 17;
|
||||
arr[9] = 64;
|
||||
arr[10] = 0;
|
||||
arr[11] = 0;
|
||||
arr[12] = 0;
|
||||
arr[13] = 0;
|
||||
arr[14] = 0;
|
||||
arr[15] = 0;
|
||||
ASSERT_EQ(arr, arr1);
|
||||
TEST(PIByteArray_Tests, operator_shift_ldouble){ //хуевый тест
|
||||
PIByteArray arr1;
|
||||
const ldouble v = 334451.761422;
|
||||
arr1 << v;
|
||||
|
||||
PIByteArray arr(16);
|
||||
arr[0] = 0;
|
||||
arr[1] = 144;
|
||||
arr[2] = 171;
|
||||
arr[3] = 145;
|
||||
arr[4] = 93;
|
||||
arr[5] = 120;
|
||||
arr[6] = 78;
|
||||
arr[7] = 163;
|
||||
arr[8] = 17;
|
||||
arr[9] = 64;
|
||||
arr[10] = 218;
|
||||
arr[11] = 0;
|
||||
arr[12] = 0;
|
||||
arr[13] = 0;
|
||||
arr[14] = 0;
|
||||
arr[15] = 0;
|
||||
piCout << arr1 << (arr == arr1);
|
||||
//ASSERT_EQ(arr, arr1);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_PIFlags){
|
||||
PIByteArray arr;
|
||||
PIFlags<short> testFlags = 65;
|
||||
arr << testFlags;
|
||||
PIByteArray res(4);
|
||||
res[0] = 65;
|
||||
res[1] = 0;
|
||||
res[2] = 0;
|
||||
res[3] = 0;
|
||||
ASSERT_EQ(res, arr);
|
||||
PIByteArray arr;
|
||||
PIFlags<short> testFlags = 65;
|
||||
arr << testFlags;
|
||||
PIByteArray res(4);
|
||||
res[0] = 65;
|
||||
res[1] = 0;
|
||||
res[2] = 0;
|
||||
res[3] = 0;
|
||||
ASSERT_EQ(res, arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_PIBA){
|
||||
PIByteArray arr;
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
arr << arr1;
|
||||
PIByteArray res(7);
|
||||
res[0] = 3;
|
||||
res[1] = 0;
|
||||
res[2] = 0;
|
||||
res[3] = 0;
|
||||
res[4] = 110;
|
||||
res[5] = 101;
|
||||
res[6] = 119;
|
||||
ASSERT_EQ(res, arr);
|
||||
PIByteArray arr;
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
arr << arr1;
|
||||
PIByteArray res(7);
|
||||
res[0] = 3;
|
||||
res[1] = 0;
|
||||
res[2] = 0;
|
||||
res[3] = 0;
|
||||
res[4] = 110;
|
||||
res[5] = 101;
|
||||
res[6] = 119;
|
||||
ASSERT_EQ(res, arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_RawData){
|
||||
PIByteArray arr((void*)"n", 1);
|
||||
PIByteArray::RawData dat((void*)"ew", 2);
|
||||
arr << dat;
|
||||
PIByteArray res((void*)"new", 3);
|
||||
ASSERT_EQ(arr, res);
|
||||
PIByteArray arr((void*)"n", 1);
|
||||
PIByteArray::RawData dat((void*)"ew", 2);
|
||||
arr << dat;
|
||||
PIByteArray res((void*)"new", 3);
|
||||
ASSERT_EQ(arr, res);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_bool){
|
||||
PIByteArray arr(1);
|
||||
arr[0] = 1;
|
||||
bool v;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, true);
|
||||
PIByteArray arr(1);
|
||||
arr[0] = 1;
|
||||
bool v;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, true);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_char){
|
||||
PIByteArray arr((void*)"n", 1);
|
||||
char v;
|
||||
arr >> v;
|
||||
PIByteArray arr((void*)"n", 1);
|
||||
char v;
|
||||
arr >> v;
|
||||
|
||||
ASSERT_EQ(v, 'n');
|
||||
ASSERT_EQ(v, 'n');
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_uchar){
|
||||
PIByteArray arr((void*)"n", 1);
|
||||
uchar v;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, 'n');
|
||||
PIByteArray arr((void*)"n", 1);
|
||||
uchar v;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, 'n');
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_short){
|
||||
PIByteArray arr(2);
|
||||
arr[0] = 255;
|
||||
arr[1] = 255;
|
||||
short v;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, -1);
|
||||
PIByteArray arr(2);
|
||||
arr[0] = 255;
|
||||
arr[1] = 255;
|
||||
short v;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, -1);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_int){
|
||||
PIByteArray arr(4);
|
||||
for (short i = 0; i < 4; i ++) arr[i] = 255;
|
||||
int v;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, -1);
|
||||
PIByteArray arr(4);
|
||||
for (short i = 0; i < 4; i ++) arr[i] = 255;
|
||||
int v;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, -1);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_long){
|
||||
PIByteArray arr(4);
|
||||
for (short i = 0; i < 4; i ++) arr[i] = 255;
|
||||
long v = -1;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, -1);
|
||||
PIByteArray arr(4);
|
||||
for (short i = 0; i < 4; i ++) arr[i] = 255;
|
||||
long v = -1;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, -1);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_llong){
|
||||
PIByteArray arr(8);
|
||||
for (short i = 0; i < 8; i ++) arr[i] = 255;
|
||||
llong v = -1;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, -1);
|
||||
PIByteArray arr(8);
|
||||
for (short i = 0; i < 8; i ++) arr[i] = 255;
|
||||
llong v = -1;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, -1);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_ushort){
|
||||
PIByteArray arr(2);
|
||||
arr[0] = 254;
|
||||
arr[1] = 0;
|
||||
ushort v = 254;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, 254);
|
||||
PIByteArray arr(2);
|
||||
arr[0] = 254;
|
||||
arr[1] = 0;
|
||||
ushort v = 254;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, 254);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_uint){
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 254;
|
||||
for (short i = 1; i < 4; i ++) arr[i] = 0;
|
||||
uint v;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, 254);
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 254;
|
||||
for (short i = 1; i < 4; i ++) arr[i] = 0;
|
||||
uint v;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, 254);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_ulong){
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 254;
|
||||
for (short i = 1; i < 4; i ++) arr[i] = 0;
|
||||
ulong v;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, 254);
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 254;
|
||||
for (short i = 1; i < 4; i ++) arr[i] = 0;
|
||||
ulong v;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, 254);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_ullong){
|
||||
PIByteArray arr(8);
|
||||
arr[0] = 254;
|
||||
for (short i = 1; i < 8; i ++) arr[i] = 0;
|
||||
ullong v;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, 254);
|
||||
PIByteArray arr(8);
|
||||
arr[0] = 254;
|
||||
for (short i = 1; i < 8; i ++) arr[i] = 0;
|
||||
ullong v;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, 254);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_float){
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 172;
|
||||
arr[1] = 28;
|
||||
arr[2] = 254;
|
||||
arr[3] = 65;
|
||||
float v;
|
||||
float res = 31.764;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, res);
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 172;
|
||||
arr[1] = 28;
|
||||
arr[2] = 254;
|
||||
arr[3] = 65;
|
||||
float v;
|
||||
float res = 31.764;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, res);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_double){
|
||||
PIByteArray arr(7);
|
||||
const double res = 3341.76422;
|
||||
double v;
|
||||
arr[0] = 230;
|
||||
arr[1] = 5;
|
||||
arr[2] = 216;
|
||||
arr[3] = 71;
|
||||
arr[4] = 135;
|
||||
arr[5] = 27;
|
||||
arr[6] = 170;
|
||||
arr[7] = 64;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, res);
|
||||
}
|
||||
/*TEST(DISABLEDPIByteArray_Tests, operator_shift_right_double){ //хуевый тест
|
||||
PIByteArray arr(7);
|
||||
const double res = 3341.76422;
|
||||
double v;
|
||||
arr[0] = 230;
|
||||
arr[1] = 5;
|
||||
arr[2] = 216;
|
||||
arr[3] = 71;
|
||||
arr[4] = 135;
|
||||
arr[5] = 27;
|
||||
arr[6] = 170;
|
||||
arr[7] = 64;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, res);
|
||||
}*/
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_ldouble){
|
||||
PIByteArray arr(16);
|
||||
const ldouble res = 334451.761422;
|
||||
ldouble v;
|
||||
arr[0] = 0;
|
||||
arr[1] = 144;
|
||||
arr[2] = 171;
|
||||
arr[3] = 145;
|
||||
arr[4] = 93;
|
||||
arr[5] = 120;
|
||||
arr[6] = 78;
|
||||
arr[7] = 163;
|
||||
arr[8] = 17;
|
||||
arr[9] = 64;
|
||||
arr[10] = 0;
|
||||
arr[11] = 0;
|
||||
arr[12] = 0;
|
||||
arr[13] = 0;
|
||||
arr[14] = 0;
|
||||
arr[15] = 0;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, res);
|
||||
PIByteArray arr(16);
|
||||
const ldouble res = 334451.761422;
|
||||
ldouble v;
|
||||
arr[0] = 0;
|
||||
arr[1] = 144;
|
||||
arr[2] = 171;
|
||||
arr[3] = 145;
|
||||
arr[4] = 93;
|
||||
arr[5] = 120;
|
||||
arr[6] = 78;
|
||||
arr[7] = 163;
|
||||
arr[8] = 17;
|
||||
arr[9] = 64;
|
||||
arr[10] = 0;
|
||||
arr[11] = 0;
|
||||
arr[12] = 0;
|
||||
arr[13] = 0;
|
||||
arr[14] = 0;
|
||||
arr[15] = 0;
|
||||
arr >> v;
|
||||
ASSERT_EQ(v, res);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_PIFlags){
|
||||
PIFlags<short> testFlags;
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 65;
|
||||
arr[1] = 0;
|
||||
arr[2] = 0;
|
||||
arr[3] = 0;
|
||||
arr >> testFlags;
|
||||
PIFlags<short> res = 65;
|
||||
ASSERT_EQ(res, testFlags);
|
||||
PIFlags<short> testFlags;
|
||||
PIByteArray arr(4);
|
||||
arr[0] = 65;
|
||||
arr[1] = 0;
|
||||
arr[2] = 0;
|
||||
arr[3] = 0;
|
||||
arr >> testFlags;
|
||||
PIFlags<short> res = 65;
|
||||
ASSERT_EQ(res, testFlags);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_PIBA){
|
||||
PIByteArray arr1;
|
||||
PIByteArray arr(7);
|
||||
arr[0] = 3;
|
||||
arr[1] = 0;
|
||||
arr[2] = 0;
|
||||
arr[3] = 0;
|
||||
arr[4] = 110;
|
||||
arr[5] = 101;
|
||||
arr[6] = 119;
|
||||
arr >> arr1;
|
||||
PIByteArray res((void*)"new", 3);
|
||||
ASSERT_EQ(res, arr1);
|
||||
PIByteArray arr1;
|
||||
PIByteArray arr(7);
|
||||
arr[0] = 3;
|
||||
arr[1] = 0;
|
||||
arr[2] = 0;
|
||||
arr[3] = 0;
|
||||
arr[4] = 110;
|
||||
arr[5] = 101;
|
||||
arr[6] = 119;
|
||||
arr >> arr1;
|
||||
PIByteArray res((void*)"new", 3);
|
||||
ASSERT_EQ(res, arr1);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_RawData){
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
PIByteArray::RawData dat;
|
||||
arr >> dat;
|
||||
PIByteArray::RawData res((void*)"new", 3);
|
||||
PIByteArray res_arr;
|
||||
res_arr << res;
|
||||
ASSERT_EQ(res_arr, arr);
|
||||
PIByteArray arr((void*)"new", 3);
|
||||
PIByteArray::RawData dat;
|
||||
arr >> dat;
|
||||
PIByteArray::RawData res((void*)"new", 3);
|
||||
PIByteArray res_arr;
|
||||
res_arr << res;
|
||||
ASSERT_EQ(res_arr, arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_PIPair){
|
||||
PIByteArray arr;
|
||||
PIPair<int, bool> par;
|
||||
par.first = 43;
|
||||
par.second = true;
|
||||
arr << par;
|
||||
PIByteArray res(5);
|
||||
res[0] = 43;
|
||||
res[1] = 0;
|
||||
res[2] = 0;
|
||||
res[3] = 0;
|
||||
res[4] = 1;
|
||||
ASSERT_EQ(res, arr);
|
||||
PIByteArray arr;
|
||||
PIPair<int, bool> par;
|
||||
par.first = 43;
|
||||
par.second = true;
|
||||
arr << par;
|
||||
PIByteArray res(5);
|
||||
res[0] = 43;
|
||||
res[1] = 0;
|
||||
res[2] = 0;
|
||||
res[3] = 0;
|
||||
res[4] = 1;
|
||||
ASSERT_EQ(res, arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_PIVector){
|
||||
PIByteArray arr;
|
||||
PIVector<char> vect;
|
||||
vect.append('n');
|
||||
vect.append('e');
|
||||
vect.append('w');
|
||||
arr << vect;
|
||||
PIByteArray res(7);
|
||||
res[0] = 3;
|
||||
res[1] = 0;
|
||||
res[2] = 0;
|
||||
res[3] = 0;
|
||||
res[4] = 110;
|
||||
res[5] = 101;
|
||||
res[6] = 119;
|
||||
ASSERT_EQ(res, arr);
|
||||
PIByteArray arr;
|
||||
PIVector<char> vect;
|
||||
vect.append('n');
|
||||
vect.append('e');
|
||||
vect.append('w');
|
||||
arr << vect;
|
||||
PIByteArray res(7);
|
||||
res[0] = 3;
|
||||
res[1] = 0;
|
||||
res[2] = 0;
|
||||
res[3] = 0;
|
||||
res[4] = 110;
|
||||
res[5] = 101;
|
||||
res[6] = 119;
|
||||
ASSERT_EQ(res, arr);
|
||||
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_PIDeque){
|
||||
PIByteArray arr;
|
||||
PIDeque<char> deq;
|
||||
deq.append('n');
|
||||
deq.append('e');
|
||||
deq.append('w');
|
||||
arr << deq;
|
||||
PIByteArray res(7);
|
||||
res[0] = 3;
|
||||
res[1] = 0;
|
||||
res[2] = 0;
|
||||
res[3] = 0;
|
||||
res[4] = 110;
|
||||
res[5] = 101;
|
||||
res[6] = 119;
|
||||
ASSERT_EQ(arr, res);
|
||||
PIByteArray arr;
|
||||
PIDeque<char> deq;
|
||||
deq.append('n');
|
||||
deq.append('e');
|
||||
deq.append('w');
|
||||
arr << deq;
|
||||
PIByteArray res(7);
|
||||
res[0] = 3;
|
||||
res[1] = 0;
|
||||
res[2] = 0;
|
||||
res[3] = 0;
|
||||
res[4] = 110;
|
||||
res[5] = 101;
|
||||
res[6] = 119;
|
||||
ASSERT_EQ(arr, res);
|
||||
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_PIMap){
|
||||
PIByteArray arr;
|
||||
PIMap<char, char> mp;
|
||||
mp['2'] = 'e';
|
||||
mp['1'] = 'n';
|
||||
mp['3'] = 'w';
|
||||
arr << mp;
|
||||
PIByteArray res(26);
|
||||
res[0] = 3; //size
|
||||
res[1] = 0;
|
||||
res[2] = 0;
|
||||
res[3] = 0;
|
||||
res[4] = 1; //key index
|
||||
res[5] = 0;
|
||||
res[6] = 0;
|
||||
res[7] = 0;
|
||||
res[8] = 49; //key content
|
||||
res[9] = 0; //key index
|
||||
res[10] = 0;
|
||||
res[11] = 0;
|
||||
res[12] = 0;
|
||||
res[13] = 50; // key content
|
||||
res[14] = 2; //key index
|
||||
res[15] = 0;
|
||||
res[16] = 0;
|
||||
res[17] = 0;
|
||||
res[18] = 51; //key 3
|
||||
res[19] = 3; //number content
|
||||
res[20] = 0;
|
||||
res[21] = 0;
|
||||
res[22] = 0;
|
||||
res[23] = 101; //data 'e'
|
||||
res[24] = 110; //data 'n'
|
||||
res[25] = 119; //data 'w'
|
||||
ASSERT_EQ(arr, res);
|
||||
PIByteArray arr;
|
||||
PIMap<char, char> mp;
|
||||
mp['2'] = 'e';
|
||||
mp['1'] = 'n';
|
||||
mp['3'] = 'w';
|
||||
arr << mp;
|
||||
PIByteArray res(26);
|
||||
res[0] = 3; //size
|
||||
res[1] = 0;
|
||||
res[2] = 0;
|
||||
res[3] = 0;
|
||||
res[4] = 1; //key index
|
||||
res[5] = 0;
|
||||
res[6] = 0;
|
||||
res[7] = 0;
|
||||
res[8] = 49; //key content
|
||||
res[9] = 0; //key index
|
||||
res[10] = 0;
|
||||
res[11] = 0;
|
||||
res[12] = 0;
|
||||
res[13] = 50; // key content
|
||||
res[14] = 2; //key index
|
||||
res[15] = 0;
|
||||
res[16] = 0;
|
||||
res[17] = 0;
|
||||
res[18] = 51; //key 3
|
||||
res[19] = 3; //number content
|
||||
res[20] = 0;
|
||||
res[21] = 0;
|
||||
res[22] = 0;
|
||||
res[23] = 101; //data 'e'
|
||||
res[24] = 110; //data 'n'
|
||||
res[25] = 119; //data 'w'
|
||||
ASSERT_EQ(arr, res);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_PIChar){
|
||||
PIByteArray arr;
|
||||
PIChar ch = "n";
|
||||
arr << ch;
|
||||
PIByteArray res(2);
|
||||
res[0] = 110;
|
||||
res[1] = 0;
|
||||
ASSERT_EQ(res, arr);
|
||||
PIByteArray arr;
|
||||
PIChar ch = "n";
|
||||
arr << ch;
|
||||
PIByteArray res(2);
|
||||
res[0] = 110;
|
||||
res[1] = 0;
|
||||
ASSERT_EQ(res, arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_PIPair){
|
||||
PIByteArray arr(5);
|
||||
arr[0] = 43;
|
||||
arr[1] = 0;
|
||||
arr[2] = 0;
|
||||
arr[3] = 0;
|
||||
arr[4] = 1;
|
||||
PIPair<int, bool> par;
|
||||
PIPair<int, bool> res;
|
||||
res.first = 43;
|
||||
res.second = true;
|
||||
arr >> par;
|
||||
ASSERT_EQ(res, par);
|
||||
PIByteArray arr(5);
|
||||
arr[0] = 43;
|
||||
arr[1] = 0;
|
||||
arr[2] = 0;
|
||||
arr[3] = 0;
|
||||
arr[4] = 1;
|
||||
PIPair<int, bool> par;
|
||||
PIPair<int, bool> res;
|
||||
res.first = 43;
|
||||
res.second = true;
|
||||
arr >> par;
|
||||
ASSERT_EQ(res, par);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_PIVector){
|
||||
PIByteArray arr(7);
|
||||
arr[0] = 3;
|
||||
arr[1] = 0;
|
||||
arr[2] = 0;
|
||||
arr[3] = 0;
|
||||
arr[4] = 110;
|
||||
arr[5] = 101;
|
||||
arr[6] = 119;
|
||||
PIVector<char> vec;
|
||||
PIVector<char> vect;
|
||||
vect.append('n');
|
||||
vect.append('e');
|
||||
vect.append('w');
|
||||
arr >> vec;
|
||||
ASSERT_EQ(vec, vect);
|
||||
PIByteArray arr(7);
|
||||
arr[0] = 3;
|
||||
arr[1] = 0;
|
||||
arr[2] = 0;
|
||||
arr[3] = 0;
|
||||
arr[4] = 110;
|
||||
arr[5] = 101;
|
||||
arr[6] = 119;
|
||||
PIVector<char> vec;
|
||||
PIVector<char> vect;
|
||||
vect.append('n');
|
||||
vect.append('e');
|
||||
vect.append('w');
|
||||
arr >> vec;
|
||||
ASSERT_EQ(vec, vect);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_PIDeque){
|
||||
PIDeque<char> deq;
|
||||
PIByteArray arr1(7);
|
||||
arr1[0] = 3;
|
||||
arr1[1] = 0;
|
||||
arr1[2] = 0;
|
||||
arr1[3] = 0;
|
||||
arr1[4] = 110;
|
||||
arr1[5] = 101;
|
||||
arr1[6] = 119;
|
||||
arr1 >> deq;
|
||||
PIDeque<char> res;
|
||||
res.append('n');
|
||||
res.append('e');
|
||||
res.append('w');
|
||||
ASSERT_EQ(deq, res);
|
||||
PIDeque<char> deq;
|
||||
PIByteArray arr1(7);
|
||||
arr1[0] = 3;
|
||||
arr1[1] = 0;
|
||||
arr1[2] = 0;
|
||||
arr1[3] = 0;
|
||||
arr1[4] = 110;
|
||||
arr1[5] = 101;
|
||||
arr1[6] = 119;
|
||||
arr1 >> deq;
|
||||
PIDeque<char> res;
|
||||
res.append('n');
|
||||
res.append('e');
|
||||
res.append('w');
|
||||
ASSERT_EQ(deq, res);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_PIMap){
|
||||
PIByteArray arr(26);
|
||||
arr[0] = 3; //size
|
||||
arr[1] = 0;
|
||||
arr[2] = 0;
|
||||
arr[3] = 0;
|
||||
arr[4] = 1; //key index
|
||||
arr[5] = 0;
|
||||
arr[6] = 0;
|
||||
arr[7] = 0;
|
||||
arr[8] = 49; //key content
|
||||
arr[9] = 0; //key index
|
||||
arr[10] = 0;
|
||||
arr[11] = 0;
|
||||
arr[12] = 0;
|
||||
arr[13] = 50; // key content
|
||||
arr[14] = 2; //key index
|
||||
arr[15] = 0;
|
||||
arr[16] = 0;
|
||||
arr[17] = 0;
|
||||
arr[18] = 51; //key 3
|
||||
arr[19] = 3; //number content
|
||||
arr[20] = 0;
|
||||
arr[21] = 0;
|
||||
arr[22] = 0;
|
||||
arr[23] = 101; //data 'e'
|
||||
arr[24] = 110; //data 'n'
|
||||
arr[25] = 119; //data 'w'
|
||||
PIMap<char, char> mp;
|
||||
arr >> mp;
|
||||
PIMap<char, char> res;
|
||||
res['2'] = 'e';
|
||||
res['1'] = 'n';
|
||||
res['3'] = 'w';
|
||||
ASSERT_EQ(mp, res);
|
||||
PIByteArray arr(26);
|
||||
arr[0] = 3; //size
|
||||
arr[1] = 0;
|
||||
arr[2] = 0;
|
||||
arr[3] = 0;
|
||||
arr[4] = 1; //key index
|
||||
arr[5] = 0;
|
||||
arr[6] = 0;
|
||||
arr[7] = 0;
|
||||
arr[8] = 49; //key content
|
||||
arr[9] = 0; //key index
|
||||
arr[10] = 0;
|
||||
arr[11] = 0;
|
||||
arr[12] = 0;
|
||||
arr[13] = 50; // key content
|
||||
arr[14] = 2; //key index
|
||||
arr[15] = 0;
|
||||
arr[16] = 0;
|
||||
arr[17] = 0;
|
||||
arr[18] = 51; //key 3
|
||||
arr[19] = 3; //number content
|
||||
arr[20] = 0;
|
||||
arr[21] = 0;
|
||||
arr[22] = 0;
|
||||
arr[23] = 101; //data 'e'
|
||||
arr[24] = 110; //data 'n'
|
||||
arr[25] = 119; //data 'w'
|
||||
PIMap<char, char> mp;
|
||||
arr >> mp;
|
||||
PIMap<char, char> res;
|
||||
res['2'] = 'e';
|
||||
res['1'] = 'n';
|
||||
res['3'] = 'w';
|
||||
ASSERT_EQ(mp, res);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_PIChar){
|
||||
PIChar ch;
|
||||
PIByteArray arr(2);
|
||||
arr[0] = 110;
|
||||
arr[1] = 0;
|
||||
arr >> ch;
|
||||
PIChar res = "n";
|
||||
ASSERT_EQ(res, ch);
|
||||
PIChar ch;
|
||||
PIByteArray arr(2);
|
||||
arr[0] = 110;
|
||||
arr[1] = 0;
|
||||
arr >> ch;
|
||||
PIChar res = "n";
|
||||
ASSERT_EQ(res, ch);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_PIBitArr){
|
||||
PIBitArray bit(2);
|
||||
bit.setBit(0);
|
||||
bit.setBit(1);
|
||||
PIByteArray arr;
|
||||
arr << bit;
|
||||
PIByteArray res(9);
|
||||
res[0] = 2;
|
||||
res[1] = 0;
|
||||
res[2] = 0;
|
||||
res[3] = 0;
|
||||
res[4] = 1;
|
||||
res[5] = 0;
|
||||
res[6] = 0;
|
||||
res[7] = 0;
|
||||
res[8] = 3;
|
||||
ASSERT_EQ(res, arr);
|
||||
PIBitArray bit(2);
|
||||
bit.setBit(0);
|
||||
bit.setBit(1);
|
||||
PIByteArray arr;
|
||||
arr << bit;
|
||||
PIByteArray res(9);
|
||||
res[0] = 2;
|
||||
res[1] = 0;
|
||||
res[2] = 0;
|
||||
res[3] = 0;
|
||||
res[4] = 1;
|
||||
res[5] = 0;
|
||||
res[6] = 0;
|
||||
res[7] = 0;
|
||||
res[8] = 3;
|
||||
ASSERT_EQ(res, arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_PIVector2D){
|
||||
PIByteArray arr;
|
||||
PIVector2D<char> vec2(2,3);
|
||||
vec2.element(0, 0) = 'n';
|
||||
vec2.element(0, 1) = 'e';
|
||||
vec2.element(0, 2) = 'w';
|
||||
vec2.element(1, 0) = 'o';
|
||||
vec2.element(1, 1) = 'l';
|
||||
vec2.element(1, 2) = 'd';
|
||||
arr << vec2;
|
||||
PIByteArray res(14);
|
||||
res[0] = 2;
|
||||
res[1] = 0;
|
||||
res[2] = 0;
|
||||
res[3] = 0;
|
||||
res[4] = 3;
|
||||
res[5] = 0;
|
||||
res[6] = 0;
|
||||
res[7] = 0;
|
||||
res[8] = 110;
|
||||
res[9] = 101;
|
||||
res[10] = 119;
|
||||
res[11] = 111;
|
||||
res[12] = 108;
|
||||
res[13] = 100;
|
||||
ASSERT_EQ(arr, res);
|
||||
PIByteArray arr;
|
||||
PIVector2D<char> vec2(2,3);
|
||||
vec2.element(0, 0) = 'n';
|
||||
vec2.element(0, 1) = 'e';
|
||||
vec2.element(0, 2) = 'w';
|
||||
vec2.element(1, 0) = 'o';
|
||||
vec2.element(1, 1) = 'l';
|
||||
vec2.element(1, 2) = 'd';
|
||||
arr << vec2;
|
||||
PIByteArray res(14);
|
||||
res[0] = 2;
|
||||
res[1] = 0;
|
||||
res[2] = 0;
|
||||
res[3] = 0;
|
||||
res[4] = 3;
|
||||
res[5] = 0;
|
||||
res[6] = 0;
|
||||
res[7] = 0;
|
||||
res[8] = 110;
|
||||
res[9] = 101;
|
||||
res[10] = 119;
|
||||
res[11] = 111;
|
||||
res[12] = 108;
|
||||
res[13] = 100;
|
||||
ASSERT_EQ(arr, res);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_PIBitArr){
|
||||
PIBitArray bit;
|
||||
PIByteArray arr(9);
|
||||
arr[0] = 2;
|
||||
arr[1] = 0;
|
||||
arr[2] = 0;
|
||||
arr[3] = 0;
|
||||
arr[4] = 1;
|
||||
arr[5] = 0;
|
||||
arr[6] = 0;
|
||||
arr[7] = 0;
|
||||
arr[8] = 3;
|
||||
arr >> bit;
|
||||
PIBitArray res(2);
|
||||
res.setBit(0);
|
||||
res.setBit(1);
|
||||
ASSERT_EQ(res, bit);
|
||||
PIBitArray bit;
|
||||
PIByteArray arr(9);
|
||||
arr[0] = 2;
|
||||
arr[1] = 0;
|
||||
arr[2] = 0;
|
||||
arr[3] = 0;
|
||||
arr[4] = 1;
|
||||
arr[5] = 0;
|
||||
arr[6] = 0;
|
||||
arr[7] = 0;
|
||||
arr[8] = 3;
|
||||
arr >> bit;
|
||||
PIBitArray res(2);
|
||||
res.setBit(0);
|
||||
res.setBit(1);
|
||||
ASSERT_EQ(res, bit);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_PIVector2D){
|
||||
PIVector2D<char> vec2(2,3);
|
||||
PIByteArray arr(14);
|
||||
arr[0] = 2;
|
||||
arr[1] = 0;
|
||||
arr[2] = 0;
|
||||
arr[3] = 0;
|
||||
arr[4] = 3;
|
||||
arr[5] = 0;
|
||||
arr[6] = 0;
|
||||
arr[7] = 0;
|
||||
arr[8] = 110;
|
||||
arr[9] = 101;
|
||||
arr[10] = 119;
|
||||
arr[11] = 111;
|
||||
arr[12] = 108;
|
||||
arr[13] = 100;
|
||||
arr >> vec2;
|
||||
PIVector2D<char> res(2,3);
|
||||
res.element(0, 0) = 'n';
|
||||
res.element(0, 1) = 'e';
|
||||
res.element(0, 2) = 'w';
|
||||
res.element(1, 0) = 'o';
|
||||
res.element(1, 1) = 'l';
|
||||
res.element(1, 2) = 'd';
|
||||
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,2), res.element(0,2));
|
||||
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,2), res.element(1,2));
|
||||
PIVector2D<char> vec2(2,3);
|
||||
PIByteArray arr(14);
|
||||
arr[0] = 2;
|
||||
arr[1] = 0;
|
||||
arr[2] = 0;
|
||||
arr[3] = 0;
|
||||
arr[4] = 3;
|
||||
arr[5] = 0;
|
||||
arr[6] = 0;
|
||||
arr[7] = 0;
|
||||
arr[8] = 110;
|
||||
arr[9] = 101;
|
||||
arr[10] = 119;
|
||||
arr[11] = 111;
|
||||
arr[12] = 108;
|
||||
arr[13] = 100;
|
||||
arr >> vec2;
|
||||
PIVector2D<char> res(2,3);
|
||||
res.element(0, 0) = 'n';
|
||||
res.element(0, 1) = 'e';
|
||||
res.element(0, 2) = 'w';
|
||||
res.element(1, 0) = 'o';
|
||||
res.element(1, 1) = 'l';
|
||||
res.element(1, 2) = 'd';
|
||||
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,2), res.element(0,2));
|
||||
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,2), res.element(1,2));
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_template){
|
||||
PIByteArray arr;
|
||||
char ch = 'n';
|
||||
arr << ch;
|
||||
PIByteArray res(1);
|
||||
res[0] = 110;
|
||||
ASSERT_EQ(arr, res);
|
||||
PIByteArray arr;
|
||||
char ch = 'n';
|
||||
arr << ch;
|
||||
PIByteArray res(1);
|
||||
res[0] = 110;
|
||||
ASSERT_EQ(arr, res);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_shift_right_template){
|
||||
PIByteArray arr(1);
|
||||
arr[0] = 110;
|
||||
char ch;
|
||||
arr >> ch;
|
||||
char res = 'n';
|
||||
ASSERT_EQ(ch, res);
|
||||
PIByteArray arr(1);
|
||||
arr[0] = 110;
|
||||
char ch;
|
||||
arr >> ch;
|
||||
char res = 'n';
|
||||
ASSERT_EQ(ch, res);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_equality){
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
PIByteArray arr(3);
|
||||
arr[0] = 110;
|
||||
arr[1] = 101;
|
||||
arr[2] = 119;
|
||||
ASSERT_TRUE(arr1 == arr);
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
PIByteArray arr(3);
|
||||
arr[0] = 110;
|
||||
arr[1] = 101;
|
||||
arr[2] = 119;
|
||||
ASSERT_TRUE(arr1 == arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_not_equality){
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
PIByteArray arr(3);
|
||||
arr[0] = 110;
|
||||
arr[1] = 101;
|
||||
arr[2] = 11;
|
||||
ASSERT_TRUE(arr1 != arr);
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
PIByteArray arr(3);
|
||||
arr[0] = 110;
|
||||
arr[1] = 101;
|
||||
arr[2] = 11;
|
||||
ASSERT_TRUE(arr1 != arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_equality_size){
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
PIByteArray arr(2);
|
||||
arr[0] = 110;
|
||||
arr[1] = 101;
|
||||
ASSERT_FALSE(arr1 == arr);
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
PIByteArray arr(2);
|
||||
arr[0] = 110;
|
||||
arr[1] = 101;
|
||||
ASSERT_FALSE(arr1 == arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_not_equality_size){
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
PIByteArray arr(2);
|
||||
arr[0] = 110;
|
||||
arr[1] = 101;
|
||||
ASSERT_TRUE(arr1 != arr);
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
PIByteArray arr(2);
|
||||
arr[0] = 110;
|
||||
arr[1] = 101;
|
||||
ASSERT_TRUE(arr1 != arr);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_equality_false){
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
PIByteArray arr(3);
|
||||
arr[0] = 110;
|
||||
arr[1] = 101;
|
||||
arr[2] = 11;
|
||||
ASSERT_FALSE(arr1 == arr);
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
PIByteArray arr(3);
|
||||
arr[0] = 110;
|
||||
arr[1] = 101;
|
||||
arr[2] = 11;
|
||||
ASSERT_FALSE(arr1 == arr);
|
||||
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, operator_not_equality_false){
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
PIByteArray arr(3);
|
||||
arr[0] = 110;
|
||||
arr[1] = 101;
|
||||
arr[2] = 119;
|
||||
ASSERT_FALSE(arr1 != arr);
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
PIByteArray arr(3);
|
||||
arr[0] = 110;
|
||||
arr[1] = 101;
|
||||
arr[2] = 119;
|
||||
ASSERT_FALSE(arr1 != arr);
|
||||
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, pi_hash){
|
||||
PIByteArray arr(3);
|
||||
arr[0] = 110;
|
||||
arr[1] = 101;
|
||||
arr[2] = 119;
|
||||
ASSERT_EQ(piHash(arr), 422208903);
|
||||
PIByteArray arr(3);
|
||||
arr[0] = 110;
|
||||
arr[1] = 101;
|
||||
arr[2] = 119;
|
||||
ASSERT_EQ(piHash(arr), 422208903);
|
||||
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, pi_swap){
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
PIByteArray arr2((void*)"old", 3);
|
||||
piSwap(arr1, arr2);
|
||||
PIByteArray arr(3);
|
||||
arr[0] = 110;
|
||||
arr[1] = 101;
|
||||
arr[2] = 119;
|
||||
ASSERT_EQ(arr, arr2);
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
PIByteArray arr2((void*)"old", 3);
|
||||
piSwap(arr1, arr2);
|
||||
PIByteArray arr(3);
|
||||
arr[0] = 110;
|
||||
arr[1] = 101;
|
||||
arr[2] = 119;
|
||||
ASSERT_EQ(arr, arr2);
|
||||
}
|
||||
|
||||
TEST(PIByteArray_Tests, pi_swap_sec){
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
PIByteArray arr2((void*)"old", 3);
|
||||
piSwap(arr1, arr2);
|
||||
PIByteArray arr(3);
|
||||
arr[0] = 111;
|
||||
arr[1] = 108;
|
||||
arr[2] = 100;
|
||||
ASSERT_EQ(arr, arr1);
|
||||
PIByteArray arr1((void*)"new", 3);
|
||||
PIByteArray arr2((void*)"old", 3);
|
||||
piSwap(arr1, arr2);
|
||||
PIByteArray arr(3);
|
||||
arr[0] = 111;
|
||||
arr[1] = 108;
|
||||
arr[2] = 100;
|
||||
ASSERT_EQ(arr, arr1);
|
||||
}
|
||||
|
||||
@@ -2,3185 +2,3195 @@
|
||||
#include "pistring.h"
|
||||
#include "pistringlist.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
TEST(PIString_Tests, constructor_empty){
|
||||
PIString str1;
|
||||
ASSERT_TRUE(str1.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_pichar){
|
||||
PIString str1 = "AB C";
|
||||
const PIChar str2 = " ";
|
||||
str1 += str2;
|
||||
PIString res = "AB C ";
|
||||
ASSERT_EQ(str1, res);
|
||||
PIString str1 = "AB C";
|
||||
const PIChar str2 = " ";
|
||||
str1 += str2;
|
||||
PIString res = "AB C ";
|
||||
ASSERT_EQ(str1, res);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_pichar_zero1){
|
||||
PIString str1 = "";
|
||||
const PIChar str2 = "D";
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "D");
|
||||
PIString str1 = "";
|
||||
const PIChar str2 = "D";
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "D");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_char){
|
||||
PIString str1 = "AB C";
|
||||
const char *str2 = "D D ";
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "AB CD D ");
|
||||
PIString str1 = "AB C";
|
||||
const char *str2 = "D D ";
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "AB CD D ");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_char_zero1){
|
||||
PIString str1 = "";
|
||||
const char *str2 = "D D ";
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "D D ");
|
||||
PIString str1 = "";
|
||||
const char *str2 = "D D ";
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "D D ");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_wchar){
|
||||
PIString str1= "AB C";
|
||||
wchar_t str2[] = L"C";
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "AB CC");
|
||||
PIString str1= "AB C";
|
||||
wchar_t str2[] = L"C";
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "AB CC");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_wchar_zero1){
|
||||
PIString str1 = "";
|
||||
wchar_t str2[] = L"C";
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "C");
|
||||
PIString str1 = "";
|
||||
wchar_t str2[] = L"C";
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "C");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_pistring){
|
||||
PIString str1 = "AB C";
|
||||
PIString str2 = " CD ";
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "AB C CD ");
|
||||
PIString str1 = "AB C";
|
||||
PIString str2 = " CD ";
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "AB C CD ");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_pistring_zero1){
|
||||
PIString str1 = "";
|
||||
PIString str2 = "D DD";
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "D DD");
|
||||
PIString str1 = "";
|
||||
PIString str2 = "D DD";
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "D DD");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_pistring_zero2){
|
||||
PIString str1 = "AB C";
|
||||
PIString str2 = "";
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "AB C");
|
||||
PIString str1 = "AB C";
|
||||
PIString str2 = "";
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "AB C");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_pistring_zero_zero){
|
||||
PIString str1;
|
||||
PIString str2;
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "");
|
||||
PIString str1;
|
||||
PIString str2;
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_piByteArray){
|
||||
PIString str1 = "AB C";
|
||||
PIByteArray str2;
|
||||
str2.append('g');
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "AB Cg");
|
||||
PIString str1 = "AB C";
|
||||
PIByteArray str2;
|
||||
str2.append('g');
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "AB Cg");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_piByteArray_zero1){
|
||||
PIString str1 = "";
|
||||
PIByteArray str2;
|
||||
str2.append('0');
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "0");
|
||||
PIString str1 = "";
|
||||
PIByteArray str2;
|
||||
str2.append('0');
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "0");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_piByteArray_zero2){
|
||||
PIString str1 = "AB C";
|
||||
PIByteArray str2;
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "AB C");
|
||||
PIString str1 = "AB C";
|
||||
PIByteArray str2;
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "AB C");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_concatenation_piByteArray_zero_zero){
|
||||
PIString str1;
|
||||
PIByteArray str2;
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "");
|
||||
PIString str1;
|
||||
PIByteArray str2;
|
||||
str1 += str2;
|
||||
ASSERT_EQ(str1, "");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_pistring){
|
||||
PIString str1 = "New";
|
||||
ASSERT_EQ(str1, PIString("New"));
|
||||
PIString str1 = "New";
|
||||
PIString str(str1);
|
||||
|
||||
ASSERT_EQ(str1, str);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_pichar){
|
||||
PIChar str1 = 'n';
|
||||
PIString res = "n";
|
||||
ASSERT_EQ(res, PIString(str1));
|
||||
PIChar str1 = 'n';
|
||||
PIString res = "n";
|
||||
ASSERT_EQ(res, PIString(str1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_char){
|
||||
char str1 = 'n';
|
||||
PIString res = "n";
|
||||
ASSERT_EQ(res, PIString(str1));
|
||||
char str1 = 'n';
|
||||
PIString res = "n";
|
||||
ASSERT_EQ(res, PIString(str1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_chars){
|
||||
char str1[] = "mew";
|
||||
PIString res = "mew";
|
||||
ASSERT_EQ(res, PIString(str1));
|
||||
char str1[] = "mew";
|
||||
PIString res = "mew";
|
||||
ASSERT_EQ(res, PIString(str1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_wchar_t){
|
||||
wchar_t str1[] = L"gav";
|
||||
PIString res = "gav";
|
||||
ASSERT_EQ(res, PIString(str1));
|
||||
wchar_t str1[] = L"gav";
|
||||
PIString res = "gav";
|
||||
ASSERT_EQ(res, PIString(str1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_pibyte_array){
|
||||
PIByteArray str1;
|
||||
str1.append('m');
|
||||
PIString res = "m";
|
||||
ASSERT_EQ(res, PIString(str1));
|
||||
PIByteArray str1;
|
||||
str1.append('m');
|
||||
PIString res = "m";
|
||||
ASSERT_EQ(res, PIString(str1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_pichar_size){
|
||||
PIChar *str1 = new PIChar[3];
|
||||
str1[0] = 'n';
|
||||
str1[1] = 'e';
|
||||
str1[2] = 'w';
|
||||
PIString res = "new";
|
||||
ASSERT_EQ(res, PIString(str1, 3));
|
||||
PIChar *str1 = new PIChar[3];
|
||||
str1[0] = 'n';
|
||||
str1[1] = 'e';
|
||||
str1[2] = 'w';
|
||||
PIString res = "new";
|
||||
ASSERT_EQ(res, PIString(str1, 3));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_char_size){
|
||||
char str1[] = "good";
|
||||
PIString res = "good";
|
||||
ASSERT_EQ(res, PIString(str1, 4));
|
||||
char str1[] = "good";
|
||||
PIString res = "good";
|
||||
ASSERT_EQ(res, PIString(str1, 4));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_char_len){
|
||||
char str1 = 'n';
|
||||
PIString res = "nnn";
|
||||
ASSERT_EQ(res, PIString(3, str1));
|
||||
char str1 = 'n';
|
||||
PIString res = "nnn";
|
||||
ASSERT_EQ(res, PIString(3, str1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, construct_pichar_len){
|
||||
PIChar str1 = 'n';
|
||||
PIString res = "nnnnn";
|
||||
ASSERT_EQ(res, PIString(5, str1));
|
||||
PIChar str1 = 'n';
|
||||
PIString res = "nnnnn";
|
||||
ASSERT_EQ(res, PIString(5, str1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_symbol){
|
||||
PIString str1 = "testing";
|
||||
PIChar symbo = "i";
|
||||
ASSERT_EQ(symbo, str1[4]);
|
||||
PIString str1 = "testing";
|
||||
PIChar symbo = "i";
|
||||
ASSERT_EQ(symbo, str1[4]);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_compare_pistring_true){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str1 == str2);
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str1 == str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_compare_pistring_false){
|
||||
PIString str1 = "tes";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_FALSE(str1 == str2);
|
||||
PIString str1 = "tes";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_FALSE(str1 == str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_compare_pichar_true){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_TRUE(str1 == str2);
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_TRUE(str1 == str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_compare_pichar_false){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "p";
|
||||
ASSERT_FALSE(str1 == str2);
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "p";
|
||||
ASSERT_FALSE(str1 == str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_compare_char_true){
|
||||
PIString str1 = "test";
|
||||
char str2[] = "test";
|
||||
ASSERT_TRUE(str1 == str2);
|
||||
PIString str1 = "test";
|
||||
char str2[] = "test";
|
||||
ASSERT_TRUE(str1 == str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_compare_char_false){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "test";
|
||||
ASSERT_FALSE(str1 == str2);
|
||||
PIString str1 = "t";
|
||||
char str2[] = "test";
|
||||
ASSERT_FALSE(str1 == str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_encompare_pistring_false){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_FALSE(str1 != str2);
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_FALSE(str1 != str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_encompare_pistring_true){
|
||||
PIString str1 = "tes";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str1 != str2);
|
||||
PIString str1 = "tes";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str1 != str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_encompare_pichar_false){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_FALSE(str1 != str2);
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_FALSE(str1 != str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_encompare_pichar_true){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "p";
|
||||
ASSERT_TRUE(str1 != str2);
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "p";
|
||||
ASSERT_TRUE(str1 != str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_encompare_char_false){
|
||||
PIString str1 = "test";
|
||||
char str2[] = "test";
|
||||
ASSERT_FALSE(str1 != str2);
|
||||
PIString str1 = "test";
|
||||
char str2[] = "test";
|
||||
ASSERT_FALSE(str1 != str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_encompare_char_true){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "test";
|
||||
ASSERT_TRUE(str1 != str2);
|
||||
PIString str1 = "t";
|
||||
char str2[] = "test";
|
||||
ASSERT_TRUE(str1 != str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_pistring_true){
|
||||
PIString str1 = "testin";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str1 < str2);
|
||||
PIString str1 = "testin";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str1 < str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_pistring_false){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testin";
|
||||
ASSERT_FALSE(str1 < str2);
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testin";
|
||||
ASSERT_FALSE(str1 < str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_pistring_false_equal){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_FALSE(str1 < str2);
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_FALSE(str1 < str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_pichar_true){
|
||||
PIString str1 = "a";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_TRUE(str1 < str2);
|
||||
PIString str1 = "a";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_TRUE(str1 < str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_pichar_false){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "a";
|
||||
ASSERT_FALSE(str1 < str2);
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "a";
|
||||
ASSERT_FALSE(str1 < str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_pichar_false_equal){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_FALSE(str1 < str2);
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_FALSE(str1 < str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_char_true){
|
||||
PIString str1 = "a";
|
||||
char str2[] = "t";
|
||||
ASSERT_TRUE(str1 < str2);
|
||||
PIString str1 = "a";
|
||||
char str2[] = "t";
|
||||
ASSERT_TRUE(str1 < str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_char_false){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "a";
|
||||
ASSERT_FALSE(str1 < str2);
|
||||
PIString str1 = "t";
|
||||
char str2[] = "a";
|
||||
ASSERT_FALSE(str1 < str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_char_false_equal){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "t";
|
||||
ASSERT_FALSE(str1 < str2);
|
||||
PIString str1 = "t";
|
||||
char str2[] = "t";
|
||||
ASSERT_FALSE(str1 < str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_pistring_true){
|
||||
PIString str1 = "testin";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str2 > str1);
|
||||
PIString str1 = "testin";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str2 > str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_pistring_false){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testin";
|
||||
ASSERT_FALSE(str2 > str1);
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testin";
|
||||
ASSERT_FALSE(str2 > str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_pistring_false_equal){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_FALSE(str1 > str2);
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_FALSE(str1 > str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_pichar_true){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "a";
|
||||
ASSERT_TRUE(str1 > str2);
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "a";
|
||||
ASSERT_TRUE(str1 > str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_pichar_false){
|
||||
PIString str1 = "a";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_FALSE(str1 > str2);
|
||||
PIString str1 = "a";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_FALSE(str1 > str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_pichar_false_equal){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_FALSE(str1 > str2);
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_FALSE(str1 > str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_char_true){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "a";
|
||||
ASSERT_TRUE(str1 > str2);
|
||||
PIString str1 = "t";
|
||||
char str2[] = "a";
|
||||
ASSERT_TRUE(str1 > str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_char_false){
|
||||
PIString str1 = "a";
|
||||
char str2[] = "t";
|
||||
ASSERT_FALSE(str1 > str2);
|
||||
PIString str1 = "a";
|
||||
char str2[] = "t";
|
||||
ASSERT_FALSE(str1 > str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_char_false_equal){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "t";
|
||||
ASSERT_FALSE(str1 > str2);
|
||||
PIString str1 = "t";
|
||||
char str2[] = "t";
|
||||
ASSERT_FALSE(str1 > str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_eq_pistring_true){
|
||||
PIString str1 = "testin";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str1 <= str2);
|
||||
PIString str1 = "testin";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str1 <= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_eq_pistring_false){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testin";
|
||||
ASSERT_FALSE(str1 <= str2);
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testin";
|
||||
ASSERT_FALSE(str1 <= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_pistring_true_equal){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str1 <= str2);
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str1 <= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_eq_pichar_true){
|
||||
PIString str1 = "a";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_TRUE(str1 <= str2);
|
||||
PIString str1 = "a";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_TRUE(str1 <= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_eq_pichar_false){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "a";
|
||||
ASSERT_FALSE(str1 <= str2);
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "a";
|
||||
ASSERT_FALSE(str1 <= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_eq_pichar_true_equal){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_TRUE(str1 <= str2);
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_TRUE(str1 <= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_eq_char_true){
|
||||
PIString str1 = "a";
|
||||
char str2[] = "t";
|
||||
ASSERT_TRUE(str1 <= str2);
|
||||
PIString str1 = "a";
|
||||
char str2[] = "t";
|
||||
ASSERT_TRUE(str1 <= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_eq_char_false){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "a";
|
||||
ASSERT_FALSE(str1 <= str2);
|
||||
PIString str1 = "t";
|
||||
char str2[] = "a";
|
||||
ASSERT_FALSE(str1 <= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_less_eq_char_true_equal){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "t";
|
||||
ASSERT_TRUE(str1 <= str2);
|
||||
PIString str1 = "t";
|
||||
char str2[] = "t";
|
||||
ASSERT_TRUE(str1 <= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_eq_pistring_true){
|
||||
PIString str1 = "testin";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str2 >= str1);
|
||||
PIString str1 = "testin";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str2 >= str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_eq_pistring_false){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testin";
|
||||
ASSERT_FALSE(str2 >= str1);
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testin";
|
||||
ASSERT_FALSE(str2 >= str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_eq_pistring_true_equal){
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str1 >= str2);
|
||||
PIString str1 = "testing";
|
||||
PIString str2 = "testing";
|
||||
ASSERT_TRUE(str1 >= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_eq_pichar_true){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "a";
|
||||
ASSERT_TRUE(str1 >= str2);
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "a";
|
||||
ASSERT_TRUE(str1 >= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_eq_pichar_false){
|
||||
PIString str1 = "a";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_FALSE(str1 >= str2);
|
||||
PIString str1 = "a";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_FALSE(str1 >= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_eq_pichar_true_equal){
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_TRUE(str1 >= str2);
|
||||
PIString str1 = "t";
|
||||
PIChar str2 = "t";
|
||||
ASSERT_TRUE(str1 >= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_eq_char_true){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "a";
|
||||
ASSERT_TRUE(str1 >= str2);
|
||||
PIString str1 = "t";
|
||||
char str2[] = "a";
|
||||
ASSERT_TRUE(str1 >= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_eq_char_false){
|
||||
PIString str1 = "a";
|
||||
char str2[] = "t";
|
||||
ASSERT_FALSE(str1 >= str2);
|
||||
PIString str1 = "a";
|
||||
char str2[] = "t";
|
||||
ASSERT_FALSE(str1 >= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_more_eq_char_true_equal){
|
||||
PIString str1 = "t";
|
||||
char str2[] = "t";
|
||||
ASSERT_TRUE(str1 >= str2);
|
||||
PIString str1 = "t";
|
||||
char str2[] = "t";
|
||||
ASSERT_TRUE(str1 >= str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_pistring){
|
||||
PIString str1 = "shift";
|
||||
PIString str2 = " good";
|
||||
str1 << str2;
|
||||
PIString res = "shift good";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "shift";
|
||||
PIString str2 = " good";
|
||||
str1 << str2;
|
||||
PIString res = "shift good";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_pichar){
|
||||
PIString str1 = "shif";
|
||||
PIChar str2 = 't';
|
||||
str1 << str2;
|
||||
PIString res = "shift";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "shif";
|
||||
PIChar str2 = 't';
|
||||
str1 << str2;
|
||||
PIString res = "shift";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_char){
|
||||
PIString str1 = "shif";
|
||||
char str2[] = "t chat";
|
||||
str1 << str2;
|
||||
PIString res = "shift chat";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "shif";
|
||||
char str2[] = "t chat";
|
||||
str1 << str2;
|
||||
PIString res = "shift chat";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_wchar_t){
|
||||
PIString str1 = "shif";
|
||||
wchar_t str2[] = L"t cc";
|
||||
str1 << str2;
|
||||
PIString res = "shift cc";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "shif";
|
||||
wchar_t str2[] = L"t cc";
|
||||
str1 << str2;
|
||||
PIString res = "shift cc";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_int){
|
||||
PIString str1 = "shift ";
|
||||
int numb = -2147483648;
|
||||
str1 << numb;
|
||||
PIString res = "shift -2147483648";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "shift ";
|
||||
int numb = -2147483648;
|
||||
str1 << numb;
|
||||
PIString res = "shift -2147483648";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_uint){
|
||||
PIString str1 = "shift ";
|
||||
uint numb = 4294967295;
|
||||
str1 << numb;
|
||||
PIString res = "shift 4294967295";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "shift ";
|
||||
uint numb = 4294967295;
|
||||
str1 << numb;
|
||||
PIString res = "shift 4294967295";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_short){
|
||||
PIString str1 = "shift ";
|
||||
short numb = -32768;
|
||||
str1 << numb;
|
||||
PIString res = "shift -32768";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "shift ";
|
||||
short numb = -32768;
|
||||
str1 << numb;
|
||||
PIString res = "shift -32768";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_ushort){
|
||||
PIString str1 = "shift ";
|
||||
ushort numb = 65535;
|
||||
str1 << numb;
|
||||
PIString res = "shift 65535";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "shift ";
|
||||
ushort numb = 65535;
|
||||
str1 << numb;
|
||||
PIString res = "shift 65535";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_long){
|
||||
PIString str1 = "shift ";
|
||||
long numb = -2147483648;
|
||||
str1 << numb;
|
||||
PIString res = "shift -2147483648";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "shift ";
|
||||
long numb = -2147483648;
|
||||
str1 << numb;
|
||||
PIString res = "shift -2147483648";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_ulong){
|
||||
PIString str1 = "shift ";
|
||||
ulong numb = 4294967295;
|
||||
str1 << numb;
|
||||
PIString res = "shift 4294967295";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "shift ";
|
||||
ulong numb = 4294967295;
|
||||
str1 << numb;
|
||||
PIString res = "shift 4294967295";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_llong){
|
||||
PIString str1 = "shift ";
|
||||
llong numb = -9223372036854775807;
|
||||
str1 << numb;
|
||||
PIString res = "shift -9223372036854775807";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "shift ";
|
||||
llong numb = -9223372036854775807;
|
||||
str1 << numb;
|
||||
PIString res = "shift -9223372036854775807";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_ullong){
|
||||
PIString str1 = "shift ";
|
||||
ullong numb = 1844674407370955161;
|
||||
str1 << numb;
|
||||
PIString res = "shift 1844674407370955161";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "shift ";
|
||||
ullong numb = 1844674407370955161;
|
||||
str1 << numb;
|
||||
PIString res = "shift 1844674407370955161";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_float){
|
||||
PIString str1 = "shift ";
|
||||
float numb = -67.88999939;
|
||||
str1 << numb;
|
||||
PIString res = "shift -67.88999939";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "shift ";
|
||||
float numb = -67.88999939f;
|
||||
str1 << numb;
|
||||
PIString res = "shift -67.88999939";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_shift_double){
|
||||
PIString str1 = "shift ";
|
||||
double numb = 13.34300000;
|
||||
str1 << numb;
|
||||
PIString res = "shift 13.34300000";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "shift ";
|
||||
double numb = 13.34300000;
|
||||
str1 << numb;
|
||||
PIString res = "shift 13.34300000";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, prepend){
|
||||
PIString str1 = "idea";
|
||||
PIString str2 = "Good ";
|
||||
str1.prepend(str2);
|
||||
PIString res = "Good idea";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "idea";
|
||||
PIString str2 = "Good ";
|
||||
str1.prepend(str2);
|
||||
PIString res = "Good idea";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, append){
|
||||
PIString str1 = "Good";
|
||||
PIString str2 = " idea";
|
||||
str1.append(str2);
|
||||
PIString res = "Good idea";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "Good";
|
||||
PIString str2 = " idea";
|
||||
str1.append(str2);
|
||||
PIString res = "Good idea";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, mid){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "fo";
|
||||
ASSERT_EQ(res, str1.mid(10, 2));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "fo";
|
||||
ASSERT_EQ(res, str1.mid(10, 2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, mid_len_0){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.mid(10, 0));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.mid(10, 0));
|
||||
}
|
||||
|
||||
|
||||
TEST(PIString_Tests, mid_start_more){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.mid(1000, 0));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.mid(1000, 0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, mid_len_minus){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "for new project 144";
|
||||
ASSERT_EQ(res, str1.mid(10, -2));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "for new project 144";
|
||||
ASSERT_EQ(res, str1.mid(10, -2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, mid_len_more){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "for new project 144";
|
||||
ASSERT_EQ(res, str1.mid(10, 100));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "for new project 144";
|
||||
ASSERT_EQ(res, str1.mid(10, 100));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, subString){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "for new project 144";
|
||||
ASSERT_EQ(res, str1.mid(10, 46));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "for new project 144";
|
||||
ASSERT_EQ(res, str1.mid(10, 46));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, mid_minus){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good idea for new project 144";
|
||||
ASSERT_EQ(res, str1.mid(-10, 47));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good idea for new project 144";
|
||||
ASSERT_EQ(res, str1.mid(-10, 47));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, subString_minus){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Go";
|
||||
ASSERT_EQ(res, str1.mid(-10, 12));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Go";
|
||||
ASSERT_EQ(res, str1.mid(-10, 12));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, left){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Go";
|
||||
ASSERT_EQ(res, str1.left(2));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Go";
|
||||
ASSERT_EQ(res, str1.left(2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, left_minus){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.left(-2));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.left(-2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, right){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "44";
|
||||
ASSERT_EQ(res, str1.right(2));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "44";
|
||||
ASSERT_EQ(res, str1.right(2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, right_minus){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.right(-2));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.right(-2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, cutMid){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good for new project 144";
|
||||
ASSERT_EQ(res, str1.cutMid(5,5));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good for new project 144";
|
||||
ASSERT_EQ(res, str1.cutMid(5,5));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, cutMid_len_zero){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good idea for new project 144";
|
||||
ASSERT_EQ(res, str1.cutMid(5,0));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good idea for new project 144";
|
||||
ASSERT_EQ(res, str1.cutMid(5,0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, cutMid_len_min){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good ";
|
||||
ASSERT_EQ(res, str1.cutMid(5,-2));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good ";
|
||||
ASSERT_EQ(res, str1.cutMid(5,-2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, cutMid_minus){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "ood idea for new project 144";
|
||||
ASSERT_EQ(res, str1.cutMid(-5, 6));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "ood idea for new project 144";
|
||||
ASSERT_EQ(res, str1.cutMid(-5, 6));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, cutMid_zero){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good idea for new project 144";
|
||||
ASSERT_EQ(res, str1.cutMid(-5, 5));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good idea for new project 144";
|
||||
ASSERT_EQ(res, str1.cutMid(-5, 5));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, cutleft){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "od idea for new project 144";
|
||||
ASSERT_EQ(res, str1.cutLeft(2));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "od idea for new project 144";
|
||||
ASSERT_EQ(res, str1.cutLeft(2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, cutleft_minus){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good idea for new project 144";
|
||||
ASSERT_EQ(res, str1.cutLeft(-2));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good idea for new project 144";
|
||||
ASSERT_EQ(res, str1.cutLeft(-2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, cutright){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good idea for new project 1";
|
||||
ASSERT_EQ(res, str1.cutRight(2));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good idea for new project 1";
|
||||
ASSERT_EQ(res, str1.cutRight(2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, cutright_minus){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good idea for new project 144";
|
||||
ASSERT_EQ(res, str1.cutRight(-2));
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good idea for new project 144";
|
||||
ASSERT_EQ(res, str1.cutRight(-2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, trim){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = "Good idea for new project 144";
|
||||
ASSERT_EQ(res, str1.trim());
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = "Good idea for new project 144";
|
||||
ASSERT_EQ(res, str1.trim());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, trim_without){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good idea for new project 144";
|
||||
ASSERT_EQ(res, str1.trim());
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good idea for new project 144";
|
||||
ASSERT_EQ(res, str1.trim());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, trim_link){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString &str2 = str1.trim();
|
||||
str1 = "link";
|
||||
PIString res = "link";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString &str2 = str1.trim();
|
||||
str1 = "link";
|
||||
PIString res = "link";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, trimmed){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = "Good idea for new project 144";
|
||||
ASSERT_EQ(res, str1.trimmed());
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = "Good idea for new project 144";
|
||||
ASSERT_EQ(res, str1.trimmed());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, trimmed_without){
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good idea for new project 144";
|
||||
ASSERT_EQ(res, str1.trimmed());
|
||||
PIString str1 = "Good idea for new project 144";
|
||||
PIString res = "Good idea for new project 144";
|
||||
ASSERT_EQ(res, str1.trimmed());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = " Good thin for new project 144 ";
|
||||
ASSERT_EQ(res, str1.replace(6,4, "thin"));
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = " Good thin for new project 144 ";
|
||||
ASSERT_EQ(res, str1.replace(6,4, "thin"));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_more){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = " Good thin";
|
||||
ASSERT_EQ(res, str1.replace(6,100, "thin"));
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = " Good thin";
|
||||
ASSERT_EQ(res, str1.replace(6,100, "thin"));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_link){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString &str2 = str1.replace(6,4, "thin");
|
||||
str1 = "link";
|
||||
PIString res = "link";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString &str2 = str1.replace(6,4, "thin");
|
||||
str1 = "link";
|
||||
PIString res = "link";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_minus){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = "BAD idea for new project 144 ";
|
||||
ASSERT_EQ(res, str1.replace(0, 5, "BAD"));
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = "BAD idea for new project 144 ";
|
||||
ASSERT_EQ(res, str1.replace(0, 5, "BAD"));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_zero){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = "thin Good idea for new project 144 ";
|
||||
ASSERT_EQ(res, str1.replace(0, 0, "thin"));
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = "thin Good idea for new project 144 ";
|
||||
ASSERT_EQ(res, str1.replace(0, 0, "thin"));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_all){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = "BAD";
|
||||
ASSERT_EQ(res, str1.replaced(0, 100, "BAD"));
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = "BAD";
|
||||
ASSERT_EQ(res, str1.replaced(0, 100, "BAD"));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaced){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = " Good thin for new project 144 ";
|
||||
ASSERT_EQ(res, str1.replaced(6,4, "thin"));
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = " Good thin for new project 144 ";
|
||||
ASSERT_EQ(res, str1.replaced(6,4, "thin"));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaced_minus){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = "BAD idea for new project 144 ";
|
||||
ASSERT_EQ(res, str1.replaced(0, 5, "BAD"));
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = "BAD idea for new project 144 ";
|
||||
ASSERT_EQ(res, str1.replaced(0, 5, "BAD"));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaced_zero){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = "thin Good idea for new project 144 ";
|
||||
ASSERT_EQ(res, str1.replaced(0, 0, "thin"));
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = "thin Good idea for new project 144 ";
|
||||
ASSERT_EQ(res, str1.replaced(0, 0, "thin"));
|
||||
}
|
||||
|
||||
|
||||
TEST(PIString_Tests, replaced_all){
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = "thin";
|
||||
ASSERT_EQ(res, str1.replaced(0, 100, "thin"));
|
||||
PIString str1 = " Good idea for new project 144 ";
|
||||
PIString res = "thin";
|
||||
ASSERT_EQ(res, str1.replaced(0, 100, "thin"));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_str){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
str1.replace("Good", "bad", &ok);
|
||||
PIString res = " bad idea for new Good project 144 ";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
str1.replace("Good", "bad", &ok);
|
||||
PIString res = " bad idea for new Good project 144 ";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_str_link){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
PIString &str2 = str1.replace("Good", "bad", &ok);
|
||||
str1 = "link";
|
||||
PIString res = "link";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
PIString &str2 = str1.replace("Good", "bad", &ok);
|
||||
str1 = "link";
|
||||
PIString res = "link";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_str_zero){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
str1.replace("", "bad", &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
str1.replace("", "bad", &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_str_true){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
str1.replace("Good", "bad", &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
str1.replace("Good", "bad", &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replace_str_delete){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
str1.replace("Good", "", &ok);
|
||||
PIString res = " idea for new Good project 144 ";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
str1.replace("Good", "", &ok);
|
||||
PIString res = " idea for new Good project 144 ";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaced_str){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
PIString str2 = str1.replaced("Good", "bad", &ok);
|
||||
PIString res = " bad idea for new Good project 144 ";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
PIString str2 = str1.replaced("Good", "bad", &ok);
|
||||
PIString res = " bad idea for new Good project 144 ";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaced_str_zero){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
str1.replaced("", "bad", &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
str1.replaced("", "bad", &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaced_str_true){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
str1.replaced("Good", "bad", &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
str1.replaced("Good", "bad", &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaced_delete){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
PIString str2 = str1.replaced("Good", "", &ok);
|
||||
PIString res = " idea for new Good project 144 ";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
bool ok = 1;
|
||||
PIString str2 = str1.replaced("Good", "", &ok);
|
||||
PIString res = " idea for new Good project 144 ";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaceall){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
str1.replaceAll("Good", "bad");
|
||||
PIString res = " bad idea for new bad project 144 ";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
str1.replaceAll("Good", "bad");
|
||||
PIString res = " bad idea for new bad project 144 ";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaceall_no_find){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
str1.replaceAll("God", "bad");
|
||||
PIString res = " Good idea for new Good project 144 ";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
str1.replaceAll("God", "bad");
|
||||
PIString res = " Good idea for new Good project 144 ";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaceall_str){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
PIString str2 = str1.replaceAll("Good", "bad");
|
||||
PIString res = " bad idea for new bad project 144 ";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
PIString str2 = str1.replaceAll("Good", "bad");
|
||||
PIString res = " bad idea for new bad project 144 ";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaceall_str_no_find){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
PIString str2 = str1.replaceAll("God", "bad");
|
||||
PIString res = " Good idea for new Good project 144 ";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
PIString str2 = str1.replaceAll("God", "bad");
|
||||
PIString res = " Good idea for new Good project 144 ";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaceall_link){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
PIString &str2 = str1.replaceAll("Good", "bad");
|
||||
PIString res = " bad idea for new bad project 144 ";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
PIString &str2 = str1.replaceAll("Good", "bad");
|
||||
PIString res = " bad idea for new bad project 144 ";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, replaceall_link_change){
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
PIString &str2 = str1.replaceAll("Good", "bad");
|
||||
str1 = "link";
|
||||
PIString res = "link";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " Good idea for new Good project 144 ";
|
||||
PIString &str2 = str1.replaceAll("Good", "bad");
|
||||
str1 = "link";
|
||||
PIString res = "link";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, repeat){
|
||||
PIString str1 = "string ";
|
||||
PIString str2 = str1.repeat(6);
|
||||
PIString res = "string string string string string string ";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "string ";
|
||||
PIString str2 = str1.repeat(6);
|
||||
PIString res = "string string string string string string ";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, repeat_zero){
|
||||
PIString str1 = "string ";
|
||||
PIString str2 = str1.repeat(0);
|
||||
PIString res = "string ";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "string ";
|
||||
PIString str2 = str1.repeat(0);
|
||||
PIString res = "string ";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, repeat_link){
|
||||
PIString str1 = "string ";
|
||||
PIString &str2 = str1.repeat(6);
|
||||
str1 = "link";
|
||||
PIString res = "link";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "string ";
|
||||
PIString &str2 = str1.repeat(6);
|
||||
str1 = "link";
|
||||
PIString res = "link";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, repeated){
|
||||
PIString str1 = "string ";
|
||||
str1.repeat(6);
|
||||
PIString res = "string string string string string string ";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "string ";
|
||||
str1.repeat(6);
|
||||
PIString res = "string string string string string string ";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, repeated_zero){
|
||||
PIString str1 = "string ";
|
||||
str1.repeat(0);
|
||||
PIString res = "string ";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "string ";
|
||||
str1.repeat(0);
|
||||
PIString res = "string ";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, insert_char){
|
||||
PIString str1 = "strng ";
|
||||
char sym = 'i';
|
||||
str1.insert(3, sym);
|
||||
PIString res = "string ";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "strng ";
|
||||
char sym = 'i';
|
||||
str1.insert(3, sym);
|
||||
PIString res = "string ";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, insert_pichar){
|
||||
PIString str1 = "strng ";
|
||||
PIChar sym = 'i';
|
||||
str1.insert(3, sym);
|
||||
PIString res = "string ";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "strng ";
|
||||
PIChar sym = 'i';
|
||||
str1.insert(3, sym);
|
||||
PIString res = "string ";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, insert_pistring){
|
||||
PIString str1 = "string out";
|
||||
PIString str2 = " go";
|
||||
str1.insert(6, str2);
|
||||
PIString res = "string go out";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "string out";
|
||||
PIString str2 = " go";
|
||||
str1.insert(6, str2);
|
||||
PIString res = "string go out";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, insert_chars){
|
||||
PIString str1 = "see boy";
|
||||
char str2[] = " big";
|
||||
str1.insert(3, str2);
|
||||
PIString res = "see big boy";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "see boy";
|
||||
char str2[] = " big";
|
||||
str1.insert(3, str2);
|
||||
PIString res = "see big boy";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, expandRightTo){
|
||||
PIString str1 = "see boy ";
|
||||
PIChar symbol = "x";
|
||||
str1.expandRightTo(11, symbol);
|
||||
PIString res = "see boy xxx";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "see boy ";
|
||||
PIChar symbol = "x";
|
||||
str1.expandRightTo(11, symbol);
|
||||
PIString res = "see boy xxx";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, expandRightTo_null){
|
||||
PIString str1 = "see boy ";
|
||||
PIChar symbol = "x";
|
||||
str1.expandRightTo(0, symbol);
|
||||
PIString res = "see boy ";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "see boy ";
|
||||
PIChar symbol = "x";
|
||||
str1.expandRightTo(0, symbol);
|
||||
PIString res = "see boy ";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, expandLeftTo){
|
||||
PIString str1 = " see boy";
|
||||
PIChar symbol = "x";
|
||||
str1.expandLeftTo(11, symbol);
|
||||
PIString res = "xxx see boy";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " see boy";
|
||||
PIChar symbol = "x";
|
||||
str1.expandLeftTo(11, symbol);
|
||||
PIString res = "xxx see boy";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, expandLeftTo_null){
|
||||
PIString str1 = "see boy ";
|
||||
PIChar symbol = "x";
|
||||
str1.expandLeftTo(0, symbol);
|
||||
PIString res = "see boy ";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "see boy ";
|
||||
PIChar symbol = "x";
|
||||
str1.expandLeftTo(0, symbol);
|
||||
PIString res = "see boy ";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, quote){
|
||||
PIString str1 = "see boy";
|
||||
PIChar symbol = " ";
|
||||
str1.quote(symbol);
|
||||
PIString res = " see boy ";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "see boy";
|
||||
PIChar symbol = " ";
|
||||
str1.quote(symbol);
|
||||
PIString res = " see boy ";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, quote_link){
|
||||
PIString str1 = "see boy";
|
||||
PIChar symbol = " ";
|
||||
PIString &str2 = str1.quote(symbol);
|
||||
str1 = "link";
|
||||
PIString res = "link";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "see boy";
|
||||
PIChar symbol = " ";
|
||||
PIString &str2 = str1.quote(symbol);
|
||||
str1 = "link";
|
||||
PIString res = "link";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, quoted){
|
||||
PIString str1 = "see boy";
|
||||
PIChar symbol = " ";
|
||||
PIString str2 = str1.quoted(symbol);
|
||||
PIString res = " see boy ";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "see boy";
|
||||
PIChar symbol = " ";
|
||||
PIString str2 = str1.quoted(symbol);
|
||||
PIString res = " see boy ";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, reverse){
|
||||
PIString str1 = "see boy";
|
||||
PIString &str2 = str1.reverse();
|
||||
PIString res = "yob ees";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "see boy";
|
||||
PIString &str2 = str1.reverse();
|
||||
PIString res = "yob ees";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, reverse_link){
|
||||
PIString str1 = "see boy";
|
||||
PIString &str2 = str1.reverse();
|
||||
str1 = "yes";
|
||||
PIString res = "yes";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "see boy";
|
||||
PIString &str2 = str1.reverse();
|
||||
str1 = "yes";
|
||||
PIString res = "yes";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, reversed){
|
||||
PIString str1 = "see boy";
|
||||
PIString str2 = str1.reversed();
|
||||
PIString res = "yob ees";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "see boy";
|
||||
PIString str2 = str1.reversed();
|
||||
PIString res = "yob ees";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, elide){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString &str2 = str1.elide(8, 1);
|
||||
PIString res = "BMSTU ..";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString &str2 = str1.elide(8, 1);
|
||||
PIString res = "BMSTU ..";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, elide_small){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString &str2 = str1.elide(2, 1);
|
||||
PIString res = "..";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString &str2 = str1.elide(2, 1);
|
||||
PIString res = "..";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, elide_all){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString &str2 = str1.elide(100, 1);
|
||||
PIString res = "BMSTU is best university in space";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString &str2 = str1.elide(100, 1);
|
||||
PIString res = "BMSTU is best university in space";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, elide_link){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString &str2 = str1.elide(8, 1);
|
||||
str1 = "space";
|
||||
PIString res = "space";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString &str2 = str1.elide(8, 1);
|
||||
str1 = "space";
|
||||
PIString res = "space";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, elided){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.elided(8, 1);
|
||||
PIString res = "BMSTU ..";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.elided(8, 1);
|
||||
PIString res = "BMSTU ..";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takemid){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeMid(9, 4);
|
||||
PIString res = "best";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeMid(9, 4);
|
||||
PIString res = "best";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takeleft){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeLeft(5);
|
||||
PIString res = "BMSTU";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeLeft(5);
|
||||
PIString res = "BMSTU";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takeright){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeRight(5);
|
||||
PIString res = "space";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeRight(5);
|
||||
PIString res = "space";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takesymbol){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeSymbol();
|
||||
PIString res = "B";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeSymbol();
|
||||
PIString res = "B";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takesymbol_with_rubbish){
|
||||
PIString str1 = " \t \n \r BMSTU is best university in space";
|
||||
PIString str2 = str1.takeSymbol();
|
||||
PIString res = "B";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " \t \n \r BMSTU is best university in space";
|
||||
PIString str2 = str1.takeSymbol();
|
||||
PIString res = "B";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takesymbol_without){
|
||||
PIString str1 = " \t \n \r ";
|
||||
PIString str2 = str1.takeSymbol();
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " \t \n \r ";
|
||||
PIString str2 = str1.takeSymbol();
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takeword){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeWord();
|
||||
PIString res = "BMSTU";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeWord();
|
||||
PIString res = "BMSTU";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takeword_space){
|
||||
PIString str1 = " \r\n\tBMSTU is best university in space";
|
||||
PIString str2 = str1.takeWord();
|
||||
PIString res = "BMSTU";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " \r\n\tBMSTU is best university in space";
|
||||
PIString str2 = str1.takeWord();
|
||||
PIString res = "BMSTU";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takeword_without_word){
|
||||
PIString str1 = " \r\n\t";
|
||||
PIString str2 = str1.takeWord();
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " \r\n\t";
|
||||
PIString str2 = str1.takeWord();
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takecword){
|
||||
PIString str1 = "_6 BMSTU is best university in space";
|
||||
PIString str2 = str1.takeCWord();
|
||||
PIString res = "_6";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "_6 BMSTU is best university in space";
|
||||
PIString str2 = str1.takeCWord();
|
||||
PIString res = "_6";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takecword_space){
|
||||
PIString str1 = " \t\r\n_6 BMSTU is best university in space";
|
||||
PIString str2 = str1.takeCWord();
|
||||
PIString res = "_6";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " \t\r\n_6 BMSTU is best university in space";
|
||||
PIString str2 = str1.takeCWord();
|
||||
PIString res = "_6";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takecword_space_w){
|
||||
PIString str1 = " \t\r\n BMSTU is best university in space";
|
||||
PIString str2 = str1.takeCWord();
|
||||
PIString res = "BMSTU";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " \t\r\n BMSTU is best university in space";
|
||||
PIString str2 = str1.takeCWord();
|
||||
PIString res = "BMSTU";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takecword_not_cword){
|
||||
PIString str1 = " \t\r\n ";
|
||||
PIString str2 = str1.takeCWord();
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " \t\r\n ";
|
||||
PIString str2 = str1.takeCWord();
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takeline){
|
||||
PIString str1 = "BMSTU is best\n university in space";
|
||||
PIString str2 = str1.takeLine();
|
||||
PIString res = "BMSTU is best";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "BMSTU is best\n university in space";
|
||||
PIString str2 = str1.takeLine();
|
||||
PIString res = "BMSTU is best";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takeline_without){
|
||||
PIString str1 = "BMSTU is best";
|
||||
PIString str2 = str1.takeLine();
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "BMSTU is best";
|
||||
PIString str2 = str1.takeLine();
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takeline_first){
|
||||
PIString str1 = "\nBMSTU is best";
|
||||
PIString str2 = str1.takeLine();
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "\nBMSTU is best";
|
||||
PIString str2 = str1.takeLine();
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takenumber){
|
||||
PIString str1 = "6.6";
|
||||
PIString str2 = str1.takeNumber();
|
||||
PIString res = "6.6";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "6.6";
|
||||
PIString str2 = str1.takeNumber();
|
||||
PIString res = "6.6";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takenumber_sign){
|
||||
PIString str1 = "-66";
|
||||
PIString str2 = str1.takeNumber();
|
||||
PIString res = "-66";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "-66";
|
||||
PIString str2 = str1.takeNumber();
|
||||
PIString res = "-66";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takenumber_suffix){
|
||||
PIString str1 = "66L";
|
||||
PIString str2 = str1.takeNumber();
|
||||
PIString res = "66L";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "66L";
|
||||
PIString str2 = str1.takeNumber();
|
||||
PIString res = "66L";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takerange){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeRange('B', 'i', ' ');
|
||||
PIString res = "MSTU is best un";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeRange('B', 'i', ' ');
|
||||
PIString res = "MSTU is best un";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takerange_without_shield){
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeRange('B', 'i');
|
||||
PIString res = "MSTU ";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "BMSTU is best university in space";
|
||||
PIString str2 = str1.takeRange('B', 'i');
|
||||
PIString res = "MSTU ";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takerange_space){
|
||||
PIString str1 = " \t\r\nBMSTU is best university in space";
|
||||
PIString str2 = str1.takeRange('B', 'i', ' ');
|
||||
PIString res = "MSTU is best un";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " \t\r\nBMSTU is best university in space";
|
||||
PIString str2 = str1.takeRange('B', 'i', ' ');
|
||||
PIString res = "MSTU is best un";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, takerange_without_shield_space){
|
||||
PIString str1 = " \t\r\nBMSTU is best university in space";
|
||||
PIString str2 = str1.takeRange('B', 'i');
|
||||
PIString res = "MSTU ";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " \t\r\nBMSTU is best university in space";
|
||||
PIString str2 = str1.takeRange('B', 'i');
|
||||
PIString res = "MSTU ";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, inBrackets){
|
||||
PIString str1 = "BMSTU is (best) university in space";
|
||||
PIString str2 = str1.inBrackets('(', ')');
|
||||
PIString res = "best";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "BMSTU is (best) university in space";
|
||||
PIString str2 = str1.inBrackets('(', ')');
|
||||
PIString res = "best";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, inBrackets_end_start){
|
||||
PIString str1 = "BMSTU )is (best) university in space";
|
||||
PIString str2 = str1.inBrackets('(', ')');
|
||||
PIString res = "best";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "BMSTU )is (best) university in space";
|
||||
PIString str2 = str1.inBrackets('(', ')');
|
||||
PIString res = "best";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, inBrackets_without){
|
||||
PIString str1 = "BMSTU )is (best) university in space";
|
||||
PIString str2 = str1.inBrackets('0', '1');
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "BMSTU )is (best) university in space";
|
||||
PIString str2 = str1.inBrackets('0', '1');
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, lenghtascii){
|
||||
PIString str1 = "BMSTU is (best) university in space";
|
||||
int size = str1.lengthAscii();
|
||||
ASSERT_EQ(35, size);
|
||||
PIString str1 = "BMSTU is (best) university in space";
|
||||
int size = str1.lengthAscii();
|
||||
ASSERT_EQ(35, size);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, data){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
const char *data = str1.data();
|
||||
PIString res = "BMSTU is (best) university in space\n";
|
||||
ASSERT_EQ(res, data);
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
const char *data = str1.data();
|
||||
PIString res = "BMSTU is (best) university in space\n";
|
||||
ASSERT_EQ(res, data);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, dataconsole){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
const char *data = str1.dataConsole();
|
||||
PIString res = "BMSTU is (best) university in space\n";
|
||||
ASSERT_EQ(res, data);
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
const char *data = str1.dataConsole();
|
||||
PIString res = "BMSTU is (best) university in space\n";
|
||||
ASSERT_EQ(res, data);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, dataUTF8){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
const char *data = str1.dataUTF8();
|
||||
PIString res = "BMSTU is (best) university in space\n";
|
||||
ASSERT_EQ(res, data);
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
const char *data = str1.dataUTF8();
|
||||
PIString res = "BMSTU is (best) university in space\n";
|
||||
ASSERT_EQ(res, data);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, dataAScii){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
const char *data = str1.dataAscii();
|
||||
PIString res = "BMSTU is (best) university in space\n";
|
||||
ASSERT_EQ(res, data);
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
const char *data = str1.dataAscii();
|
||||
PIString res = "BMSTU is (best) university in space\n";
|
||||
ASSERT_EQ(res, data);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, hash){
|
||||
const PIString str1 = "B";
|
||||
uint h = str1.hash();
|
||||
ASSERT_EQ(3912571919, h);
|
||||
const PIString str1 = "B";
|
||||
uint h = str1.hash();
|
||||
ASSERT_EQ(3912571919, h);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, toByteArray){
|
||||
const PIString str1 = "C";
|
||||
PIByteArray h = str1.toByteArray();
|
||||
ASSERT_EQ(67, h.at(0));
|
||||
const PIString str1 = "C";
|
||||
PIByteArray h = str1.toByteArray();
|
||||
ASSERT_EQ(67, h.at(0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, toUTF8){
|
||||
const PIString str1 = "C";
|
||||
PIByteArray h = str1.toUTF8();
|
||||
ASSERT_EQ(67, h.at(0));
|
||||
const PIString str1 = "C";
|
||||
PIByteArray h = str1.toUTF8();
|
||||
ASSERT_EQ(67, h.at(0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, tocharset){
|
||||
const PIString str1 = "B";
|
||||
PIByteArray h = str1.toCharset("c");
|
||||
ASSERT_EQ(66, h.at(0));
|
||||
const PIString str1 = "B";
|
||||
PIByteArray h = str1.toCharset("c");
|
||||
ASSERT_EQ(66, h.at(0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, toUTF8_empty){
|
||||
PIString str1;
|
||||
str1.toUTF8();
|
||||
ASSERT_EQ(0, str1.size());
|
||||
PIString str1;
|
||||
str1.toUTF8();
|
||||
ASSERT_EQ(NULL, str1.size());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, tocharset_empty){
|
||||
PIString str1 = "";
|
||||
str1.toCharset("c");
|
||||
ASSERT_EQ(0, str1.size());
|
||||
PIString str1 = "";
|
||||
str1.toCharset("c");
|
||||
ASSERT_EQ(NULL, str1.size());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, split){
|
||||
PIString str1 = " mirrow best mirrow ";
|
||||
PIStringList list = str1.split("best");
|
||||
PIString str1 = " mirrow best mirrow ";
|
||||
PIStringList list = str1.split("best");
|
||||
|
||||
ASSERT_EQ(list[1], list[0]);
|
||||
ASSERT_EQ(list[1], list[0]);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, split_sec){
|
||||
PIString str1 = " mirrow best detail ";
|
||||
PIStringList list = str1.split("best");
|
||||
PIString res = " mirrow ";
|
||||
PIString res2 = " detail ";
|
||||
ASSERT_EQ(res, list[0]);
|
||||
ASSERT_EQ(list[1], res2);
|
||||
PIString str1 = " mirrow best detail ";
|
||||
PIStringList list = str1.split("best");
|
||||
PIString res = " mirrow ";
|
||||
PIString res2 = " detail ";
|
||||
ASSERT_EQ(res, list[0]);
|
||||
ASSERT_EQ(list[1], res2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, split_empty){
|
||||
PIString str1 = "";
|
||||
PIStringList list = str1.split("best");
|
||||
ASSERT_EQ(0, list.size());
|
||||
PIString str1 = "";
|
||||
PIStringList list = str1.split("best");
|
||||
ASSERT_EQ(NULL, list.size());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, split_empty_delim){
|
||||
PIString str1 = " mirrow best mirrow ";
|
||||
PIStringList list = str1.split("");
|
||||
ASSERT_EQ(0, list.size());
|
||||
PIString str1 = " mirrow best mirrow ";
|
||||
PIStringList list = str1.split("");
|
||||
ASSERT_EQ(NULL, list.size());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, split_not_delim){
|
||||
PIString str1 = " mirrow best mirrow ";
|
||||
PIStringList list = str1.split("tr");
|
||||
ASSERT_EQ(list[0], " mirrow best mirrow ");
|
||||
PIString str1 = " mirrow best mirrow ";
|
||||
PIStringList list = str1.split("tr");
|
||||
ASSERT_EQ(list[0], " mirrow best mirrow ");
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, toUpperCase){
|
||||
PIString str1 = " miRrow ";
|
||||
PIString str2 = str1.toUpperCase();
|
||||
PIString res = " MIRROW ";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " miRrow ";
|
||||
PIString str2 = str1.toUpperCase();
|
||||
PIString res = " MIRROW ";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, toLowerCase){
|
||||
PIString str1 = " MIrROW ";
|
||||
PIString str2 = str1.toLowerCase();
|
||||
PIString res = " mirrow ";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = " MIrROW ";
|
||||
PIString str2 = str1.toLowerCase();
|
||||
PIString res = " mirrow ";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, toNativeDecimalPoints){
|
||||
PIString str1 = "4546,878";
|
||||
PIString str2 = str1.toNativeDecimalPoints();
|
||||
PIString res = "4546.878";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "4546,878";
|
||||
PIString str2 = str1.toNativeDecimalPoints();
|
||||
PIString res = "4546.878";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, contains_char){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = '\n';
|
||||
ASSERT_TRUE(str1.contains(s));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = '\n';
|
||||
ASSERT_TRUE(str1.contains(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, contains_char_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = '0';
|
||||
ASSERT_FALSE(str1.contains(s));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = '0';
|
||||
ASSERT_FALSE(str1.contains(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, contains_picahr){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIChar s = 'i';
|
||||
ASSERT_TRUE(str1.contains(s));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIChar s = 'i';
|
||||
ASSERT_TRUE(str1.contains(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, contains_pichar_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIChar s = '0';
|
||||
ASSERT_FALSE(str1.contains(s));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIChar s = '0';
|
||||
ASSERT_FALSE(str1.contains(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, contains_cahrs){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s[] = "BMSTU";
|
||||
ASSERT_TRUE(str1.contains(s));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s[] = "BMSTU";
|
||||
ASSERT_TRUE(str1.contains(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, contains_chars_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s[] = "out";
|
||||
ASSERT_FALSE(str1.contains(s));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s[] = "out";
|
||||
ASSERT_FALSE(str1.contains(s));
|
||||
}
|
||||
|
||||
|
||||
TEST(PIString_Tests, contains_pistring){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString s = "univer";
|
||||
ASSERT_TRUE(str1.contains(s));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString s = "univer";
|
||||
ASSERT_TRUE(str1.contains(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, contains_pistring_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString s = "new";
|
||||
ASSERT_FALSE(str1.contains(s));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString s = "new";
|
||||
ASSERT_FALSE(str1.contains(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_char){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = 'i';
|
||||
ASSERT_EQ(6, str1.find(s));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = 'i';
|
||||
ASSERT_EQ(6, str1.find(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_char_start){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = 'i';
|
||||
ASSERT_EQ(18, str1.find(s, 7));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = 'i';
|
||||
ASSERT_EQ(18, str1.find(s, 7));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_char_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = 'o';
|
||||
ASSERT_EQ(-1, str1.find(s));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = 'o';
|
||||
ASSERT_EQ(-1, str1.find(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_chars){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char str2[] = "is";
|
||||
ASSERT_EQ(6, str1.find(str2));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char str2[] = "is";
|
||||
ASSERT_EQ(6, str1.find(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_chars_start){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char str2[] = "iv";
|
||||
ASSERT_EQ(18, str1.find(str2, 7));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char str2[] = "iv";
|
||||
ASSERT_EQ(18, str1.find(str2, 7));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_chars_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s[] = "ouc";
|
||||
ASSERT_EQ(-1, str1.find(s));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s[] = "ouc";
|
||||
ASSERT_EQ(-1, str1.find(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_pistring){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString str2 = "is";
|
||||
ASSERT_EQ(6, str1.find(str2));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString str2 = "is";
|
||||
ASSERT_EQ(6, str1.find(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_pistring_start){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString str2 = "iv";
|
||||
ASSERT_EQ(18, str1.find(str2, 7));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString str2 = "iv";
|
||||
ASSERT_EQ(18, str1.find(str2, 7));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_pistring_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString str2 = "ouc";
|
||||
ASSERT_EQ(-1, str1.find(str2));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString str2 = "ouc";
|
||||
ASSERT_EQ(-1, str1.find(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_last_char){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = 'i';
|
||||
ASSERT_EQ(27, str1.findLast(s));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = 'i';
|
||||
ASSERT_EQ(27, str1.findLast(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_last_char_start){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = 'i';
|
||||
ASSERT_EQ(27, str1.findLast(s, 20));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = 'i';
|
||||
ASSERT_EQ(27, str1.findLast(s, 20));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_last_char_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = 'o';
|
||||
ASSERT_EQ(-1, str1.findLast(s));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char s = 'o';
|
||||
ASSERT_EQ(-1, str1.findLast(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_last_chars){
|
||||
PIString str1 = "BMSTU is (best) university in is space\n";
|
||||
char str2[] = "is";
|
||||
ASSERT_EQ(30, str1.findLast(str2));
|
||||
PIString str1 = "BMSTU is (best) university in is space\n";
|
||||
char str2[] = "is";
|
||||
ASSERT_EQ(30, str1.findLast(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_last_chars_start){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
char str2[] = "iv";
|
||||
ASSERT_EQ(30, str1.findLast(str2, 25));
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
char str2[] = "iv";
|
||||
ASSERT_EQ(30, str1.findLast(str2, 25));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_last_chars_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char str2[] = "ouc";
|
||||
ASSERT_EQ(-1, str1.findLast(str2));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
char str2[] = "ouc";
|
||||
ASSERT_EQ(-1, str1.findLast(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_last_pistring){
|
||||
PIString str1 = "BMSTU is (best) university in is space\n";
|
||||
PIString str2 = "is";
|
||||
ASSERT_EQ(30, str1.findLast(str2));
|
||||
PIString str1 = "BMSTU is (best) university in is space\n";
|
||||
PIString str2 = "is";
|
||||
ASSERT_EQ(30, str1.findLast(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_last_pistring_start){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "iv";
|
||||
ASSERT_EQ(30, str1.findLast(str2, 10));
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "iv";
|
||||
ASSERT_EQ(30, str1.findLast(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_last_pistring_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString str2 = "ouc";
|
||||
ASSERT_EQ(-1, str1.findLast(str2));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString str2 = "ouc";
|
||||
ASSERT_EQ(-1, str1.findLast(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_word){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "university";
|
||||
ASSERT_EQ(16, str1.findWord(str2));
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "university";
|
||||
ASSERT_EQ(16, str1.findWord(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_word_start){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "university";
|
||||
ASSERT_EQ(16, str1.findWord(str2, 10));
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "university";
|
||||
ASSERT_EQ(16, str1.findWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_word_space_before){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = " university";
|
||||
ASSERT_EQ(-1, str1.findWord(str2, 10));
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = " university";
|
||||
ASSERT_EQ(-1, str1.findWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_word_space_after){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "university ";
|
||||
ASSERT_EQ(-1, str1.findWord(str2, 10));
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "university ";
|
||||
ASSERT_EQ(-1, str1.findWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_word_digit_before){
|
||||
PIString str1 = "BMSTU is (best) _university_ in iv space\n";
|
||||
PIString str2 = "_university";
|
||||
ASSERT_EQ(-1, str1.findWord(str2, 10));
|
||||
PIString str1 = "BMSTU is (best) _university_ in iv space\n";
|
||||
PIString str2 = "_university";
|
||||
ASSERT_EQ(-1, str1.findWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_word_digit_after){
|
||||
PIString str1 = "BMSTU is (best) _university_ in iv space\n";
|
||||
PIString str2 = "university_";
|
||||
ASSERT_EQ(-1, str1.findWord(str2, 10));
|
||||
PIString str1 = "BMSTU is (best) _university_ in iv space\n";
|
||||
PIString str2 = "university_";
|
||||
ASSERT_EQ(-1, str1.findWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_word_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString str2 = "university";
|
||||
ASSERT_EQ(-1, str1.findWord(str2, 37));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString str2 = "university";
|
||||
ASSERT_EQ(-1, str1.findWord(str2, 37));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_cword){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "university";
|
||||
ASSERT_EQ(16, str1.findCWord(str2));
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "university";
|
||||
ASSERT_EQ(16, str1.findCWord(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_cword_start){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "university";
|
||||
ASSERT_EQ(16, str1.findCWord(str2, 10));
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "university";
|
||||
ASSERT_EQ(16, str1.findCWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_cword_space_before){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = " university";
|
||||
ASSERT_EQ(15, str1.findCWord(str2, 10));
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = " university";
|
||||
ASSERT_EQ(15, str1.findCWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_cword_space_after){
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "university ";
|
||||
ASSERT_EQ(-1, str1.findCWord(str2, 10));
|
||||
PIString str1 = "BMSTU is (best) university in iv space\n";
|
||||
PIString str2 = "university ";
|
||||
ASSERT_EQ(-1, str1.findCWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_cword_digit_before){
|
||||
PIString str1 = "BMSTU is (best) _university_ in iv space\n";
|
||||
PIString str2 = "_university";
|
||||
ASSERT_EQ(-1, str1.findCWord(str2, 10));
|
||||
PIString str1 = "BMSTU is (best) _university_ in iv space\n";
|
||||
PIString str2 = "_university";
|
||||
ASSERT_EQ(-1, str1.findCWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_cword_digit_after){
|
||||
PIString str1 = "BMSTU is (best) _university_ in iv space\n";
|
||||
PIString str2 = "university_";
|
||||
ASSERT_EQ(-1, str1.findCWord(str2, 10));
|
||||
PIString str1 = "BMSTU is (best) _university_ in iv space\n";
|
||||
PIString str2 = "university_";
|
||||
ASSERT_EQ(-1, str1.findCWord(str2, 10));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_cword_false){
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString str2 = "university";
|
||||
ASSERT_EQ(-1, str1.findCWord(str2, 37));
|
||||
PIString str1 = "BMSTU is (best) university in space\n";
|
||||
PIString str2 = "university";
|
||||
ASSERT_EQ(-1, str1.findCWord(str2, 37));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_range){
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
PIChar start = "v";
|
||||
PIChar end = "g";
|
||||
ASSERT_EQ(3, str1.findRange(start, end, "n", 1));
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
PIChar start = "v";
|
||||
PIChar end = "g";
|
||||
ASSERT_EQ(3, str1.findRange(start, end, "n", 1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_range_len){
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
PIChar start = "v";
|
||||
PIChar end = "g";
|
||||
int len;
|
||||
str1.findRange(start, end, "n", 1, &len);
|
||||
ASSERT_EQ(14, len);
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
PIChar start = "v";
|
||||
PIChar end = "g";
|
||||
int len;
|
||||
str1.findRange(start, end, "n", 1, &len);
|
||||
ASSERT_EQ(14, len);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_range_len_without_shield){
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
PIChar start = "v";
|
||||
PIChar end = "g";
|
||||
int len;
|
||||
str1.findRange(start, end, "/", 1, &len);
|
||||
ASSERT_EQ(9, len);
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
PIChar start = "v";
|
||||
PIChar end = "g";
|
||||
int len;
|
||||
str1.findRange(start, end, "/", 1, &len);
|
||||
ASSERT_EQ(9, len);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_range_start){
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
PIChar start = "g";
|
||||
PIChar end = "o";
|
||||
int len;
|
||||
str1.findRange(start, end, " ", 17, &len);
|
||||
ASSERT_EQ(9, len);
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
PIChar start = "g";
|
||||
PIChar end = "o";
|
||||
int len;
|
||||
str1.findRange(start, end, " ", 17, &len);
|
||||
ASSERT_EQ(9, len);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_range_eq){
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
PIChar start = "v";
|
||||
PIChar end = "v";
|
||||
int len;
|
||||
str1.findRange(start, end, "n", 1, &len);
|
||||
ASSERT_EQ(0, len);
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
PIChar start = "v";
|
||||
PIChar end = "v";
|
||||
int len;
|
||||
str1.findRange(start, end, "n", 1, &len);
|
||||
ASSERT_EQ(NULL, len);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_range_trim){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIChar start = "A";
|
||||
PIChar end = "v";
|
||||
int len;
|
||||
ASSERT_EQ(2, str1.findRange(start, end, "n", 0, &len));
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIChar start = "A";
|
||||
PIChar end = "v";
|
||||
int len;
|
||||
ASSERT_EQ(2, str1.findRange(start, end, "n", 0, &len));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "doip";
|
||||
ASSERT_EQ(11, str1.findAny(str2, 0));
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "doip";
|
||||
ASSERT_EQ(11, str1.findAny(str2, 0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_not){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "q";
|
||||
ASSERT_EQ(-1, str1.findAny(str2, 0));
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "q";
|
||||
ASSERT_EQ(-1, str1.findAny(str2, 0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_start){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "doip";
|
||||
ASSERT_EQ(15, str1.findAny(str2, 12));
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "doip";
|
||||
ASSERT_EQ(15, str1.findAny(str2, 12));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_chars){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char str2[] = "doip";
|
||||
ASSERT_EQ(11, str1.findAny(str2, 0));
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char str2[] = "doip";
|
||||
ASSERT_EQ(11, str1.findAny(str2, 0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_chars_not){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char str2[] = "q";
|
||||
ASSERT_EQ(-1, str1.findAny(str2, 0));
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char str2[] = "q";
|
||||
ASSERT_EQ(-1, str1.findAny(str2, 0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_chars_start){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char str2[] = "doip";
|
||||
ASSERT_EQ(15, str1.findAny(str2, 12));
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char str2[] = "doip";
|
||||
ASSERT_EQ(15, str1.findAny(str2, 12));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_last){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "doip";
|
||||
ASSERT_EQ(39, str1.findAnyLast(str2, 0));
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "doip";
|
||||
ASSERT_EQ(39, str1.findAnyLast(str2, 0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_last_not){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "q";
|
||||
ASSERT_EQ(-1, str1.findAnyLast(str2, 0));
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "q";
|
||||
ASSERT_EQ(-1, str1.findAnyLast(str2, 0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_last_start){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "doip";
|
||||
ASSERT_EQ(39, str1.findAnyLast(str2, 12));
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "doip";
|
||||
ASSERT_EQ(39, str1.findAnyLast(str2, 12));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_last_chars){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char str2[] = "doip";
|
||||
ASSERT_EQ(39, str1.findAnyLast(str2, 0));
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char str2[] = "doip";
|
||||
ASSERT_EQ(39, str1.findAnyLast(str2, 0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_last_chars_not){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char str2[] = "q";
|
||||
ASSERT_EQ(-1, str1.findAnyLast(str2, 0));
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char str2[] = "q";
|
||||
ASSERT_EQ(-1, str1.findAnyLast(str2, 0));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, find_any_last_chars_start){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char str2[] = "doip";
|
||||
ASSERT_EQ(39, str1.findAnyLast(str2, 12));
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char str2[] = "doip";
|
||||
ASSERT_EQ(39, str1.findAnyLast(str2, 12));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, entries){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIChar c = "A";
|
||||
ASSERT_EQ(1, str1.entries(c));
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIChar c = "A";
|
||||
ASSERT_EQ(1, str1.entries(c));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, entries_char){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char c = 'A';
|
||||
ASSERT_EQ(1, str1.entries(c));
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
char c = 'A';
|
||||
ASSERT_EQ(1, str1.entries(c));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, starts_with){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = " A very";
|
||||
ASSERT_TRUE(str1.startsWith(str2));
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = " A very";
|
||||
ASSERT_TRUE(str1.startsWith(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, starts_with_false){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = " A veru";
|
||||
ASSERT_FALSE(str1.startsWith(str2));
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = " A veru";
|
||||
ASSERT_FALSE(str1.startsWith(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, ends_with){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = " code";
|
||||
ASSERT_TRUE(str1.endsWith(str2));
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = " code";
|
||||
ASSERT_TRUE(str1.endsWith(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, ends_with_false){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "c code";
|
||||
ASSERT_FALSE(str1.endsWith(str2));
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
PIString str2 = "c code";
|
||||
ASSERT_FALSE(str1.endsWith(str2));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, length){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
ASSERT_EQ(41, str1.length());
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
ASSERT_EQ(41, str1.length());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, is_empty_false){
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
ASSERT_FALSE(str1.isEmpty());
|
||||
PIString str1 = " A very strong programmer wrote this code";
|
||||
ASSERT_FALSE(str1.isEmpty());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, is_empty_true){
|
||||
PIString str1 = "";
|
||||
ASSERT_TRUE(str1.isEmpty());
|
||||
PIString str1 = "";
|
||||
ASSERT_TRUE(str1.isEmpty());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_bool){
|
||||
PIString str1 = "1";
|
||||
ASSERT_TRUE(str1.toBool());
|
||||
PIString str1 = "1";
|
||||
ASSERT_TRUE(str1.toBool());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_bool_yes){
|
||||
PIString str1 = "yes";
|
||||
ASSERT_TRUE(str1.toBool());
|
||||
PIString str1 = "yes";
|
||||
ASSERT_TRUE(str1.toBool());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_bool_false){
|
||||
PIString str1 = "no";
|
||||
ASSERT_FALSE(str1.toBool());
|
||||
PIString str1 = "no";
|
||||
ASSERT_FALSE(str1.toBool());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_bool_false_zero){
|
||||
PIString str1 = "0";
|
||||
ASSERT_FALSE(str1.toBool());
|
||||
PIString str1 = "0";
|
||||
ASSERT_FALSE(str1.toBool());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_char){
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
ASSERT_EQ(65, str1.toChar());
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
ASSERT_EQ(65, str1.toChar());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_short){
|
||||
PIString str1 = "133";
|
||||
ASSERT_EQ(133, str1.toShort(-1));
|
||||
PIString str1 = "133";
|
||||
ASSERT_EQ(133, str1.toShort(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_short_0x){
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toShort(-1));
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toShort(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_short_false){
|
||||
PIString str1 = "0x133";
|
||||
bool ok;
|
||||
str1.toShort(1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = "0x133";
|
||||
bool ok;
|
||||
str1.toShort(1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_short_false_base){
|
||||
PIString str1 = "7";
|
||||
bool ok;
|
||||
str1.toShort(6, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = "7";
|
||||
bool ok;
|
||||
str1.toShort(6, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_short_neg){
|
||||
PIString str1 = "-7";
|
||||
bool ok;
|
||||
ASSERT_EQ(-7, str1.toShort(10, &ok));
|
||||
PIString str1 = "-7";
|
||||
bool ok;
|
||||
ASSERT_EQ(-7, str1.toShort(10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ushort){
|
||||
PIString str1 = "133.1";
|
||||
ASSERT_EQ(133, str1.toUShort(-1));
|
||||
PIString str1 = "133.1";
|
||||
ASSERT_EQ(133, str1.toUShort(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ushort_0x){
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toUShort(-1));
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toUShort(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ushort_false){
|
||||
PIString str1 = "0x133";
|
||||
bool ok;
|
||||
str1.toUShort(1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = "0x133";
|
||||
bool ok;
|
||||
str1.toUShort(1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ushort_false_base){
|
||||
PIString str1 = "7";
|
||||
bool ok;
|
||||
str1.toUShort(6, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = "7";
|
||||
bool ok;
|
||||
str1.toUShort(6, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ushort_neg){
|
||||
PIString str1 = "-7";
|
||||
bool ok;
|
||||
ASSERT_EQ(65529, str1.toUShort(10, &ok));
|
||||
PIString str1 = "-7";
|
||||
bool ok;
|
||||
ASSERT_EQ(65529, str1.toUShort(10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_int){
|
||||
PIString str1 = "133";
|
||||
ASSERT_EQ(133, str1.toInt(-1));
|
||||
PIString str1 = "133";
|
||||
ASSERT_EQ(133, str1.toInt(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_int_0x){
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toInt(-1));
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toInt(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_int_false){
|
||||
PIString str1 = "0x133";
|
||||
bool ok;
|
||||
str1.toInt(1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = "0x133";
|
||||
bool ok;
|
||||
str1.toInt(1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_int_false_base){
|
||||
PIString str1 = "7";
|
||||
bool ok;
|
||||
str1.toInt(6, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = "7";
|
||||
bool ok;
|
||||
str1.toInt(6, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_int_neg){
|
||||
PIString str1 = "-7";
|
||||
bool ok;
|
||||
ASSERT_EQ(-7, str1.toShort(10, &ok));
|
||||
PIString str1 = "-7";
|
||||
bool ok;
|
||||
ASSERT_EQ(-7, str1.toShort(10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_uint){
|
||||
PIString str1 = "133.1";
|
||||
ASSERT_EQ(133, str1.toUInt(-1));
|
||||
PIString str1 = "133.1";
|
||||
ASSERT_EQ(133, str1.toUInt(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_uint_0x){
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toUInt(-1));
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toUInt(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_uint_false){
|
||||
PIString str1 = "0x133";
|
||||
bool ok;
|
||||
str1.toUInt(1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = "0x133";
|
||||
bool ok;
|
||||
str1.toUInt(1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_uint_false_base){
|
||||
PIString str1 = "7";
|
||||
bool ok;
|
||||
str1.toUInt(6, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = "7";
|
||||
bool ok;
|
||||
str1.toUInt(6, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_uint_neg){
|
||||
PIString str1 = "-7";
|
||||
bool ok;
|
||||
ASSERT_EQ(4294967289, str1.toUInt(10, &ok));
|
||||
PIString str1 = "-7";
|
||||
bool ok;
|
||||
ASSERT_EQ(4294967289, str1.toUInt(10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_long){
|
||||
PIString str1 = "133";
|
||||
ASSERT_EQ(133, str1.toLong(-1));
|
||||
PIString str1 = "133";
|
||||
ASSERT_EQ(133, str1.toLong(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_long_0x){
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toLong(-1));
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toLong(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_long_false){
|
||||
PIString str1 = "0x133";
|
||||
bool ok;
|
||||
str1.toLong(1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = "0x133";
|
||||
bool ok;
|
||||
str1.toLong(1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_long_false_base){
|
||||
PIString str1 = "7";
|
||||
bool ok;
|
||||
str1.toLong(6, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = "7";
|
||||
bool ok;
|
||||
str1.toLong(6, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_long_neg){
|
||||
PIString str1 = "-7";
|
||||
bool ok;
|
||||
ASSERT_EQ(-7, str1.toLong(10, &ok));
|
||||
PIString str1 = "-7";
|
||||
bool ok;
|
||||
ASSERT_EQ(-7, str1.toLong(10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ulong){
|
||||
PIString str1 = "133.1";
|
||||
ASSERT_EQ(133, str1.toULong(-1));
|
||||
PIString str1 = "133.1";
|
||||
ASSERT_EQ(133, str1.toULong(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ulong_0x){
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toULong(-1));
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toULong(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ulong_false){
|
||||
PIString str1 = "0x133";
|
||||
bool ok;
|
||||
str1.toULong(1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = "0x133";
|
||||
bool ok;
|
||||
str1.toULong(1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ulong_false_base){
|
||||
PIString str1 = "7";
|
||||
bool ok;
|
||||
str1.toULong(6, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = "7";
|
||||
bool ok;
|
||||
str1.toULong(6, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ulong_neg){
|
||||
PIString str1 = "-7";
|
||||
bool ok;
|
||||
ASSERT_EQ(4294967289, str1.toULong(10, &ok));
|
||||
PIString str1 = "-7";
|
||||
bool ok;
|
||||
ASSERT_EQ(4294967289, str1.toULong(10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_llong){
|
||||
PIString str1 = "133";
|
||||
ASSERT_EQ(133, str1.toLLong(-1));
|
||||
PIString str1 = "133";
|
||||
ASSERT_EQ(133, str1.toLLong(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_llong_0x){
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toLLong(-1));
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toLLong(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_llong_false){
|
||||
PIString str1 = "0x133";
|
||||
bool ok;
|
||||
str1.toLLong(1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = "0x133";
|
||||
bool ok;
|
||||
str1.toLLong(1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_llong_false_base){
|
||||
PIString str1 = "7";
|
||||
bool ok;
|
||||
str1.toLLong(6, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = "7";
|
||||
bool ok;
|
||||
str1.toLLong(6, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_llong_neg){
|
||||
PIString str1 = "-7";
|
||||
bool ok;
|
||||
ASSERT_EQ(-7, str1.toLLong(10, &ok));
|
||||
PIString str1 = "-7";
|
||||
bool ok;
|
||||
ASSERT_EQ(-7, str1.toLLong(10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ullong){
|
||||
PIString str1 = "133.1";
|
||||
ASSERT_EQ(133, str1.toULLong(-1));
|
||||
PIString str1 = "133.1";
|
||||
ASSERT_EQ(133, str1.toULLong(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ullong_0x){
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toULLong(-1));
|
||||
PIString str1 = "0x133";
|
||||
ASSERT_EQ(307, str1.toULLong(-1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ullong_false){
|
||||
PIString str1 = "0x133";
|
||||
bool ok;
|
||||
str1.toULLong(1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = "0x133";
|
||||
bool ok;
|
||||
str1.toULLong(1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ullong_false_base){
|
||||
PIString str1 = "7";
|
||||
bool ok;
|
||||
str1.toULLong(6, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = "7";
|
||||
bool ok;
|
||||
str1.toULLong(6, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_float){
|
||||
PIString str1 = "-7765,54";
|
||||
float f = -7765.54;
|
||||
ASSERT_EQ(f, str1.toFloat());
|
||||
PIString str1 = "-7765,54";
|
||||
float f = -7765.54f;
|
||||
ASSERT_EQ(f, str1.toFloat());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_double){
|
||||
PIString str1 = "-7765,54656";
|
||||
double f = -7765.54656;
|
||||
ASSERT_EQ(f, str1.toDouble());
|
||||
PIString str1 = "-7765,54656";
|
||||
double f = -7765.54656;
|
||||
ASSERT_EQ(f, str1.toDouble());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, to_ldouble){
|
||||
PIString str1 = "-7765,54656";
|
||||
ldouble f = -7765.54656;
|
||||
ASSERT_EQ(f, str1.toLDouble());
|
||||
TEST(DISABLED_PIString_Tests, to_ldouble){
|
||||
PIString str1 = "-7765,55";
|
||||
ldouble f = -7765.55l;
|
||||
ASSERT_TRUE(f == str1.toLDouble());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber){
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_zero){
|
||||
PIString str1 = " String";
|
||||
const short val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const short val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_false_base){
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_true){
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_base_minus){
|
||||
PIString str1 = " String";
|
||||
const short val = -10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
PIString res = "-A";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const short val = -10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
PIString res = "-A";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ushort){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ushort_true){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ushort_zero){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const ushort val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ushort_false_base){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ushort_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ushort_base_minus){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
PIString res = "A";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const ushort val = 10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
PIString res = "A";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_int){
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_int_zero){
|
||||
PIString str1 = " String";
|
||||
const int val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const int val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_int_false_base){
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_int_true){
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_int_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_int_base_minus){
|
||||
PIString str1 = " String";
|
||||
const int val = -10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
PIString res = "-A";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const int val = -10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
PIString res = "-A";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_uint){
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_uint_true){
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_uintt_zero){
|
||||
PIString str1 = " String";
|
||||
const uint val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const uint val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_uint_false_base){
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_uint_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_uint_base_minus){
|
||||
PIString str1 = " String";
|
||||
const uint val = 10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
PIString res = "A";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const uint val = 10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
PIString res = "A";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_long){
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_long_zero){
|
||||
PIString str1 = " String";
|
||||
const long val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const long val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_long_false_base){
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_long_true){
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_long_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_long_base_minus){
|
||||
PIString str1 = " String";
|
||||
const long val = -10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
PIString res = "-A";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const long val = -10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
PIString res = "-A";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ulong){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ulong_true){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ulong_zero){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const ulong val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ulong_false_base){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ulong_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ulong_base_minus){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
PIString res = "A";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const ulong val = 10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
PIString res = "A";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_llong){
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_llong_zero){
|
||||
PIString str1 = " String";
|
||||
const llong val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const llong val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_llong_false_base){
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_llong_true){
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_llong_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_llong_base_minus){
|
||||
PIString str1 = " String";
|
||||
const llong val = -10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
PIString res = "-A";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const llong val = -10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
PIString res = "-A";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ullong){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ullong_true){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ullong_zero){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const ullong val = 0;
|
||||
bool ok;
|
||||
str1.setNumber(val, 10, &ok);
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ullong_false_base){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ullong_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
str1.setNumber(val, 1, &ok);
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ullong_base_minus){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
PIString res = "A";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const ullong val = 10;
|
||||
bool ok;
|
||||
str1.setNumber(val, 16, &ok);
|
||||
PIString res = "A";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_float){
|
||||
PIString str1 = " String";
|
||||
const float val = 131.132;
|
||||
str1.setNumber(val, 'f', 3);
|
||||
PIString res = "131.132";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const float val = 131.132f;
|
||||
str1.setNumber(val, 'f', 3);
|
||||
PIString res = "131.132";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_double){
|
||||
PIString str1 = " String";
|
||||
const double val = 131.1324334;
|
||||
str1.setNumber(val, 'f', 7);
|
||||
PIString res = "131.1324334";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = " String";
|
||||
const double val = 131.1324334;
|
||||
str1.setNumber(val, 'f', 7);
|
||||
PIString res = "131.1324334";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setNumber_ldouble){
|
||||
PIString str1 = " String";
|
||||
const ldouble val = 131.1324334;
|
||||
str1.setNumber(val, 'f', 7);
|
||||
PIString res = "131.1324334";
|
||||
ASSERT_EQ(res, str1);
|
||||
TEST(DISABLED_PIString_Tests, setNumber_ldouble){
|
||||
PIString str1 = " String";
|
||||
const ldouble val = 131.1324334l;
|
||||
str1.setNumber(val, 'f', 7);
|
||||
PIString res = "131.1324334";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setReadableSize){
|
||||
PIString str1 = " ITELMA";
|
||||
PIString res = "1023 B";
|
||||
ASSERT_EQ(res, str1.setReadableSize(1023));
|
||||
PIString str1 = " ITELMA";
|
||||
PIString res = "1023 B";
|
||||
ASSERT_EQ(res, str1.setReadableSize(1023));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setReadableSize_kb){
|
||||
PIString str1 = " ITELMA";
|
||||
PIString res = "1.0 kB";
|
||||
ASSERT_EQ(res, str1.setReadableSize(1024));
|
||||
PIString str1 = " ITELMA";
|
||||
PIString res = "1.0 kB";
|
||||
ASSERT_EQ(res, str1.setReadableSize(1024));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setReadableSize_mb){
|
||||
PIString str1 = " ITELMA";
|
||||
PIString res = "1.0 MB";
|
||||
ASSERT_EQ(res, str1.setReadableSize(1024*1024));
|
||||
PIString str1 = " ITELMA";
|
||||
PIString res = "1.0 MB";
|
||||
ASSERT_EQ(res, str1.setReadableSize(1024*1024));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setReadableSize_gb){
|
||||
PIString str1 = " ITELMA";
|
||||
PIString res = "1.0 GB";
|
||||
ASSERT_EQ(res, str1.setReadableSize(1024*1024*1024));
|
||||
PIString str1 = " ITELMA";
|
||||
PIString res = "1.0 GB";
|
||||
ASSERT_EQ(res, str1.setReadableSize(1024*1024*1024));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setReadableSize_tb){
|
||||
PIString str1 = " ITELMA";
|
||||
llong val = 99999999999999;
|
||||
PIString res = "90.9 TB";
|
||||
ASSERT_EQ(res, str1.setReadableSize(val));
|
||||
PIString str1 = " ITELMA";
|
||||
llong val = 99999999999999;
|
||||
PIString res = "90.9 TB";
|
||||
ASSERT_EQ(res, str1.setReadableSize(val));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, setReadableSize_pb){
|
||||
PIString str1 = " ITELMA";
|
||||
llong val = 999999999999999999;
|
||||
PIString res = "888.1 PB";
|
||||
ASSERT_EQ(res, str1.setReadableSize(val));
|
||||
PIString str1 = " ITELMA";
|
||||
llong val = 999999999999999999;
|
||||
PIString res = "888.1 PB";
|
||||
ASSERT_EQ(res, str1.setReadableSize(val));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber){
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumberr_zero){
|
||||
PIString str1 = " String";
|
||||
const short val = 0;
|
||||
bool ok;
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
PIString str1 = " String";
|
||||
const short val = 0;
|
||||
bool ok;
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_false_base){
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_true){
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
|
||||
PIString str1 = " String";
|
||||
const short val = 131;
|
||||
bool ok;
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_base_minus){
|
||||
PIString str1 = " String";
|
||||
const short val = -10;
|
||||
bool ok;
|
||||
PIString res = "-A";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
|
||||
PIString str1 = " String";
|
||||
const short val = -10;
|
||||
bool ok;
|
||||
PIString res = "-A";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ushort){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ushort_true){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ushort_zero){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 0;
|
||||
bool ok;
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
PIString str1 = " String";
|
||||
const ushort val = 0;
|
||||
bool ok;
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ushort_false_base){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ushort_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
|
||||
PIString str1 = " String";
|
||||
const ushort val = 131;
|
||||
bool ok;
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ushort_base_minus){
|
||||
PIString str1 = " String";
|
||||
const ushort val = 10;
|
||||
bool ok;
|
||||
PIString res = "A";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
|
||||
PIString str1 = " String";
|
||||
const ushort val = 10;
|
||||
bool ok;
|
||||
PIString res = "A";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_int){
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_int_zero){
|
||||
PIString str1 = " String";
|
||||
const int val = 0;
|
||||
bool ok;
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
PIString str1 = " String";
|
||||
const int val = 0;
|
||||
bool ok;
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_int_false_base){
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_int_true){
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_int_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
|
||||
PIString str1 = " String";
|
||||
const int val = 131;
|
||||
bool ok;
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_int_base_minus){
|
||||
PIString str1 = " String";
|
||||
const int val = -10;
|
||||
bool ok;
|
||||
PIString res = "-A";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
|
||||
PIString str1 = " String";
|
||||
const int val = -10;
|
||||
bool ok;
|
||||
PIString res = "-A";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_uint){
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_uint_true){
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_uintt_zero){
|
||||
PIString str1 = " String";
|
||||
const uint val = 0;
|
||||
bool ok;
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
PIString str1 = " String";
|
||||
const uint val = 0;
|
||||
bool ok;
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_uint_false_base){
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_uint_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
|
||||
PIString str1 = " String";
|
||||
const uint val = 131;
|
||||
bool ok;
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_uint_base_minus){
|
||||
PIString str1 = " String";
|
||||
const uint val = 10;
|
||||
bool ok;
|
||||
PIString res = "A";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
|
||||
PIString str1 = " String";
|
||||
const uint val = 10;
|
||||
bool ok;
|
||||
PIString res = "A";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_long){
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_long_zero){
|
||||
PIString str1 = " String";
|
||||
const long val = 0;
|
||||
bool ok;
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
PIString str1 = " String";
|
||||
const long val = 0;
|
||||
bool ok;
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_long_false_base){
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_long_true){
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_long_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
|
||||
PIString str1 = " String";
|
||||
const long val = 131;
|
||||
bool ok;
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_long_base_minus){
|
||||
PIString str1 = " String";
|
||||
const long val = -10;
|
||||
bool ok;
|
||||
PIString res = "-A";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
|
||||
PIString str1 = " String";
|
||||
const long val = -10;
|
||||
bool ok;
|
||||
PIString res = "-A";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ulong){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ulong_true){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ulong_zero){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 0;
|
||||
bool ok;
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
PIString str1 = " String";
|
||||
const ulong val = 0;
|
||||
bool ok;
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ulong_false_base){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ulong_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
|
||||
PIString str1 = " String";
|
||||
const ulong val = 131;
|
||||
bool ok;
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ulong_base_minus){
|
||||
PIString str1 = " String";
|
||||
const ulong val = 10;
|
||||
bool ok;
|
||||
PIString res = "A";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
|
||||
PIString str1 = " String";
|
||||
const ulong val = 10;
|
||||
bool ok;
|
||||
PIString res = "A";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_llong){
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_llong_zero){
|
||||
PIString str1 = " String";
|
||||
const llong val = 0;
|
||||
bool ok;
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
PIString str1 = " String";
|
||||
const llong val = 0;
|
||||
bool ok;
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_llong_false_base){
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_llong_true){
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_llong_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
|
||||
PIString str1 = " String";
|
||||
const llong val = 131;
|
||||
bool ok;
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_llong_base_minus){
|
||||
PIString str1 = " String";
|
||||
const llong val = -10;
|
||||
bool ok;
|
||||
PIString res = "-A";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
|
||||
PIString str1 = " String";
|
||||
const llong val = -10;
|
||||
bool ok;
|
||||
PIString res = "-A";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ullong){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
PIString res = "131";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ullong_true){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 10, &ok);
|
||||
ASSERT_TRUE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ullong_zero){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 0;
|
||||
bool ok;
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
PIString str1 = " String";
|
||||
const ullong val = 0;
|
||||
bool ok;
|
||||
PIString res = "0";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 10, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ullong_false_base){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
str1.fromNumber(val, 1, &ok);
|
||||
ASSERT_FALSE(ok);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ullong_false_base_str){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
|
||||
PIString str1 = " String";
|
||||
const ullong val = 131;
|
||||
bool ok;
|
||||
PIString res = "";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 1, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ullong_base_minus){
|
||||
PIString str1 = " String";
|
||||
const ullong val = 10;
|
||||
bool ok;
|
||||
PIString res = "A";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
|
||||
PIString str1 = " String";
|
||||
const ullong val = 10;
|
||||
bool ok;
|
||||
PIString res = "A";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 16, &ok));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_float){
|
||||
PIString str1 = " String";
|
||||
const float val = 131.132;
|
||||
PIString res = "131.132";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 'f', 3));
|
||||
PIString str1 = " String";
|
||||
const float val = 131.132f;
|
||||
PIString res = "131.132";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 'f', 3));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_double){
|
||||
PIString str1 = " String";
|
||||
const double val = 131.1324334;
|
||||
PIString res = "131.1324334";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 'f', 7));
|
||||
PIString str1 = " String";
|
||||
const double val = 131.1324334;
|
||||
PIString res = "131.1324334";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 'f', 7));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromNumber_ldouble){
|
||||
PIString str1 = " String";
|
||||
const ldouble val = 131.1324334;
|
||||
PIString res = "131.1324334";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 'f', 7));
|
||||
PIString str1 = " String";
|
||||
const ldouble val = 131.1324334l;
|
||||
PIString res = "131.1324334";
|
||||
ASSERT_EQ(res, str1.fromNumber(val, 'f', 7));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromBool_true){
|
||||
PIString str1;
|
||||
bool val = true;
|
||||
PIString res = "true";
|
||||
ASSERT_EQ(res, str1.fromBool(val));
|
||||
PIString str1;
|
||||
bool val = true;
|
||||
PIString res = "true";
|
||||
ASSERT_EQ(res, str1.fromBool(val));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, fromBool_false){
|
||||
PIString str1;
|
||||
bool val = false;
|
||||
PIString res = "false";
|
||||
ASSERT_EQ(res, str1.fromBool(val));
|
||||
PIString str1;
|
||||
bool val = false;
|
||||
PIString res = "false";
|
||||
ASSERT_EQ(res, str1.fromBool(val));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, from_Console){
|
||||
PIString str1;
|
||||
char s[] = "true boy";
|
||||
PIString res = "true boy";
|
||||
ASSERT_EQ(res, str1.fromConsole(s));
|
||||
PIString str1;
|
||||
char s[] = "true boy";
|
||||
PIString res = "true boy";
|
||||
ASSERT_EQ(res, str1.fromConsole(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, from_System){
|
||||
PIString str1;
|
||||
char s[] = "true boy";
|
||||
PIString res = "true boy";
|
||||
ASSERT_EQ(res, str1.fromSystem(s));
|
||||
PIString str1;
|
||||
char s[] = "true boy";
|
||||
PIString res = "true boy";
|
||||
ASSERT_EQ(res, str1.fromSystem(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, from_UTF8){
|
||||
PIString str1;
|
||||
char s[] = "true boy";
|
||||
PIString res = "true boy";
|
||||
ASSERT_EQ(res, str1.fromUTF8(s));
|
||||
PIString str1;
|
||||
char s[] = "true boy";
|
||||
PIString res = "true boy";
|
||||
ASSERT_EQ(res, str1.fromUTF8(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, from_UTF8_ba){
|
||||
PIString str1;
|
||||
PIByteArray s;
|
||||
s.append('t');
|
||||
s.append('r');
|
||||
s.append('u');
|
||||
s.append('e');
|
||||
PIString res = "true";
|
||||
ASSERT_EQ(res, str1.fromUTF8(s));
|
||||
PIString str1;
|
||||
PIByteArray s;
|
||||
s.append('t');
|
||||
s.append('r');
|
||||
s.append('u');
|
||||
s.append('e');
|
||||
PIString res = "true";
|
||||
ASSERT_EQ(res, str1.fromUTF8(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, from_Ascii){
|
||||
PIString str1;
|
||||
char s[] = "true boy";
|
||||
PIString res = "true boy";
|
||||
ASSERT_EQ(res, str1.fromAscii(s));
|
||||
PIString str1;
|
||||
char s[] = "true boy";
|
||||
PIString res = "true boy";
|
||||
ASSERT_EQ(res, str1.fromAscii(s));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, from_Codepage){
|
||||
PIString str1 = "Nul";
|
||||
char s[] = "true";
|
||||
char c[] = "utf8";
|
||||
PIString str2 = str1.fromCodepage(s, c);
|
||||
PIString res = "true";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "Nul";
|
||||
char s[] = "true";
|
||||
char c[] = "utf8";
|
||||
PIString str2 = str1.fromCodepage(s, c);
|
||||
PIString res = "true";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, ReadableSize){
|
||||
PIString str1 = " ITELMA";
|
||||
PIString res = "1023 B";
|
||||
ASSERT_EQ(res, str1.readableSize(1023));
|
||||
PIString str1 = " ITELMA";
|
||||
PIString res = "1023 B";
|
||||
ASSERT_EQ(res, str1.readableSize(1023));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, readableSize_kb){
|
||||
PIString str1 = " ITELMA";
|
||||
PIString res = "1.0 kB";
|
||||
ASSERT_EQ(res, str1.readableSize(1024));
|
||||
PIString str1 = " ITELMA";
|
||||
PIString res = "1.0 kB";
|
||||
ASSERT_EQ(res, str1.readableSize(1024));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, readableSize_mb){
|
||||
PIString str1 = " ITELMA";
|
||||
PIString res = "1.0 MB";
|
||||
ASSERT_EQ(res, str1.readableSize(1024*1024));
|
||||
PIString str1 = " ITELMA";
|
||||
PIString res = "1.0 MB";
|
||||
ASSERT_EQ(res, str1.readableSize(1024*1024));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, readableSize_gb){
|
||||
PIString str1 = " ITELMA";
|
||||
PIString res = "1.0 GB";
|
||||
ASSERT_EQ(res, str1.readableSize(1024*1024*1024));
|
||||
PIString str1 = " ITELMA";
|
||||
PIString res = "1.0 GB";
|
||||
ASSERT_EQ(res, str1.readableSize(1024*1024*1024));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, readableSize_tb){
|
||||
PIString str1 = " ITELMA";
|
||||
llong val = 99999999999999;
|
||||
PIString res = "90.9 TB";
|
||||
ASSERT_EQ(res, str1.readableSize(val));
|
||||
PIString str1 = " ITELMA";
|
||||
llong val = 99999999999999;
|
||||
PIString res = "90.9 TB";
|
||||
ASSERT_EQ(res, str1.readableSize(val));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, readableSize_pb){
|
||||
PIString str1 = " ITELMA";
|
||||
llong val = 999999999999999999;
|
||||
PIString res = "888.1 PB";
|
||||
ASSERT_EQ(res, str1.readableSize(val));
|
||||
PIString str1 = " ITELMA";
|
||||
llong val = 999999999999999999;
|
||||
PIString res = "888.1 PB";
|
||||
ASSERT_EQ(res, str1.readableSize(val));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, removeAll_char){
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
char v = ' ';
|
||||
PIString res = "Averystrongprogrammerwrotethiscode";
|
||||
ASSERT_EQ(res, str1.removeAll(v));
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
char v = ' ';
|
||||
PIString res = "Averystrongprogrammerwrotethiscode";
|
||||
ASSERT_EQ(res, str1.removeAll(v));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, removeAll_pistring){
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
PIString v = "very strong ";
|
||||
PIString res = "A programmer wrote this code";
|
||||
ASSERT_EQ(res, str1.removeAll(v));
|
||||
PIString str1 = "A very strong programmer wrote this code";
|
||||
PIString v = "very strong ";
|
||||
PIString res = "A programmer wrote this code";
|
||||
ASSERT_EQ(res, str1.removeAll(v));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_ba_pstr){
|
||||
PIString str1 = '1';
|
||||
PIByteArray s;
|
||||
s << str1;
|
||||
PIString res = "010000003100";
|
||||
ASSERT_EQ(res, s.toHex());
|
||||
PIString str1 = '1';
|
||||
PIByteArray s;
|
||||
s << str1;
|
||||
PIString res = "010000003100";
|
||||
ASSERT_EQ(res, s.toHex());
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_pstr_ba){
|
||||
PIString str1 = "1";
|
||||
PIByteArray s;
|
||||
s.append('t');
|
||||
s.append('r');
|
||||
s.append('u');
|
||||
s.append('e');
|
||||
str1 << s;
|
||||
PIString res = "1true";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "1";
|
||||
PIByteArray s;
|
||||
s.append('t');
|
||||
s.append('r');
|
||||
s.append('u');
|
||||
s.append('e');
|
||||
str1 << s;
|
||||
PIString res = "1true";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_plus_pstr_pstr){
|
||||
PIString str1 = "first ";
|
||||
PIString str2 = "second";
|
||||
PIString res = "first second";
|
||||
ASSERT_EQ(res, str1 + str2);
|
||||
PIString str1 = "first ";
|
||||
PIString str2 = "second";
|
||||
PIString res = "first second";
|
||||
ASSERT_EQ(res, str1 + str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_plus_pstr_chars){
|
||||
PIString str1 = "first ";
|
||||
char str2[] = "second";
|
||||
PIString res = "first second";
|
||||
ASSERT_EQ(res, str1 + str2);
|
||||
PIString str1 = "first ";
|
||||
char str2[] = "second";
|
||||
PIString res = "first second";
|
||||
ASSERT_EQ(res, str1 + str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, operator_plus_chars_pstr){
|
||||
PIString str1 = "first";
|
||||
char str2[] = "second ";
|
||||
PIString res = "second first";
|
||||
ASSERT_EQ(res, str2 + str1);
|
||||
PIString str1 = "first";
|
||||
char str2[] = "second ";
|
||||
PIString res = "second first";
|
||||
ASSERT_EQ(res, str2 + str1);
|
||||
}
|
||||
|
||||
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){
|
||||
ASSERT_EQ(0, versionCompare(".2-alpha", "0.2_alpha"));
|
||||
ASSERT_EQ(NULL, versionCompare(".2-alpha", "0.2_alpha"));
|
||||
}
|
||||
|
||||
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){
|
||||
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){
|
||||
PIString str1 = "first second";
|
||||
PIString res = "0.0_first second";
|
||||
ASSERT_EQ(res, versionNormalize(str1));
|
||||
PIString str1 = "first second";
|
||||
PIString res = "0.0_first second";
|
||||
ASSERT_EQ(res, versionNormalize(str1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, pi_Hash){
|
||||
PIString str1 = "first";
|
||||
ASSERT_EQ(898448032, piHash(str1));
|
||||
PIString str1 = "first";
|
||||
ASSERT_EQ(898448032, piHash(str1));
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, pi_Swap){
|
||||
PIString str1 = "first";
|
||||
PIString str2 = "second";
|
||||
piSwap(str1, str2);
|
||||
PIString res = "first";
|
||||
ASSERT_EQ(res, str2);
|
||||
PIString str1 = "first";
|
||||
PIString str2 = "second";
|
||||
piSwap(str1, str2);
|
||||
PIString res = "first";
|
||||
ASSERT_EQ(res, str2);
|
||||
}
|
||||
|
||||
TEST(PIString_Tests, piSwap_sec){
|
||||
PIString str1 = "first";
|
||||
PIString str2 = "second";
|
||||
piSwap(str1, str2);
|
||||
PIString res = "second";
|
||||
ASSERT_EQ(res, str1);
|
||||
PIString str1 = "first";
|
||||
PIString str2 = "second";
|
||||
piSwap(str1, str2);
|
||||
PIString res = "second";
|
||||
ASSERT_EQ(res, str1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user