Thrift-2029:Port C++ tests to Windows
Client: cpp
Patch: Ben Craig
Updates cpp tests to work with windows and c++11
diff --git a/lib/cpp/test/AllProtocolTests.tcc b/lib/cpp/test/AllProtocolTests.tcc
index 9155da8..7ccaef5 100644
--- a/lib/cpp/test/AllProtocolTests.tcc
+++ b/lib/cpp/test/AllProtocolTests.tcc
@@ -45,7 +45,7 @@
Val out;
GenericIO::read(protocol, out);
if (out != val) {
- snprintf(errorMessage, ERR_LEN, "Invalid naked test (type: %s)", ClassNames::getName<Val>());
+ THRIFT_SNPRINTF(errorMessage, ERR_LEN, "Invalid naked test (type: %s)", ClassNames::getName<Val>());
throw TException(errorMessage);
}
}
@@ -71,11 +71,11 @@
protocol->readFieldBegin(name, fieldType, fieldId);
if (fieldId != 15) {
- snprintf(errorMessage, ERR_LEN, "Invalid ID (type: %s)", typeid(val).name());
+ THRIFT_SNPRINTF(errorMessage, ERR_LEN, "Invalid ID (type: %s)", typeid(val).name());
throw TException(errorMessage);
}
if (fieldType != type) {
- snprintf(errorMessage, ERR_LEN, "Invalid Field Type (type: %s)", typeid(val).name());
+ THRIFT_SNPRINTF(errorMessage, ERR_LEN, "Invalid Field Type (type: %s)", typeid(val).name());
throw TException(errorMessage);
}
@@ -83,7 +83,7 @@
GenericIO::read(protocol, out);
if (out != val) {
- snprintf(errorMessage, ERR_LEN, "Invalid value read (type: %s)", typeid(val).name());
+ THRIFT_SNPRINTF(errorMessage, ERR_LEN, "Invalid value read (type: %s)", typeid(val).name());
throw TException(errorMessage);
}
@@ -143,8 +143,8 @@
testNaked<TProto, int16_t>((int16_t)-1);
testNaked<TProto, int16_t>((int16_t)-15000);
testNaked<TProto, int16_t>((int16_t)-0x7fff);
- testNaked<TProto, int16_t>(std::numeric_limits<int16_t>::min());
- testNaked<TProto, int16_t>(std::numeric_limits<int16_t>::max());
+ testNaked<TProto, int16_t>((std::numeric_limits<int16_t>::min)());
+ testNaked<TProto, int16_t>((std::numeric_limits<int16_t>::max)());
testField<TProto, T_I16, int16_t>((int16_t)0);
testField<TProto, T_I16, int16_t>((int16_t)1);
@@ -165,8 +165,8 @@
testNaked<TProto, int32_t>(-1);
testNaked<TProto, int32_t>(-15000);
testNaked<TProto, int32_t>(-0xffff);
- testNaked<TProto, int32_t>(std::numeric_limits<int32_t>::min());
- testNaked<TProto, int32_t>(std::numeric_limits<int32_t>::max());
+ testNaked<TProto, int32_t>((std::numeric_limits<int32_t>::min)());
+ testNaked<TProto, int32_t>((std::numeric_limits<int32_t>::max)());
testField<TProto, T_I32, int32_t>(0);
testField<TProto, T_I32, int32_t>(1);
@@ -182,12 +182,12 @@
testField<TProto, T_I32, int32_t>(-15000);
testField<TProto, T_I32, int32_t>(-0xffff);
testField<TProto, T_I32, int32_t>(-0xffffff);
- testNaked<TProto, int64_t>(std::numeric_limits<int32_t>::min());
- testNaked<TProto, int64_t>(std::numeric_limits<int32_t>::max());
- testNaked<TProto, int64_t>(std::numeric_limits<int32_t>::min() + 10);
- testNaked<TProto, int64_t>(std::numeric_limits<int32_t>::max() - 16);
- testNaked<TProto, int64_t>(std::numeric_limits<int64_t>::min());
- testNaked<TProto, int64_t>(std::numeric_limits<int64_t>::max());
+ testNaked<TProto, int64_t>((std::numeric_limits<int32_t>::min)());
+ testNaked<TProto, int64_t>((std::numeric_limits<int32_t>::max)());
+ testNaked<TProto, int64_t>((std::numeric_limits<int32_t>::min)() + 10);
+ testNaked<TProto, int64_t>((std::numeric_limits<int32_t>::max)() - 16);
+ testNaked<TProto, int64_t>((std::numeric_limits<int64_t>::min)());
+ testNaked<TProto, int64_t>((std::numeric_limits<int64_t>::max)());
testNaked<TProto, int64_t>(0);
@@ -219,7 +219,7 @@
printf("%s => OK\n", protoname);
} catch (TException e) {
- snprintf(errorMessage, ERR_LEN, "%s => Test FAILED: %s", protoname, e.what());
+ THRIFT_SNPRINTF(errorMessage, ERR_LEN, "%s => Test FAILED: %s", protoname, e.what());
throw TException(errorMessage);
}
}