Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 1 | #include "examples/cpp/hello-lib.h" |
| 2 | |
Kristina Chodorow | f01b229 | 2015-03-02 16:08:28 +0000 | [diff] [blame] | 3 | #include <string> |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 4 | |
Kristina Chodorow | f01b229 | 2015-03-02 16:08:28 +0000 | [diff] [blame] | 5 | using hello::HelloLib; |
| 6 | using std::string; |
| 7 | |
| 8 | /** |
| 9 | * This prints "Hello world". If it is run with arguments, it will use the first |
| 10 | * argument instead of "world". Build and run //examples/cpp:hello-world to see |
| 11 | * this program in action. |
| 12 | * |
| 13 | * This file does double-duty as a "test." It is a cc_binary, so it can also be |
| 14 | * compiled as a cc_test and Bazel will decide on whether it passed or failed |
| 15 | * based on exit code (which is always 0 here, so the test "passes"). See |
| 16 | * hello-fail.cc for an example of making a test fail. |
| 17 | */ |
| 18 | int main(int argc, char** argv) { |
| 19 | HelloLib lib("Hello"); |
| 20 | string thing = "world"; |
| 21 | if (argc > 1) { |
| 22 | thing = argv[1]; |
| 23 | } |
| 24 | lib.greet(thing); |
Han-Wen Nienhuys | d08b27f | 2015-02-25 16:45:20 +0100 | [diff] [blame] | 25 | return 0; |
| 26 | } |