summaryrefslogtreecommitdiff
path: root/test/cpp
diff options
context:
space:
mode:
authorJames E. King, III <jking@apache.org>2017-01-20 10:11:41 -0500
committerJames E. King, III <jking@apache.org>2017-01-20 10:12:06 -0500
commit7edc8faefd391ce11eca3023a35cc54bcb2eb1af (patch)
tree961c2fccc47ba9cc0a5d70b9b9314950699ea521 /test/cpp
parente0ccbd6e62e14f32d7c5fe0f9cec6eff3259b863 (diff)
downloadthrift-7edc8faefd391ce11eca3023a35cc54bcb2eb1af.tar.gz
THRIFT-3873: fix various compiler warnings and overflow errors
THRIFT-3847: change VERSION to PACKAGE_VERSION to avoid conflicts with third party or OS headers This closes #1128
Diffstat (limited to 'test/cpp')
-rwxr-xr-xtest/cpp/CMakeLists.txt1
-rwxr-xr-xtest/cpp/Makefile.am2
-rw-r--r--test/cpp/src/TestClient.cpp46
-rw-r--r--test/cpp/src/TestServer.cpp10
4 files changed, 37 insertions, 22 deletions
diff --git a/test/cpp/CMakeLists.txt b/test/cpp/CMakeLists.txt
index 09850a814..1facfa435 100755
--- a/test/cpp/CMakeLists.txt
+++ b/test/cpp/CMakeLists.txt
@@ -33,7 +33,6 @@ include_directories("${CMAKE_CURRENT_BINARY_DIR}")
include_directories("${CMAKE_CURRENT_BINARY_DIR}/gen-cpp")
include_directories("${PROJECT_SOURCE_DIR}/lib/cpp/src")
-
set(crosstestgencpp_SOURCES
gen-cpp/ThriftTest.cpp
gen-cpp/ThriftTest_types.cpp
diff --git a/test/cpp/Makefile.am b/test/cpp/Makefile.am
index 9c4ac0731..d825bdd21 100755
--- a/test/cpp/Makefile.am
+++ b/test/cpp/Makefile.am
@@ -107,7 +107,7 @@ gen-cpp/StressTest_types.cpp gen-cpp/StressTest_constants.cpp gen-cpp/Service.cp
$(THRIFT) --gen cpp $<
AM_CPPFLAGS = $(BOOST_CPPFLAGS) $(LIBEVENT_CPPFLAGS) -I$(top_srcdir)/lib/cpp/src -Igen-cpp
-AM_CXXFLAGS = -Wall -Wextra -pedantic
+AM_CXXFLAGS = -Wall -Wextra -pedantic -D__STDC_LIMIT_MACROS
AM_LDFLAGS = $(BOOST_LDFLAGS) $(LIBEVENT_LDFLAGS) $(ZLIB_LIBS)
clean-local:
diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp
index c16d04544..da20b892e 100644
--- a/test/cpp/src/TestClient.cpp
+++ b/test/cpp/src/TestClient.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -17,8 +17,6 @@
* under the License.
*/
-#define __STDC_FORMAT_MACROS
-#include <inttypes.h>
#include <limits>
#include <locale>
#include <ios>
@@ -35,6 +33,13 @@
#include <thrift/async/TEvhttpClientChannel.h>
#include <thrift/server/TNonblockingServer.h> // <event.h>
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
#include <boost/shared_ptr.hpp>
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
@@ -355,6 +360,10 @@ int main(int argc, char** argv) {
}
try {
+#ifdef _MSC_VER
+#pragma warning( push )
+#pragma warning( disable : 4566 )
+#endif
string str(
"}{Afrikaans, Alemannisch, Aragonés, العربية, مصرى, "
"Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, "
@@ -381,6 +390,9 @@ int main(int argc, char** argv) {
"Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, "
"Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, "
"Bân-lâm-gú, 粵語");
+#ifdef _MSC_VER
+#pragma warning( pop )
+#endif
cout << "testString(" << str << ") = " << flush;
testClient.testString(s, str);
cout << s << endl;
@@ -457,10 +469,10 @@ int main(int argc, char** argv) {
BASETYPE_IDENTITY_TEST(testI64, (int64_t)-1);
BASETYPE_IDENTITY_TEST(testI64, (int64_t)7000000000000000123LL);
BASETYPE_IDENTITY_TEST(testI64, (int64_t)-7000000000000000123LL);
- BASETYPE_IDENTITY_TEST(testI64, (int64_t)pow(2LL, 32));
- BASETYPE_IDENTITY_TEST(testI64, (int64_t)-pow(2LL, 32));
- BASETYPE_IDENTITY_TEST(testI64, (int64_t)pow(2LL, 32) + 1);
- BASETYPE_IDENTITY_TEST(testI64, (int64_t)-pow(2LL, 32) - 1);
+ BASETYPE_IDENTITY_TEST(testI64, (int64_t)pow(static_cast<double>(2LL), 32));
+ BASETYPE_IDENTITY_TEST(testI64, (int64_t)-pow(static_cast<double>(2LL), 32));
+ BASETYPE_IDENTITY_TEST(testI64, (int64_t)pow(static_cast<double>(2LL), 32) + 1);
+ BASETYPE_IDENTITY_TEST(testI64, (int64_t)-pow(static_cast<double>(2LL), 32) - 1);
BASETYPE_IDENTITY_TEST(testI64, numeric_limits<int64_t>::max());
BASETYPE_IDENTITY_TEST(testI64, numeric_limits<int64_t>::min());
@@ -472,19 +484,19 @@ int main(int argc, char** argv) {
BASETYPE_IDENTITY_TEST(testDouble, -1.0);
BASETYPE_IDENTITY_TEST(testDouble, -5.2098523);
BASETYPE_IDENTITY_TEST(testDouble, -0.000341012439638598279);
- BASETYPE_IDENTITY_TEST(testDouble, pow(2, 32));
- BASETYPE_IDENTITY_TEST(testDouble, pow(2, 32) + 1);
- BASETYPE_IDENTITY_TEST(testDouble, pow(2, 53) - 1);
- BASETYPE_IDENTITY_TEST(testDouble, -pow(2, 32));
- BASETYPE_IDENTITY_TEST(testDouble, -pow(2, 32) - 1);
- BASETYPE_IDENTITY_TEST(testDouble, -pow(2, 53) + 1);
+ BASETYPE_IDENTITY_TEST(testDouble, pow(static_cast<double>(2), 32));
+ BASETYPE_IDENTITY_TEST(testDouble, pow(static_cast<double>(2), 32) + 1);
+ BASETYPE_IDENTITY_TEST(testDouble, pow(static_cast<double>(2), 53) - 1);
+ BASETYPE_IDENTITY_TEST(testDouble, -pow(static_cast<double>(2), 32));
+ BASETYPE_IDENTITY_TEST(testDouble, -pow(static_cast<double>(2), 32) - 1);
+ BASETYPE_IDENTITY_TEST(testDouble, -pow(static_cast<double>(2), 53) + 1);
try {
- double expected = pow(10, 307);
+ double expected = pow(static_cast<double>(10), 307);
cout << "testDouble(" << expected << ") = " << flush;
double actual = testClient.testDouble(expected);
cout << "(" << actual << ")" << endl;
- if (expected - actual > pow(10, 292)) {
+ if (expected - actual > pow(static_cast<double>(10), 292)) {
cout << "*** FAILED ***" << endl
<< "Expected: " << expected << " but got: " << actual << endl;
}
@@ -496,11 +508,11 @@ int main(int argc, char** argv) {
}
try {
- double expected = pow(10, -292);
+ double expected = pow(static_cast<double>(10), -292);
cout << "testDouble(" << expected << ") = " << flush;
double actual = testClient.testDouble(expected);
cout << "(" << actual << ")" << endl;
- if (expected - actual > pow(10, -307)) {
+ if (expected - actual > pow(static_cast<double>(10), -307)) {
cout << "*** FAILED ***" << endl
<< "Expected: " << expected << " but got: " << actual << endl;
}
diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp
index b4378608b..b86b34c17 100644
--- a/test/cpp/src/TestServer.cpp
+++ b/test/cpp/src/TestServer.cpp
@@ -17,9 +17,6 @@
* under the License.
*/
-#define __STDC_FORMAT_MACROS
-#include <inttypes.h>
-
#include <thrift/concurrency/ThreadManager.h>
#include <thrift/concurrency/PlatformThreadFactory.h>
#include <thrift/protocol/TBinaryProtocol.h>
@@ -41,6 +38,13 @@
#include <thrift/transport/TTransportUtils.h>
#include "ThriftTest.h"
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
#include <iostream>
#include <stdexcept>
#include <sstream>