This commit is contained in:
Alex Yatskov 2011-09-04 11:49:21 -07:00
parent 9ec36cae77
commit 3704bd944d
2 changed files with 55 additions and 3 deletions

View File

@ -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() { static void serverTest() {
printf("Server test!\n"); printf("Server test!\n");
} }

View File

@ -45,10 +45,12 @@ const int SOCKET_INVALID = -1;
#ifdef _WIN32 #ifdef _WIN32
#pragma comment(lib, "ws2_32.lib")
struct WsaScope { struct WsaScope {
WsaScope() { WsaScope() {
WSAData data; WSAData data;
WSAStartup(MAKEWORD(2, 2), &data); WSAStartup(MAKEWORD(2, 2), &data);
} }
~WsaScope() { ~WsaScope() {