Daniele Bartolini 13 роки тому
батько
коміт
e87c18d2f6
2 змінених файлів з 45 додано та 0 видалено
  1. 2 0
      tests/CMakeLists.txt
  2. 43 0
      tests/compressors.cpp

+ 2 - 0
tests/CMakeLists.txt

@@ -8,8 +8,10 @@ link_directories(${CROWN_BINARY_DIR})
 add_executable(allocators allocators.cpp)
 add_executable(containers containers.cpp)
 add_executable(messages messages.cpp)
+add_executable(compressors compressors.cpp)
 
 
 target_link_libraries(allocators crown)
 target_link_libraries(containers crown)
 target_link_libraries(messages crown)
+target_link_libraries(compressors crown)

+ 43 - 0
tests/compressors.cpp

@@ -0,0 +1,43 @@
+#include <cstdio>
+#include <cstring>
+#include "MallocAllocator.h"
+#include "ZipCompressor.h"
+
+using namespace crown;
+
+int main(int argc, char** argv)
+{
+	if (argc != 2)
+	{
+		printf("Arguments must be 2");
+		return -1;
+	}
+	
+	MallocAllocator allocator;
+	ZipCompressor compressor(allocator);
+
+	char* file_name = argv[1];
+
+	const char* uncompressed_string = "foobar";
+	uint8_t* result;
+	size_t result_size = 0;
+
+	result = compressor.compress((void*)uncompressed_string, strlen(uncompressed_string), result_size);
+
+	printf("Before: ");
+	printf("Size: %d", strlen(uncompressed_string));
+	printf(uncompressed_string);
+	printf("\n");
+
+	printf("After: ");
+	printf("Size: %d", result_size);
+	for (size_t i = 0; i < result_size; i++)
+	{
+		printf("%c", result[i]);
+	}
+	printf("\n");
+
+//	allocator->deallocate(result);
+	
+	return 0;
+}