aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2018-01-18 17:01:08 -0800
committerGravatar Muxi Yan <mxyan@google.com>2018-01-18 17:01:08 -0800
commit277e2e4f07744bd0f803efc80440f2e315f6d34a (patch)
tree7cb6a30ba29adc0ce63d544fc96ad94b45114581
parent1164fd6fca13e0b072dd8f08880534481455c15a (diff)
Clean up tests, examples, and podspecs
-rw-r--r--examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.mm24
-rw-r--r--examples/cpp/helloworld/cocoapods/Podfile2
-rw-r--r--templates/gRPC-C++.podspec.template4
-rw-r--r--test/cpp/GRPCCppTests/test/server_context_test_spouse_test.mm10
4 files changed, 13 insertions, 27 deletions
diff --git a/examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.mm b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.mm
index 9cc2460c92..6ff1ca593d 100644
--- a/examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.mm
+++ b/examples/cpp/helloworld/cocoapods/HelloWorldCpp/ViewController.mm
@@ -21,10 +21,10 @@
#include <grpc++/generic/generic_stub.h>
#include <grpc++/generic/async_generic_service.h>
-void* tag(int i) { return (void*)(intptr_t)i; }
+static void* tag(int i) { return (void*)(intptr_t)i; }
// Serialized Proto bytes of Hello World example
-const uint8_t message[] =
+const uint8_t kMessage[] =
{0x0A, 0x0B, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x2D, 0x43};
@interface ViewController ()
@@ -32,7 +32,7 @@ const uint8_t message[] =
@end
@implementation ViewController {
- grpc::CompletionQueue cli_cq_;
+ grpc::CompletionQueue cq_;
std::unique_ptr<grpc::GenericStub> generic_stub_;
}
@@ -50,23 +50,23 @@ const uint8_t message[] =
grpc::ClientContext cli_ctx;
std::unique_ptr<grpc::GenericClientAsyncReaderWriter> call =
- generic_stub_->Call(&cli_ctx, kMethodName, &cli_cq_, tag(1));
- cli_cq_.Next(&got_tag, &ok);
+ generic_stub_->Call(&cli_ctx, kMethodName, &cq_, tag(1));
+ cq_.Next(&got_tag, &ok);
if (!ok || got_tag != tag(1)) {
NSLog(@"Failed to create call.");
abort();
}
- grpc::Slice send_slice = grpc::Slice(message, sizeof(message) / sizeof(message[0]));
+ grpc::Slice send_slice = grpc::Slice(kMessage, sizeof(kMessage) / sizeof(kMessage[0]));
std::unique_ptr<grpc::ByteBuffer> send_buffer(new grpc::ByteBuffer(&send_slice, 1));
call->Write(*send_buffer, tag(2));
- cli_cq_.Next(&got_tag, &ok);
+ cq_.Next(&got_tag, &ok);
if (!ok || got_tag != tag(2)) {
NSLog(@"Failed to send message.");
abort();
}
grpc::ByteBuffer recv_buffer;
call->Read(&recv_buffer, tag(3));
- cli_cq_.Next(&got_tag, &ok);
+ cq_.Next(&got_tag, &ok);
if (!ok || got_tag != tag(3)) {
NSLog(@"Failed to receive message.");
abort();
@@ -74,7 +74,7 @@ const uint8_t message[] =
grpc::Status status;
call->Finish(&status, tag(4));
- cli_cq_.Next(&got_tag, &ok);
+ cq_.Next(&got_tag, &ok);
if (!ok || got_tag != tag(4)) {
NSLog(@"Failed to finish call.");
abort();
@@ -98,10 +98,4 @@ const uint8_t message[] =
"Expected bytes: 0a 11 48 65 6c 6c 6f 20 4f 62 6a 65 63 74 69 76 65 2d 43", recvBytes);
}
-
-- (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
-}
-
-
@end
diff --git a/examples/cpp/helloworld/cocoapods/Podfile b/examples/cpp/helloworld/cocoapods/Podfile
index a471fe03cf..5467f97080 100644
--- a/examples/cpp/helloworld/cocoapods/Podfile
+++ b/examples/cpp/helloworld/cocoapods/Podfile
@@ -1,8 +1,6 @@
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
-source 'https://github.com/muxi/grpc-pod.git'
-
install! 'cocoapods', :deterministic_uuids => false
target 'HelloWorldCpp' do
diff --git a/templates/gRPC-C++.podspec.template b/templates/gRPC-C++.podspec.template
index 0c4d9a583b..78adb27915 100644
--- a/templates/gRPC-C++.podspec.template
+++ b/templates/gRPC-C++.podspec.template
@@ -185,9 +185,9 @@
end
s.prepare_command = <<-END_OF_COMMAND
- find src/cpp/ -type f -exec sed -E -i '.back' 's;#include "third_party/nanopb/(.*)";#include <nanopb/\\1>;g' {} \\\;
+ find src/cpp/ -type f -exec sed -E -i'.back' 's;#include "third_party/nanopb/(.*)";#include <nanopb/\\1>;g' {} \\\;
find src/cpp/ -name "*.back" -type f -delete
- find src/core/ -regex ".*\.h" -type f -exec sed -E -i '.back' 's;#include "third_party/nanopb/(.*)";#include <nanopb/\\1>;g' {} \\\;
+ find src/core/ -regex ".*\.h" -type f -exec sed -E -i'.back' 's;#include "third_party/nanopb/(.*)";#include <nanopb/\\1>;g' {} \\\;
find src/core/ -name "*.back" -type f -delete
END_OF_COMMAND
end
diff --git a/test/cpp/GRPCCppTests/test/server_context_test_spouse_test.mm b/test/cpp/GRPCCppTests/test/server_context_test_spouse_test.mm
index f947a2896c..fd6878efbf 100644
--- a/test/cpp/GRPCCppTests/test/server_context_test_spouse_test.mm
+++ b/test/cpp/GRPCCppTests/test/server_context_test_spouse_test.mm
@@ -16,6 +16,8 @@
*
*/
+// Hack TEST macro of gTest and make they conform XCTest style. We only
+// need test name (b), not test case name (a).
#define TEST(a,b) - (void)test ## b
#define ASSERT_TRUE XCTAssert
#define ASSERT_EQ XCTAssertEqual
@@ -95,12 +97,4 @@ TEST(ServerContextTestSpouseTest, TrailingMetadata) {
ASSERT_EQ(metadata, spouse.GetTrailingMetadata());
}
-- (void)setUp {
- [super setUp];
-}
-
-- (void)tearDown {
- [super tearDown];
-}
-
@end