Daniele Bartolini 11 лет назад
Родитель
Сommit
dafba67629

+ 0 - 5
engine/CMakeLists.txt

@@ -663,11 +663,6 @@ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:$ORIGIN")
 add_executable(${CROWN_EXECUTABLE_NAME} ${CROWN_MAIN_SRC})
 target_link_libraries(${CROWN_EXECUTABLE_NAME} crown-lib)
 
-if (CROWN_BUILD_TESTS)
-	add_subdirectory(tests)
-endif (CROWN_BUILD_TESTS)
-
-
 install (TARGETS crown-lib DESTINATION bin)
 install (TARGETS ${CROWN_EXECUTABLE_NAME} DESTINATION bin)
 

+ 0 - 33
engine/tests/CMakeLists.txt

@@ -1,33 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-project(crown-tests)
-
-#add_executable(allocators allocators.cpp)
-#add_executable(containers containers.cpp)
-#add_executable(compressors compressors.cpp)
-#add_executable(strings strings.cpp)
-#add_executable(paths paths.cpp)
-#add_executable(dynamic-strings dynamic-strings.cpp)
-#add_executable(json json.cpp)
-#add_executable(events events.cpp)
-
-
-#target_link_libraries(allocators crown)
-#target_link_libraries(containers crown)
-#target_link_libraries(compressors crown)
-#target_link_libraries(strings crown)
-#target_link_libraries(paths crown)
-#target_link_libraries(dynamic-strings crown)
-#target_link_libraries(json crown)
-#target_link_libraries(events crown)
-
-
-#install (TARGETS allocators DESTINATION test)
-#install (TARGETS containers DESTINATION test)
-#install (TARGETS compressors DESTINATION test)
-#install (TARGETS strings DESTINATION test)
-#install (TARGETS paths DESTINATION test)
-#install (TARGETS dynamic-strings DESTINATION test)
-#install (TARGETS json DESTINATION test)
-#install (TARGETS events DESTINATION test)
-

+ 0 - 32
engine/tests/allocators.cpp

@@ -1,32 +0,0 @@
-#include "Allocator.h"
-#include "HeapAllocator.h"
-#include "StackAllocator.h"
-#include <cstdio>
-#include "Assert.h"
-
-using namespace crown;
-
-int main()
-{
-	HeapAllocator malloc_allocator;
-
-	char* char_buffer = (char*)malloc_allocator.allocate(128);
-	CE_ASSERT(malloc_allocator.allocated_size() >= 128, "Allocated size differs from requested size");
-
-	printf("HeapAllocator::get_allocated_size(): %d\n", (uint32_t)malloc_allocator.allocated_size());
-
-	malloc_allocator.deallocate(char_buffer);
-
-	printf("HeapAllocator::get_allocated_size(): %d\n", (uint32_t)malloc_allocator.allocated_size());
-	//CE_ASSERT(malloc_allocator.get_allocated_size() == 0);
-
-	uint8_t buffer[1024 * 1024];
-
-	StackAllocator stack(buffer, 1024 * 1024);
-
-	stack.allocate(12);
-	stack.allocate(5);
-
-	//memory::dump(buffer, stack.allocated_size(), 4);
-}
-

+ 0 - 49
engine/tests/compressors.cpp

@@ -1,49 +0,0 @@
-#include <cstdio>
-#include <cstring>
-#include "HeapAllocator.h"
-#include "ZipCompressor.h"
-
-using namespace crown;
-
-int main()
-{
-	
-	HeapAllocator allocator;
-	ZipCompressor compressor(allocator);
-
-	const char* uncompressed_string = "letstry";
-	uint8_t* compressed_string;
-	uint8_t* result;
-	size_t compr_size = 0;
-	size_t result_size = 0;
-	
- 	compressed_string = compressor.compress((void*)uncompressed_string, strlen(uncompressed_string), compr_size);
-	
-	printf("Uncompressed: ");
-	printf("Size: %d - ", (uint32_t)strlen(uncompressed_string));
-	printf(uncompressed_string);
-	printf("\n\n");
-
-	printf("Compressed: ");
-	printf("Size: %d - ", (uint32_t)compr_size);
-	for (size_t i = 0; i < compr_size; i++)
-	{
-		printf("%c", compressed_string[i]);
-	}
-	printf("\n\n");
-
-	result = compressor.uncompress((void*)compressed_string, compr_size, result_size);
-	
-	printf("Uncompressed again: ");
-	printf("Size: %d - ", (uint32_t)result_size);
-	for (size_t i = 0; i < result_size; i++)
-	{
-		printf("%c", result[i]);
-	}
-	printf("\n\n");
-	
-	allocator.deallocate(compressed_string);
-  	allocator.deallocate(result); 
-	
-	return 0;
-}

+ 0 - 38
engine/tests/containers.cpp

@@ -1,38 +0,0 @@
-#include "Crown.h"
-#include <cstdio>
-#include "Assert.h"
-
-using namespace crown;
-
-int main()
-{
-	HeapAllocator allocator;
-
-	Array<int> int_list(allocator);
-
-	CE_ASSERT(int_list.size() == 0, "Size differs from expected value");
-
-	int_list.push_back(10);
-	int_list.push_back(20);
-	int_list.push_back(30);
-	int_list.push_back(40);
-	int_list.push_back(50);
-	int_list.push_back(60);
-
-	CE_ASSERT(int_list.size() == 6, "Size differs from expected value");
-	CE_ASSERT(int_list.front() == 10, "Front differs from expected value");
-	CE_ASSERT(int_list.back() == 60, "Back differs from expected value");
-
-	int_list.pop_back();
-
-	CE_ASSERT(int_list.size() == 5, "Size differs from expected value");
-	CE_ASSERT(int_list.front() == 10, "Front differs from expected value");
-	CE_ASSERT(int_list.back() == 50, "Back differs from expected value");
-
-	int_list.clear();
-
-	CE_ASSERT(int_list.size() == 0, "Size differs from expected value");
-
-	return 0;
-}
-

+ 0 - 27
engine/tests/decoders.cpp

@@ -1,27 +0,0 @@
-#include "Crown.h"
-
-using namespace crown;
-
-int main(int argc, char** argv)
-{
-	Device* engine = device();
-
-	engine->init(argc, argv);
-
-	// Begin Test
-	ResourceId rid = engine->resource_manager()->load("sound", "sounds/untrue");
-	engine->resource_manager()->flush();
-
-	SoundResource* stream = (SoundResource*)engine->resource_manager()->get(rid);
-
-	OggDecoder decoder((char*)stream->data(), stream->size());
-
-	while(decoder.stream())
-	{
-		CE_LOGI("size: %d", decoder.size());
-	}
-
-	engine->shutdown();
-
-	return 0;
-}

+ 0 - 81
engine/tests/dynamic-strings.cpp

@@ -1,81 +0,0 @@
-#include "Crown.h"
-
-using namespace crown;
-
-//-----------------------------------------------------------------------------
-void creation_test()
-{
-	DynamicString string(default_allocator(), "Creation Test");
-	CE_LOGI("%s", string.c_str());
-
-	string = "Creation Test OK!";
-	CE_LOGI("%s", string.c_str());
-}
-
-//-----------------------------------------------------------------------------
-void equal_test()
-{
-	DynamicString string(default_allocator(), "Equal Test");
-	CE_LOGI("%s", string.c_str());
-
-	DynamicString string1(default_allocator(), "DynamicString assigned!");	
-
-	string = string1;
-	CE_LOGI("%s", string.c_str());
-
-	string = "C-string assigned";
-	CE_LOGI("%s", string.c_str());
-
-	string = 'C';
-	CE_LOGI("%s", string.c_str());
-
-	string = "Equal Test OK!";
-	CE_LOGI("%s", string.c_str());
-}
-
-//-----------------------------------------------------------------------------
-void plus_equal_test()
-{
-	DynamicString string(default_allocator(), "PlusEqual Test");
-	DynamicString string1(default_allocator(), " DynamicString appended!");
-
-	string += string1;
-	CE_LOGI("%s", string.c_str());
-
-	string += " C-string appended! ";
-	CE_LOGI("%s", string.c_str());
-
-	string += 'C';
-	CE_LOGI("%s", string.c_str());
-
-	string = "PlusEqual Test OK!";
-	CE_LOGI("%s", string.c_str());
-}
-
-//-----------------------------------------------------------------------------
-void starts_ends_with_test()
-{
-	TempAllocator1024 alloc;
-
-	DynamicString string(alloc, "lua/game.lua");
-
-	CE_ASSERT(string.starts_with("lua"), "FAIL");
-	CE_ASSERT(string.starts_with("lua/game.lua"), "FAIL");
-	CE_ASSERT(!string.starts_with("game"), "FAIL");
-	CE_ASSERT(!string.starts_with("lua/game.lua/foo"), "FAIL");
-
-	CE_ASSERT(string.ends_with(".lua"), "FAIL");
-	CE_ASSERT(string.ends_with("lua/game.lua"), "FAIL");
-	CE_ASSERT(!string.ends_with("foo"), "FAIL");
-	CE_ASSERT(!string.ends_with("lua/game.lua/"), "FAIL");
-}
-
-int main()
-{
-	creation_test();
-	equal_test();
-	plus_equal_test();
-	starts_ends_with_test();
-
-	return 0;
-}

+ 0 - 111
engine/tests/events.cpp

@@ -1,111 +0,0 @@
-// #include <cstdlib>
-// #include <ctime>
-
-// #include "Crown.h"
-// #include "EventBuffer.h"
-// #include "OsTypes.h"
-// #include "Mouse.h"
-// #include "OsThread.h"
-// #include "Log.h"
-
-// using namespace crown;
-
-// EventBuffer* g_write;
-// EventBuffer* g_read;
-
-// OsThread g_thread("consumer-thread");
-// Semaphore g_write_sem;
-// Semaphore g_read_sem;
-
-// bool g_exit = false;
-
-// //-----------------------------------------------------------------------------
-// void push_event(int32_t x, int32_t y)
-// {
-// 	OsMouseEvent ome;
-// 	ome.button = MouseButton::LEFT;
-// 	ome.x = x;
-// 	ome.y = y;
-// 	ome.pressed = true;
-
-// 	g_write->push_event((uint32_t)OsEvent::MOUSE, &ome, sizeof(OsMouseEvent));
-// 	CE_LOGI("Event pushed");
-// }
-
-// //-----------------------------------------------------------------------------
-// void swap()
-// {
-// 	EventBuffer* tmp;
-
-// 	tmp = g_write;
-// 	g_write = g_read;
-// 	g_read = tmp;
-
-// 	CE_LOGI("Buffers swapped");
-// }
-
-// //-----------------------------------------------------------------------------
-// int32_t thread_proc(void* /*user_data*/)
-// {
-// 	static uint32_t count = 0;
-
-// 	OsMouseEvent* result;
-// 	uint32_t et; size_t es;
-
-// 	while (true)
-// 	{
-// 		CE_LOGI("%p", g_read);
-		
-// 		do
-// 		{
-// 			result = (OsMouseEvent*)g_read->get_next_event(et, es);
-
-// 			if (result != NULL)
-// 			{
-// 				CE_LOGD("x: %d, y: %d", result->x, result->y);
-// 			}
-// 		}
-// 		while (result != NULL);
-
-// 		g_exit = ++count == 3 ? true : false;
-
-// 		g_read->clear();
-
-// 		g_write_sem.post();
-// 		g_read_sem.wait();
-// 	}
-
-// 	return 0;
-// }
-
-// //-----------------------------------------------------------------------------
-// int main()
-// {
-// 	memory::init();
-
-// 	g_write = CE_NEW(default_allocator(), EventBuffer);
-// 	g_read = CE_NEW(default_allocator(), EventBuffer);
-
-// 	g_thread.start(thread_proc);
-
-// 	while (!g_exit)
-// 	{
-// 		g_write_sem.wait();
-
-// 		push_event(10, 10);
-// 		push_event(20, 20);
-// 		push_event(30, 30);
-
-// 		swap();
-
-// 		g_read_sem.post();
-// 	}
-
-// 	g_thread.stop();
-
-// 	memory::shutdown();
-
-// 	return 0;
-// }
-
-int main() {}

+ 0 - 42
engine/tests/json.cpp

@@ -1,42 +0,0 @@
-#include "Crown.h"
-
-using namespace crown;
-
-int main()
-{
-	const char* json_string = 	"{"
-    							"\"glossary\": { "
-        						"	\"title\": \"example glossary\", "
-								"	\"GlossDiv\": { "
-            					"		\"title\": \"S\", "
-								"		\"GlossList\": { "
-                				"			\"GlossEntry\": { "
-                    			"				\"ID\": \"SGML\", "
-								"				\"SortAs\": \"SGML\", "
-								"				\"GlossTerm\": \"Standard Generalized Markup Language\", "
-								"				\"Acronym\": \"SGML\", "
-								"				\"Abbrev\": \"ISO 8879:1986\", "
-								"				\"GlossDef\": { "
-                        		"					\"para\": \"A meta-markup language, used to create markup languages such as DocBook.\", "
-								"					\"GlossSeeAlso\": [\"GML\", \"XML\"] "
-                    			"				  }, "
-								"				\"GlossSee\": \"markup\" "
-                				"			 } "
-            					"		  } "
-        						"	   } "
-    							"  } "
-    							"}";
-
-    JSONParser parser(json_string);
-
-    JSONElement root = parser.root();
-
-    CE_ASSERT(root.has_key("glossary"), "'glossary' not found!");
-
-    CE_LOGI("%s", root.key("glossary").key("GlossDiv").key("title").to_string());
-    CE_LOGI("%s", root.key("glossary").key("title").to_string());
-    CE_LOGI("%s", root.key("glossary").key("GlossDiv").key("GlossList").key("GlossEntry").key("GlossTerm").to_string());
-
-
-	return 0;
-}

+ 0 - 404
engine/tests/messages.cpp

@@ -1,404 +0,0 @@
-#include <cstdio>
-
-#include "Vector3.h"
-#include "OS.h"
-#include "NetAddress.h"
-#include "BitMessage.h"
-#include "HeapAllocator.h"
-
-using namespace crown;
-
-void test_int8()
-{
-	uint32_t bits_written;
-	uint32_t rem_write_bits;
-	uint32_t bits_read;
-	uint32_t rem_read_bits; 
-	
-	HeapAllocator allocator;
-  	network::BitMessage m = network::BitMessage(allocator);
-	
-	int8_t res;
-	
-	m.init(4);
-	m.begin_writing();
-	m.write_int8(-56);
-	bits_written = m.get_num_bits_written();
-	rem_write_bits = m.get_remaining_write_bits();
-
-	res = m.read_int8();
-	bits_read = m.get_num_bits_read();
-	rem_read_bits = m.get_remaining_read_bits();
-	
-	printf("\n-----------------------------\n");
-	printf("start write and read for UINT8\n");
-	printf("value = %d\n", res);
-	printf("bits written = %d\n", bits_written);
-	printf("remaining write bits = %d\n", rem_write_bits);
-	printf("bits read = %d\n", bits_read);
-	printf("remaining read bits = %d\n", rem_read_bits);
-	printf("-----------------------------\n");
-
-	printf("\n");	
-
-}
-
-void test_uint8()
-{
-	uint32_t bits_written;
-	uint32_t rem_write_bits;
-	uint32_t bits_read;
-	uint32_t rem_read_bits; 
-	
-	HeapAllocator allocator;
-  	network::BitMessage m = network::BitMessage(allocator);
-
-	uint8_t res;
-	
-	m.init(4);
-	m.begin_writing();
-	m.write_uint8(255);
-	bits_written = m.get_num_bits_written();
-	rem_write_bits = m.get_remaining_write_bits();
-
-	m.begin_reading();
-	res = m.read_uint8();
-	bits_read = m.get_num_bits_read();
-	rem_read_bits = m.get_remaining_read_bits();
-	
-	printf("\n-----------------------------\n");
-	printf("start write and read for UINT8\n");
-	printf("value = %d\n", res);
-	printf("bits written = %d\n", bits_written);
-	printf("remaining write bits = %d\n", rem_write_bits);
-	printf("bits read = %d\n", bits_read);
-	printf("remaining read bits = %d\n", rem_read_bits);
-	printf("-----------------------------\n");
-
-	printf("\n");
-}
-
-void test_int16()
-{
-	uint32_t bits_written;
-	uint32_t rem_write_bits;
-	uint32_t bits_read;
-	uint32_t rem_read_bits; 
-	
-	HeapAllocator allocator;
-  	network::BitMessage m = network::BitMessage(allocator);  
-	
-	int16_t res;
-	
-	m.init(4);
-	m.write_int16(-5555);
-	bits_written = m.get_num_bits_written();
-	rem_write_bits = m.get_remaining_write_bits();
-
-	res = m.read_int16();
-	bits_read = m.get_num_bits_read();
-	rem_read_bits = m.get_remaining_read_bits();
-	
-	printf("-----------------------------\n");
-	printf("start write and read for INT16\n");
-	printf("value = %d\n", res);
-	printf("bits written = %d\n", bits_written);
-	printf("remaining write bits = %d\n", rem_write_bits);
-	printf("bits read = %d\n", bits_read);
-	printf("remaining read bits = %d\n", rem_read_bits);
-	printf("-----------------------------\n");
-	printf("\n");
-}
-
-void test_uint16()
-{
-  	uint32_t bits_written;
-	uint32_t rem_write_bits;
-	uint32_t bits_read;
-	uint32_t rem_read_bits; 
-
-	HeapAllocator allocator;
-  	network::BitMessage m = network::BitMessage(allocator);
-
-	uint16_t res;
-	
-	m.init(4);
-	m.write_uint16(5555);
-	bits_written = m.get_num_bits_written();
-	rem_write_bits = m.get_remaining_write_bits();
-
-	res = m.read_uint16();
-	bits_read = m.get_num_bits_read();
-	rem_read_bits = m.get_remaining_read_bits();
-	
-	printf("-----------------------------\n");
-	printf("start write and read for UINT16\n");
-	printf("value = %d\n", res);
-	printf("bits written = %d\n", bits_written);
-	printf("remaining write bits = %d\n", rem_write_bits);
-	printf("bits read = %d\n", bits_read);
-	printf("remaining read bits = %d\n", rem_read_bits);
-	printf("-----------------------------\n");
-	printf("\n");
-}
-
-void test_int32()
-{
-  	uint32_t bits_written;
-	uint32_t rem_write_bits;
-	uint32_t bits_read;
-	uint32_t rem_read_bits; 
-
-	HeapAllocator allocator;
-  	network::BitMessage m = network::BitMessage(allocator);
-	
-	int32_t res;
-	
-	m.init(4);
-	m.write_int32(4000000000);
-	bits_written = m.get_num_bits_written();
-	rem_write_bits = m.get_remaining_write_bits();
-	
-	res = m.read_int32();
-	bits_read = m.get_num_bits_read();
-	rem_read_bits = m.get_remaining_read_bits();
-	
-	printf("-----------------------------\n");
-	printf("start write and read for INT32\n");
-	printf("value = %d\n", res);
-	printf("bits written = %d\n", bits_written);
-	printf("remaining write bits = %d\n", rem_write_bits);
-	printf("bits read = %d\n", bits_read);
-	printf("remaining read bits = %d\n", rem_read_bits);
-	printf("-----------------------------\n");
-	printf("\n");
-	
-}
-
-void test_float()
-{
-  	uint32_t bits_written;
-	uint32_t rem_write_bits;
-	uint32_t bits_read;
-	uint32_t rem_read_bits; 
-
-	HeapAllocator allocator;
-  	network::BitMessage m = network::BitMessage(allocator);
-
-	float res;
-	
-	m.init(4);
-	m.write_float(4.5342f);
-	bits_written = m.get_num_bits_written();
-	rem_write_bits = m.get_remaining_write_bits();
-	
-	res = m.read_float();
-	bits_read = m.get_num_bits_read();
-	rem_read_bits = m.get_remaining_read_bits();
-	
-	printf("-----------------------------\n");
-	printf("start write and read for float\n");
-	printf("value = %f\n", res);
-	printf("bits written = %d\n", bits_written);
-	printf("remaining write bits = %d\n", rem_write_bits);
-	printf("bits read = %d\n", bits_read);
-	printf("remaining read bits = %d\n", rem_read_bits);
-	printf("-----------------------------\n");
-	printf("\n");	
-	
-
-}
-
-void test_vec3()
-{
-  	uint32_t bits_written;
-	uint32_t rem_write_bits;
-	uint32_t bits_read;
-	uint32_t rem_read_bits; 
-
-	HeapAllocator allocator;
-  	network::BitMessage m = network::BitMessage(allocator);
-	
-	
-	Vector3 v(0.525f, 0.432f, 0.234f);
-	Vector3 res;
-	
-	m.init(12);
-	m.write_vec3(v);
-	bits_written = m.get_num_bits_written();
-	rem_write_bits = m.get_remaining_write_bits();
-	
-	res = m.read_vec3();
-	bits_read = m.get_num_bits_read();
-	rem_read_bits = m.get_remaining_read_bits();
-	
-	printf("-----------------------------\n");
-	printf("start write and read for VEC_3\n");
-	printf("x = %f, y = %f, z = %f\n", res.x, res.y, res.z);
-	printf("bits written = %d\n", bits_written);
-	printf("remaining write bits = %d\n", rem_write_bits);
-	printf("bits read = %d\n", bits_read);
-	printf("remaining read bits = %d\n", rem_read_bits);
-	printf("-----------------------------\n");
-	printf("\n");	
-}
-
-void test_string()
-{
-  	uint32_t bits_written;
-	uint32_t rem_write_bits;
-	uint32_t bits_read;
-	uint32_t rem_read_bits; 
-
-	HeapAllocator allocator;
-  	network::BitMessage m = network::BitMessage(allocator);
-	
-	uint8_t tmp[16];
-	char res[16];
-
-	char s[] = "test";
-	
-	m.init(16);
-
-	m.write_string(s, sizeof(s), true);
- 	bits_written = m.get_num_bits_written();
-  	rem_write_bits = m.get_remaining_write_bits();	
-	
-	m.read_string(res, 6);
-	bits_read = m.get_num_bits_read();
-	rem_read_bits = m.get_remaining_read_bits();
-
-	printf("-----------------------------\n");
-	printf("start write and read for STRING\n");
- 	printf("string = %s\n", res);
-	printf("sizeof string= %d\n", sizeof(s));
-	printf("bits written = %d\n", bits_written);
-	printf("remaining write bits = %d\n", rem_write_bits);
-	printf("bits read = %d\n", bits_read);
-	printf("remaining read bits = %d\n", rem_read_bits);
-	printf("-----------------------------\n");
-	printf("\n");	
-
-}
-
-void test_data()
-{
-  	uint32_t bits_written;
-	uint32_t rem_write_bits;
-	uint32_t bits_read;
-	uint32_t rem_read_bits; 
-
-	HeapAllocator allocator;
-  	network::BitMessage m = network::BitMessage(allocator);
-	
-	uint8_t tmp[] = "test generic";
-	uint8_t res[16];
-	
-	m.init(16);
-	
-	m.write_data(tmp, 16);
- 	bits_written = m.get_num_bits_written();
-  	rem_write_bits = m.get_remaining_write_bits();	
-	
-	m.read_data(res, 16);
-	bits_read = m.get_num_bits_read();
-	rem_read_bits = m.get_remaining_read_bits();
-	
-	printf("-----------------------------\n");
-	printf("start write and read for GENERIC\n");
-	printf("string = %s\n", res);
-	printf("bits written = %d\n", bits_written);
-	printf("remaining write bits = %d\n", rem_write_bits);
-	printf("bits read = %d\n", bits_read);
-	printf("remaining read bits = %d\n", rem_read_bits);
-	printf("-----------------------------\n");
-	printf("\n");	
-
-}
-
-void test_net_address()
-{
-	uint32_t bits_written;
-	uint32_t rem_write_bits;
-	uint32_t bits_read;
-	uint32_t rem_read_bits; 
-	
-	HeapAllocator allocator;
-	network::BitMessage m = network::BitMessage(allocator);
-
-	uint8_t tmp[16];
-	
-	
-	os::NetAddress addr;
-	os::NetAddress res;
-	
-	addr.set(192, 168, 0, 1, 80);
-	
-	m.init(16);
-	m.write_netaddr(addr);
-	bits_written = m.get_num_bits_written();
-	rem_write_bits = m.get_remaining_write_bits();	
-	
-	m.read_netaddr(&res);
-	bits_read = m.get_num_bits_read();
-	rem_read_bits = m.get_remaining_read_bits();
-	
-	printf("-----------------------------\n");
-	printf("start write and read for NET_ADDRESS\n");
-	printf("a = %d, b = %d, c = %d, d = %d, p = %d\n", res.m_address[0], res.m_address[1], res.m_address[2], res.m_address[3], res.m_port);
-	printf("bits written = %d\n", bits_written);
-	printf("remaining write bits = %d\n", rem_write_bits);
-	printf("bits read = %d\n", bits_read);
-	printf("remaining read bits = %d\n", rem_read_bits);
-	printf("-----------------------------\n");
-	printf("\n");
-}
-
-int main()
-{
-/*	
-	test_int8();
-	test_uint8();
-	test_int16();
-	test_uint16();
-	test_int32();
-	test_float();
-	test_vec3();
-	test_string();
-	test_data();
-	test_net_address();
-*/
-	HeapAllocator allocator;
-	network::BitMessage msg = network::BitMessage(allocator);
-	
-	uint32_t protocol_id = 0xFFFFFFFF;
-	uint16_t sequence = 12345;
-	uint16_t ack	  = 12344;
-	uint32_t ack_bits = 1234543;
-	
-	msg.init(6);
-	msg.set_header(protocol_id, sequence, ack, ack_bits);
-	msg.begin_writing();
-	msg.write_string("prova", 6);
-	
-	msg.begin_reading();
-	uint8_t* header = msg.get_header();
- 	char data[6];
- 	msg.read_string(data, 6);
-	
-	uint32_t tmp1 = header[0] << 24 | header[1] << 16 | header[2] << 8 | header[3];
-	uint16_t tmp2 = header[4] << 8 | header[5];
-	uint16_t tmp3 = header[6] << 8 | header[7];
-	uint32_t tmp4 = header[8] << 24 | header[9] << 16 | header[10] << 8 | header[11];
-	
-	os::printf("protocol_id: %d\n", tmp1);
-	os::printf("sequence: %d\n", tmp2);
-	os::printf("ack: %d\n", tmp3);
-	os::printf("ack_bits: %d\n", tmp4);
- 	os::printf("data: %s\n", data);
-	os::printf("\n");
-
-	
-	
-	return 0;
-}

+ 0 - 108
engine/tests/paths.cpp

@@ -1,108 +0,0 @@
-#include "StringUtils.h"
-#include "Path.h"
-#include "Assert.h"
-#include <stdio.h>
-
-using namespace crown;
-
-int main()
-{	
-	char path_output[128];
-	
-	// Test is_valid_segment
-	CE_ASSERT(path::is_valid_segment(".") == false, "");
-	
-	CE_ASSERT(path::is_valid_segment("/") == false, "");
-	
-	CE_ASSERT(path::is_valid_segment("\\") == false, "");
-
-	CE_ASSERT(path::is_valid_segment(":") == false, "");
-	
-	CE_ASSERT(path::is_valid_segment("tga/") == false, "");
-	
-	CE_ASSERT(path::is_valid_segment("tga\\foo") == false, "");
-	
-	CE_ASSERT(path::is_valid_segment("tga") == true, "");
-	
-	CE_ASSERT(path::is_valid_segment("back_texture") == true, "");
-	
-	// Test pathname
-	path::pathname("/home/project/texture.tga", path_output, 128);
-	CE_ASSERT(string::strcmp("/home/project", path_output) == 0, "");
-
-	path::pathname("/home/project", path_output, 128);
-	CE_ASSERT(string::strcmp("/home", path_output) == 0, "");
-	
-	path::pathname("/home", path_output, 128);
-	CE_ASSERT(string::strcmp("", path_output) == 0, "");
-	
-	path::pathname("/", path_output, 128);
-	CE_ASSERT(string::strcmp("", path_output) == 0, "");
-	
-	path::pathname("", path_output, 128);
-	CE_ASSERT(string::strcmp("", path_output) == 0, "");
-	
-	// Test filename
-	path::filename("/home/project/texture.tga", path_output, 128);
-	CE_ASSERT(string::strcmp("texture.tga", path_output) == 0, "");
-	
-	path::filename("/home/project/texture", path_output, 128);
-	CE_ASSERT(string::strcmp("texture", path_output) == 0, "");
-	
-	path::filename("/home", path_output, 128);
-	CE_ASSERT(string::strcmp("home", path_output) == 0, "");
-	
-	path::filename("/", path_output, 128);
-	CE_ASSERT(string::strcmp("", path_output) == 0, "");
-	
-	path::filename("", path_output, 128);
-	CE_ASSERT(string::strcmp("", path_output) == 0, "");
-
-	// Test basename
-	path::basename("/home/project/texture.tga", path_output, 128);
-	CE_ASSERT(string::strcmp("texture", path_output) == 0, "");
-	
-	path::basename("/home/project/textureabc", path_output, 128);
-	printf(path_output);
-	CE_ASSERT(string::strcmp("textureabc", path_output) == 0, "");
-	
-	path::basename("/hom.e/proj./e.ct/textu.reabc", path_output, 128);
-	CE_ASSERT(string::strcmp("textu", path_output) == 0, "");
-	
-	path::basename("texture.tga", path_output, 128);
-	CE_ASSERT(string::strcmp("texture", path_output) == 0, "");
-	
-	path::basename("/home", path_output, 128);
-	CE_ASSERT(string::strcmp("home", path_output) == 0, "");
-	
-	path::basename("/", path_output, 128);
-	CE_ASSERT(string::strcmp("", path_output) == 0, "");
-	
-	path::basename("", path_output, 128);
-	CE_ASSERT(string::strcmp("", path_output) == 0, "");
-	
-	// Test extension
-	path::extension("/home/project/texture.tga", path_output, 128);
-	CE_ASSERT(string::strcmp("tga", path_output) == 0, "");
-	
-	path::extension("/home/project/texture", path_output, 128);
-	CE_ASSERT(string::strcmp("", path_output) == 0, "");
-	
-	path::extension("/home/project.x/texture.tga", path_output, 128);
-	CE_ASSERT(string::strcmp("tga", path_output) == 0, "");
-	
-	// Test filename_without_extension
-	path::filename_without_extension("/home/project/texture.tga", path_output, 128);
-	CE_ASSERT(string::strcmp("/home/project/texture", path_output) == 0, "");
-	
-	// Test strip_trailing_separator
-	path::strip_trailing_separator("/home/project/texture.tga", path_output, 128);
-	CE_ASSERT(string::strcmp("/home/project/texture.tga", path_output) == 0, "");
-	
-	path::strip_trailing_separator("/home/project/texture2.tga/", path_output, 128);
-	CE_ASSERT(string::strcmp("/home/project/texture2.tga", path_output) == 0, "");
-	
-	path::strip_trailing_separator("texture.tga", path_output, 128);
-	CE_ASSERT(string::strcmp("texture.tga", path_output) == 0, "");
-}
-

+ 0 - 49
engine/tests/strings.cpp

@@ -1,49 +0,0 @@
-#include "StringUtils.h"
-#include "Assert.h"
-#include <stdio.h>
-
-using namespace crown;
-
-const char* hello_string = "/h.ello.everybody.stri/ng";
-const char* path_string = "/home/project/texture.tga";
-
-int main()
-{
-	// Test strlen
-	CE_ASSERT(string::strlen("ciao") == 4, "");
-	// FIXME add UTF-8 test case
-
-	// Test begin/end
-	CE_ASSERT(string::begin(hello_string) == &hello_string[0], "");
-	
-	CE_ASSERT(string::end(hello_string) == &hello_string[24] + 2, "");
-	
-	// Test find_first/find_last
-	CE_ASSERT(string::find_first(hello_string, '.') == &hello_string[2], "");
-	
-	CE_ASSERT(string::find_last(hello_string, '.') == &hello_string[17], "");
-	
-	CE_ASSERT(string::find_first(hello_string, '?') == string::end(hello_string), "");
-	
-	CE_ASSERT(string::find_last(hello_string, '?') == string::end(hello_string), "");
-	
-	CE_ASSERT(string::find_last(hello_string, '/') == &hello_string[22], "");
-	
-	CE_ASSERT(string::find_last(path_string, '/') == &path_string[13], "");
-	
-	// Test substring
-	char string_buffer[64];
-	
-	memset(string_buffer, 'a', 64);
-	string::substring(string::begin(hello_string), string::end(hello_string), string_buffer, 64);
-	CE_ASSERT(string::strcmp(hello_string, string_buffer) == 0, "");
-	
-	memset(string_buffer, 'a', 64);
-	string::substring(string::begin(hello_string), &hello_string[11], string_buffer, 64);
-	CE_ASSERT(string::strcmp(string_buffer, "/h.ello.eve") == 0, "");
-	
-	memset(string_buffer, 'a', 64);
-	string::substring(string::begin(hello_string), string::end(hello_string), string_buffer, 5);
-	CE_ASSERT(string::strcmp(string_buffer, "/h.el") == 0, "");
-}
-