Permalink
Browse files

THRIFT-920. cpp: C++ Test and Tutorial does not compile anymore due t…

…o the change within Enum handling

Patch: Roger Meier and Christian Lavoie

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1001826 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent a5df7c7 commit 833ae492902c08ab13ebc4efa73adef0a4936dff Bryan Duxbury committed Sep 27, 2010
Showing with 36 additions and 36 deletions.
  1. +4 −4 test/cpp/Thrift-test.mk
  2. +11 −11 test/cpp/src/TestClient.cpp
  3. +15 −15 test/cpp/src/TestServer.cpp
  4. +2 −2 tutorial/cpp/CppClient.cpp
  5. +4 −4 tutorial/cpp/CppServer.cpp
View
8 test/cpp/Thrift-test.mk
@@ -59,16 +59,16 @@ stubs: ../ThriftTest.thrift
$(THRIFT) --gen cpp ../ThriftTest.thrift
server-debug: stubs
- g++ -o TestServer $(DCFL) src/TestServer.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp ../ThriftTest_extras.cpp
+ g++ -o TestServer $(DCFL) src/TestServer.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp $(thrift_home)/lib/cpp/test/ThriftTest_extras.cpp
client-debug: stubs
- g++ -o TestClient $(DCFL) src/TestClient.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp ../ThriftTest_extras.cpp
+ g++ -o TestClient $(DCFL) src/TestClient.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp $(thrift_home)/lib/cpp/test/ThriftTest_extras.cpp
server: stubs
- g++ -o TestServer $(CFL) src/TestServer.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp ../ThriftTest_extras.cpp
+ g++ -o TestServer $(CFL) src/TestServer.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp $(thrift_home)/lib/cpp/test/ThriftTest_extras.cpp
client: stubs
- g++ -o TestClient $(CFL) src/TestClient.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp ../ThriftTest_extras.cpp
+ g++ -o TestClient $(CFL) src/TestClient.cpp ./gen-cpp/ThriftTest.cpp ./gen-cpp/ThriftTest_types.cpp $(thrift_home)/lib/cpp/test/ThriftTest_extras.cpp
small:
$(THRIFT) --gen cpp ../SmallTest.thrift
View
22 test/cpp/src/TestClient.cpp
@@ -297,23 +297,23 @@ int main(int argc, char** argv) {
* ENUM TEST
*/
printf("testEnum(ONE)");
- Numberz ret = testClient.testEnum(ONE);
+ Numberz::type ret = testClient.testEnum(Numberz::ONE);
printf(" = %d\n", ret);
printf("testEnum(TWO)");
- ret = testClient.testEnum(TWO);
+ ret = testClient.testEnum(Numberz::TWO);
printf(" = %d\n", ret);
printf("testEnum(THREE)");
- ret = testClient.testEnum(THREE);
+ ret = testClient.testEnum(Numberz::THREE);
printf(" = %d\n", ret);
printf("testEnum(FIVE)");
- ret = testClient.testEnum(FIVE);
+ ret = testClient.testEnum(Numberz::FIVE);
printf(" = %d\n", ret);
printf("testEnum(EIGHT)");
- ret = testClient.testEnum(EIGHT);
+ ret = testClient.testEnum(Numberz::EIGHT);
printf(" = %d\n", ret);
/**
@@ -345,27 +345,27 @@ int main(int argc, char** argv) {
* INSANITY TEST
*/
Insanity insane;
- insane.userMap.insert(make_pair(FIVE, 5000));
+ insane.userMap.insert(make_pair(Numberz::FIVE, 5000));
Xtruct truck;
truck.string_thing = "Truck";
truck.byte_thing = 8;
truck.i32_thing = 8;
truck.i64_thing = 8;
insane.xtructs.push_back(truck);
printf("testInsanity()");
- map<UserId, map<Numberz,Insanity> > whoa;
+ map<UserId, map<Numberz::type,Insanity> > whoa;
testClient.testInsanity(whoa, insane);
printf(" = {");
- map<UserId, map<Numberz,Insanity> >::const_iterator i_iter;
+ map<UserId, map<Numberz::type,Insanity> >::const_iterator i_iter;
for (i_iter = whoa.begin(); i_iter != whoa.end(); ++i_iter) {
printf("%"PRId64" => {", i_iter->first);
- map<Numberz,Insanity>::const_iterator i2_iter;
+ map<Numberz::type,Insanity>::const_iterator i2_iter;
for (i2_iter = i_iter->second.begin();
i2_iter != i_iter->second.end();
++i2_iter) {
printf("%d => {", i2_iter->first);
- map<Numberz, UserId> userMap = i2_iter->second.userMap;
- map<Numberz, UserId>::const_iterator um;
+ map<Numberz::type, UserId> userMap = i2_iter->second.userMap;
+ map<Numberz::type, UserId>::const_iterator um;
printf("{");
for (um = userMap.begin(); um != userMap.end(); ++um) {
printf("%d => %"PRId64", ", um->first, um->second);
View
30 test/cpp/src/TestServer.cpp
@@ -138,7 +138,7 @@ class TestHandler : public ThriftTestIf {
out = thing;
}
- Numberz testEnum(const Numberz thing) {
+ Numberz::type testEnum(const Numberz::type thing) {
printf("testEnum(%d)\n", thing);
return thing;
}
@@ -163,7 +163,7 @@ class TestHandler : public ThriftTestIf {
}
- void testInsanity(map<UserId, map<Numberz,Insanity> > &insane, const Insanity &argument) {
+ void testInsanity(map<UserId, map<Numberz::type,Insanity> > &insane, const Insanity &argument) {
printf("testInsanity()\n");
Xtruct hello;
@@ -179,36 +179,36 @@ class TestHandler : public ThriftTestIf {
goodbye.i64_thing = 4;
Insanity crazy;
- crazy.userMap.insert(make_pair(EIGHT, 8));
+ crazy.userMap.insert(make_pair(Numberz::EIGHT, 8));
crazy.xtructs.push_back(goodbye);
Insanity looney;
- crazy.userMap.insert(make_pair(FIVE, 5));
+ crazy.userMap.insert(make_pair(Numberz::FIVE, 5));
crazy.xtructs.push_back(hello);
- map<Numberz, Insanity> first_map;
- map<Numberz, Insanity> second_map;
+ map<Numberz::type, Insanity> first_map;
+ map<Numberz::type, Insanity> second_map;
- first_map.insert(make_pair(TWO, crazy));
- first_map.insert(make_pair(THREE, crazy));
+ first_map.insert(make_pair(Numberz::TWO, crazy));
+ first_map.insert(make_pair(Numberz::THREE, crazy));
- second_map.insert(make_pair(SIX, looney));
+ second_map.insert(make_pair(Numberz::SIX, looney));
insane.insert(make_pair(1, first_map));
insane.insert(make_pair(2, second_map));
printf("return");
printf(" = {");
- map<UserId, map<Numberz,Insanity> >::const_iterator i_iter;
+ map<UserId, map<Numberz::type,Insanity> >::const_iterator i_iter;
for (i_iter = insane.begin(); i_iter != insane.end(); ++i_iter) {
printf("%"PRId64" => {", i_iter->first);
- map<Numberz,Insanity>::const_iterator i2_iter;
+ map<Numberz::type,Insanity>::const_iterator i2_iter;
for (i2_iter = i_iter->second.begin();
i2_iter != i_iter->second.end();
++i2_iter) {
printf("%d => {", i2_iter->first);
- map<Numberz, UserId> userMap = i2_iter->second.userMap;
- map<Numberz, UserId>::const_iterator um;
+ map<Numberz::type, UserId> userMap = i2_iter->second.userMap;
+ map<Numberz::type, UserId>::const_iterator um;
printf("{");
for (um = userMap.begin(); um != userMap.end(); ++um) {
printf("%d => %"PRId64", ", um->first, um->second);
@@ -232,7 +232,7 @@ class TestHandler : public ThriftTestIf {
}
- void testMulti(Xtruct &hello, const int8_t arg0, const int32_t arg1, const int64_t arg2, const std::map<int16_t, std::string> &arg3, const Numberz arg4, const UserId arg5) {
+ void testMulti(Xtruct &hello, const int8_t arg0, const int32_t arg1, const int64_t arg2, const std::map<int16_t, std::string> &arg3, const Numberz::type arg4, const UserId arg5) {
printf("testMulti()\n");
hello.string_thing = "Hello2";
@@ -353,7 +353,7 @@ int main(int argc, char **argv) {
if (!args["workers"].empty()) {
workerCount = atoi(args["workers"].c_str());
}
- } catch (exception& e) {
+ } catch (std::exception& e) {
cerr << e.what() << endl;
cerr << usage;
}
View
4 tutorial/cpp/CppClient.cpp
@@ -53,7 +53,7 @@ int main(int argc, char** argv) {
printf("1+1=%d\n", sum);
Work work;
- work.op = DIVIDE;
+ work.op = Operation::DIVIDE;
work.num1 = 1;
work.num2 = 0;
@@ -64,7 +64,7 @@ int main(int argc, char** argv) {
printf("InvalidOperation: %s\n", io.why.c_str());
}
- work.op = SUBTRACT;
+ work.op = Operation::SUBTRACT;
work.num1 = 15;
work.num2 = 10;
int32_t diff = client.calculate(1, work);
View
8 tutorial/cpp/CppServer.cpp
@@ -61,16 +61,16 @@ class CalculatorHandler : public CalculatorIf {
int32_t val;
switch (work.op) {
- case ADD:
+ case Operation::ADD:
val = work.num1 + work.num2;
break;
- case SUBTRACT:
+ case Operation::SUBTRACT:
val = work.num1 - work.num2;
break;
- case MULTIPLY:
+ case Operation::MULTIPLY:
val = work.num1 * work.num2;
break;
- case DIVIDE:
+ case Operation::DIVIDE:
if (work.num2 == 0) {
InvalidOperation io;
io.what = work.op;

0 comments on commit 833ae49

Please sign in to comment.