summaryrefslogtreecommitdiff
path: root/test/cpp
diff options
context:
space:
mode:
authorZezeng Wang <51382517@qq.com>2020-04-28 14:23:15 +0800
committerGitHub <noreply@github.com>2020-04-28 07:23:15 +0100
commit371d92f159d4e518f1de81519b3a9de629ba8970 (patch)
tree6b8145ed28390af78f2d6ffc6269db55f18ec6b7 /test/cpp
parent87462913428f9463c537223f2d23bbbf56cddb43 (diff)
downloadthrift-371d92f159d4e518f1de81519b3a9de629ba8970.tar.gz
THRIFT-5179: Fix generated code for struct's named "a" or "b"
Client: cpp
Diffstat (limited to 'test/cpp')
-rwxr-xr-xtest/cpp/CMakeLists.txt17
-rwxr-xr-xtest/cpp/Makefile.am3
-rw-r--r--test/cpp/src/SpecificNameTest.cpp29
3 files changed, 49 insertions, 0 deletions
diff --git a/test/cpp/CMakeLists.txt b/test/cpp/CMakeLists.txt
index 367b6decc..9ecc17183 100755
--- a/test/cpp/CMakeLists.txt
+++ b/test/cpp/CMakeLists.txt
@@ -56,6 +56,13 @@ set(crossstressgencpp_SOURCES
add_library(crossstressgencpp STATIC ${crossstressgencpp_SOURCES})
LINK_AGAINST_THRIFT_LIBRARY(crossstressgencpp thrift)
+set(crossspecificnamegencpp_SOURCES
+ gen-cpp/EchoService.cpp
+ gen-cpp/SpecificNameTest_types.cpp
+)
+add_library(crossspecificnamegencpp STATIC ${crossspecificnamegencpp_SOURCES})
+LINK_AGAINST_THRIFT_LIBRARY(crossspecificnamegencpp thrift)
+
add_executable(TestServer src/TestServer.cpp)
target_link_libraries(TestServer crosstestgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
LINK_AGAINST_THRIFT_LIBRARY(TestServer thrift)
@@ -86,6 +93,12 @@ if (NOT WIN32 AND NOT CYGWIN)
add_test(NAME StressTestNonBlocking COMMAND StressTestNonBlocking)
endif()
+add_executable(SpecificNameTest src/SpecificNameTest.cpp)
+target_link_libraries(SpecificNameTest crossspecificnamegencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB})
+LINK_AGAINST_THRIFT_LIBRARY(SpecificNameTest thrift)
+LINK_AGAINST_THRIFT_LIBRARY(SpecificNameTest thriftnb)
+add_test(NAME SpecificNameTest COMMAND SpecificNameTest)
+
#
# Common thrift code generation rules
#
@@ -97,3 +110,7 @@ add_custom_command(OUTPUT gen-cpp/SecondService.cpp gen-cpp/SecondService.h gen-
add_custom_command(OUTPUT gen-cpp/Service.cpp
COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/StressTest.thrift
)
+
+add_custom_command(OUTPUT gen-cpp/EchoService.cpp gen-cpp/SpecificNameTest_types.cpp
+ COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/SpecificNameTest.thrift
+)
diff --git a/test/cpp/Makefile.am b/test/cpp/Makefile.am
index 4f77c1501..d3754f478 100755
--- a/test/cpp/Makefile.am
+++ b/test/cpp/Makefile.am
@@ -103,6 +103,9 @@ gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_constants
gen-cpp/Service.cpp: $(top_srcdir)/test/StressTest.thrift $(THRIFT)
$(THRIFT) --gen cpp $<
+gen-cpp/SpecificNameTest_types.cpp gen-cpp/EchoService.cpp: $(top_srcdir)/test/SpecificName.thrift $(THRIFT)
+ $(THRIFT) --gen cpp $<
+
AM_CPPFLAGS = $(BOOST_CPPFLAGS) $(LIBEVENT_CPPFLAGS) -I$(top_srcdir)/lib/cpp/src -Igen-cpp -I.
AM_CXXFLAGS = -Wall -Wextra -pedantic -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
AM_LDFLAGS = $(BOOST_LDFLAGS) $(LIBEVENT_LDFLAGS) $(ZLIB_LIBS)
diff --git a/test/cpp/src/SpecificNameTest.cpp b/test/cpp/src/SpecificNameTest.cpp
new file mode 100644
index 000000000..9c31ac10f
--- /dev/null
+++ b/test/cpp/src/SpecificNameTest.cpp
@@ -0,0 +1,29 @@
+/*
+ * 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
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+int main(int argc, char** argv) {
+
+ //Empty in main function,
+ //because we just want to test
+ //whether the generated source code
+ //(IDL file contains struct named as
+ //'a' or 'b') can be compiled.
+
+ return 0;
+}