Example #1
0
TEST(List, can_find_element_by_index) {
	List<int> list;
	list.AddToHead(1);
	list.AddToTail(4);//1

	EXPECT_EQ(4, list.At(1)->GetVar());

}
Example #2
0
TEST(List, can_add_element_at_head) {
	List<int> list;
	list.AddToHead(1);
	list.AddToTail(4);
	list.AddElement(2, 0);//2,1,4

	EXPECT_EQ(3, list.GetLength());
	EXPECT_EQ(2, list.At(0)->GetVar());
}
Example #3
0
TEST(List, can_add_element_by_index) {
	List<int> list;
	list.AddToHead(1);
	list.AddToTail(4);
	list.AddElement(2,1);//1,2,4

	EXPECT_EQ(3, list.GetLength());
	EXPECT_EQ(2, list.At(1)->GetVar());
}
Example #4
0
 int main(){
 	List list;

 	for (int i = 0; i < 10; ++i){
 		list.Unshift(i);
 	}
 	Show(list);
 	list.Shift();
 	Show(list);
 	list.At(3) = 42;
 	Show(list);

 }
int main()
{
	/*IntNode* head = new IntNode(0);
	head->previous = head;
	head->next = head;

	for (int numberOfNodesToAdd = 1; numberOfNodesToAdd < 100; numberOfNodesToAdd++)
	{
		head->previous->AddAfter(new IntNode(numberOfNodesToAdd));
	}

	print(head);
	printBackwards(head);

	*/

	List myList;

	myList.Append(1);
	myList.Append(2);

	cout << myList.At(0) << endl;
	cout << myList.At(1) << endl;
	//cout << myList.At(10) << endl;

	myList.Set(1, 20);

	cout << myList.At(0) << endl;
	cout << myList.At(1) << endl;

	myList.RemoveByValue(20);

	cout << myList.At(0) << endl;
	cout << myList.At(1) << endl;

	system("pause");

	return 0;
}
Example #6
0
TEST(List, can_not_find_element_by_index_more_then_length) {
	List<int> list;

	EXPECT_ANY_THROW(list.At(1));
}
Example #7
0
TEST(List, can_not_find_element_by_negative_index) {
	List<int> list;

	EXPECT_ANY_THROW(list.At(-1));
}