#include "pistringlist.h"

#include "gtest/gtest.h"

using namespace std;

TEST(PIStringList_Tests, construct_empty) {
	PIStringList lis;
	ASSERT_TRUE(lis.isEmpty());
}

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]);
}

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_move_data) {
	PIString str1 = "first string";
	PIString str  = str1;
	PIStringList lis(move(str));
	ASSERT_EQ(str1, lis[0]);
}
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]);
}

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_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_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);
}

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_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_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);
}

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_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_std_initializer_list_length) {
	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";
	PIStringList lis{"first string", "second string", "third string", "fourth string", "fourth string"};
	ASSERT_EQ(lis[0], str1);
	ASSERT_EQ(lis[1], str2);
	ASSERT_EQ(lis[2], str3);
	ASSERT_EQ(lis[3], str4);
	ASSERT_EQ(lis[4], str4);
}

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);
}

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_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_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);
}

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);
}

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");
}

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");
}
