parent
8013d17dfa
commit
9b94773a7f
@ -1,8 +1,22 @@
|
|||||||
|
# External dependency to grpc-enabled Google-styleprotobuf bulding
|
||||||
|
# rules. This method comes from
|
||||||
|
# https://github.com/pubref/rules_protobuf#usage.
|
||||||
git_repository(
|
git_repository(
|
||||||
name = "org_pubref_rules_protobuf",
|
name = "org_pubref_rules_protobuf",
|
||||||
remote = "https://github.com/pubref/rules_protobuf",
|
remote = "https://github.com/pubref/rules_protobuf",
|
||||||
tag = "v0.7.1",
|
tag = "v0.7.1",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# External dependency to gtest 1.7.0. This method comes from
|
||||||
|
# https://www.bazel.io/versions/master/docs/tutorial/cpp.html.
|
||||||
|
new_http_archive(
|
||||||
|
name = "gtest",
|
||||||
|
url = "https://github.com/google/googletest/archive/release-1.7.0.zip",
|
||||||
|
sha256 = "b58cb7547a28b2c718d1e38aee18a3659c9e3ff52440297e965f5edffe34b6d0",
|
||||||
|
build_file = "third_party/gtest.BUILD",
|
||||||
|
strip_prefix = "googletest-release-1.7.0",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
load("@org_pubref_rules_protobuf//cpp:rules.bzl", "cpp_proto_repositories")
|
load("@org_pubref_rules_protobuf//cpp:rules.bzl", "cpp_proto_repositories")
|
||||||
cpp_proto_repositories()
|
cpp_proto_repositories()
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
cc_library(
|
||||||
|
name = "main",
|
||||||
|
srcs = glob(
|
||||||
|
["src/*.cc"],
|
||||||
|
exclude = ["src/gtest-all.cc"]
|
||||||
|
),
|
||||||
|
hdrs = glob([
|
||||||
|
"include/**/*.h",
|
||||||
|
"src/*.h"
|
||||||
|
]),
|
||||||
|
copts = ["-Iexternal/gtest/include"],
|
||||||
|
linkopts = ["-pthread"],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
@ -1,6 +1,11 @@
|
|||||||
#include "third_party/protobuf_test/example_lib.h"
|
#include "third_party/protobuf_test/example_lib.h"
|
||||||
#include <string>
|
|
||||||
|
|
||||||
std::string get_greet(const ::protos::Greeting& who) {
|
namespace third_party {
|
||||||
|
namespace protobuf_test {
|
||||||
|
|
||||||
|
std::string get_greet(const Greeting& who) {
|
||||||
return "Hello " + who.name();
|
return "Hello " + who.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace protobuf_test
|
||||||
|
} // namespace thrid_party
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
#include "third_party/protobuf_test/example_lib.h"
|
||||||
|
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
namespace third_party {
|
||||||
|
namespace protobuf_test {
|
||||||
|
|
||||||
|
TEST(ProtobufTest, GetGreet) {
|
||||||
|
Greeting g;
|
||||||
|
g.set_name("Paddle");
|
||||||
|
EXPECT_EQ("Hello Paddle", get_greet(g));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace protobuf_test
|
||||||
|
} // namespace third_party
|
Loading…
Reference in new issue