Esempio n. 1
0
int test_collection_04()
{
	//
	struct collection *col = NULL;

	// Pokud to proběhne bez toho aniž by spadlo na neoprávněný přístup do paměti, je to OK (snad)..
	col = collection_new();

	//
	collection_add(col, NULL);
	collection_add(col, NULL);
	collection_add(col, NULL);
	collection_add(col, NULL);
	collection_add(col, NULL);
	collection_add(col, NULL);
	collection_add(col, NULL);
	collection_add(col, NULL);

	// Zde budu testovat hodnoty položky kolekce..
	struct collection_item *item = col -> first_item;
	while(item)
	{
		//
		void *object = NULL;

		//
		if(item -> object)
		{
			object = item -> object;
		}

		//
		if(object != NULL)
		{
			ctest_assert_null(object, "Hodnota položky object v kolekci je neplatná měla by být NULL..");
			break;
		}

		//
		item = item -> next;
	}

	//
	collection_delete(col);

	//
	char *assert_message = "Testing collection for new/several add(null)/delete..";
	ctest_assert_pass(assert_message);

	//
	return 0;
}
Esempio n. 2
0
int test_collection_02()
{
	//
	struct collection *col = NULL;

	// Pokud to proběhne bez toho aniž by spadlo na neoprávněný přístup do paměti, je to OK (snad)..
	collection_delete(col);

	//
	char *assert_message = "Testing collection for delete NULL..";
	ctest_assert_pass(assert_message);

	//
	return 0;
}
Esempio n. 3
0
int test_collection_01()
{
	//
	struct collection *col;

	//
	col = collection_new();
	collection_delete(col);

	//
	char *assert_message = "Testing collection for simple new/delete..";
	ctest_assert_pass(assert_message);

	//
	return 0;
}
Esempio n. 4
0
int test_collection_03()
{
	//
	struct collection *col = NULL;

	// Pokud to proběhne bez toho aniž by spadlo na neoprávněný přístup do paměti, je to OK (snad)..
	col = collection_new();
	collection_add(col, NULL);
	collection_delete(col);

	//
	char *assert_message = "Testing collection for new/add(null)/delete..";
	ctest_assert_pass(assert_message);

	//
	return 0;
}
Esempio n. 5
0
int cprocessor_close()
{
	//
	if(co_collection)
	{
		// Smazání samotných objektů v kolekci (co_collection)..
		collection_object_delete(co_collection, &cprocessor_command_delete);

		//
		collection_delete(co_collection);

		//
		co_collection = NULL;
	}

	//
	return 0;
}
Esempio n. 6
0
void array_delete(Array * array){
	collection_delete((Collection *)array);	
}
Esempio n. 7
0
int test_collection_05()
{
	//
	struct collection *col = NULL;

	//
	int my_number = 1234;
	int *my_object = &my_number;

	// Pokud to proběhne bez toho aniž by spadlo na neoprávněný přístup do paměti, je to OK (snad)..
	col = collection_new();

	//
	collection_add(col, my_object);
	collection_add(col, my_object);
	collection_add(col, my_object);
	collection_add(col, my_object);

	//
	struct collection_item *item = col -> first_item;

	//
	while(item)
	{
		//
		void *object = NULL;

		//
		object = item -> object;
	
		//
		if(object == NULL)
		{
			ctest_assert_fail("Object has to by valid object to pass this test!");
			break;
		}

		//
		if(object != my_object)
		{
			ctest_assert_fail("Object address is not the expected one!");
			break;
		}

		//
		int value = *(int *) object;
		if(value != my_number)
		{
			ctest_assert_fail("Object value is not the excepted one!");
			break;
		}

		//
		item = item -> next;
	}

	//
	collection_delete(col);

	//
	char *assert_message = "Testing collection for new/several add(null)/delete..";
	ctest_assert_pass(assert_message);

	//
	return 0;
}