From 3704bd944debaa9fab2095a249fe90d05859870d Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 4 Sep 2011 11:49:21 -0700 Subject: [PATCH] cleanup --- main.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++- mc_socket.cpp | 6 ++++-- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 357cee0..183348b 100644 --- a/main.cpp +++ b/main.cpp @@ -38,9 +38,59 @@ static const int SERVER_MAX_CLIENTS = 1; // -// Local functions +// Serial unit tests // +static const char serialTestData[] = "SerializationTests"; +static const int serialTestDataSize = sizeof(serialTestData); + +struct ComplexLocalSerial { + bool serialize(Serializer* serializer) const { + printf("ComplexLocalSerial::serialize:\n"); + + const bool result = serializer->writeRaw(serialTestData, serialTestDataSize); + if (result) { + printf("\t[SUCCESS] Wrote data\n"); + } + else { + printf("\t[ERROR] Error writing data\n"); + } + + return result; + } + + bool deserialize(Deserializer* deserializer) { + printf("ComplexLocalSerial::deserialize:\n"); + + const char * data = deserializer->readRaw(serialTestDataSize); + if (data == NULL) { + printf("\t*** Error reading data\n"); + } + else if (memcmp(data, serialTestData, serialTestDataSize) != 0) { + printf("\t*** Error reading correct data\n"); + } + else { + printf("\tRead data\n"); + } + + const bool success = deserializer->readRaw(buffer); + serialTestDataSize + + deserializer-> + } +}; + +static void unitTestSerialization() { + Buffer buffer; + + + + + +} + + + static void serverTest() { printf("Server test!\n"); } diff --git a/mc_socket.cpp b/mc_socket.cpp index 148832f..8c44d97 100644 --- a/mc_socket.cpp +++ b/mc_socket.cpp @@ -45,10 +45,12 @@ const int SOCKET_INVALID = -1; #ifdef _WIN32 +#pragma comment(lib, "ws2_32.lib") + struct WsaScope { WsaScope() { - WSAData data; - WSAStartup(MAKEWORD(2, 2), &data); + WSAData data; + WSAStartup(MAKEWORD(2, 2), &data); } ~WsaScope() {