Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,7 @@ | ||
new_http_archive( | ||
name = "gtest", | ||
url = "https://github.com/google/googletest/archive/release-1.8.0.zip", | ||
sha256 = "f3ed3b58511efd272eb074a3a6d6fb79d7c2e6a0e374323d1e6bcbcc1ef141bf", | ||
build_file = "gtest.BUILD", | ||
strip_prefix = "googletest-release-1.8.0", | ||
) |
14
gtest.Build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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"], | ||
) |
15
main/BUILD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,15 @@ | ||
cc_library( | ||
name = "hello-greet", | ||
srcs = ["hello-greet.cc"], | ||
hdrs = ["hello-greet.h"], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
cc_binary( | ||
name = "hello-world", | ||
srcs = ["hello-world.cc"], | ||
deps = [ | ||
":hello-greet", | ||
# "//lib:hello-time", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,6 @@ | ||
#include "main/hello-greet.h" | ||
#include <string> | ||
|
||
std::string get_greet(const std::string& who) { | ||
return "Hello " + who; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,8 @@ | ||
#ifndef LIB_HELLO_GREET_H_ | ||
#define LIB_HELLO_GREET_H_ | ||
|
||
#include <string> | ||
|
||
std::string get_greet(const std::string &thing); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,12 @@ | ||
#include "main/hello-greet.h" | ||
#include <iostream> | ||
#include <string> | ||
|
||
int main(int argc, char** argv) { | ||
std::string who = "world"; | ||
if (argc > 1) { | ||
who = argv[1]; | ||
} | ||
std::cout << get_greet(who) << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,9 @@ | ||
cc_test( | ||
name = "hello-test", | ||
srcs = ["hello-test.cc"], | ||
copts = ["-Iexternal/gtest/include"], | ||
deps = [ | ||
"@gtest//:main", | ||
"//main:hello-greet", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,6 @@ | ||
#include "gtest/gtest.h" | ||
#include "lib/hello-greet.h" | ||
|
||
TEST(HelloTest, GetGreet) { | ||
EXPECT_EQ(get_greet("Bazel"), "Hello Bazel"); | ||
} |