cleanup
This commit is contained in:
parent
9ec36cae77
commit
3704bd944d
52
main.cpp
52
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");
|
||||
}
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user