From dc8543a4738548dda6f210cca035693e19c7042d Mon Sep 17 00:00:00 2001 From: Andreas Schuh Date: Sun, 30 Mar 2014 15:16:00 +0100 Subject: [PATCH] Add test which uses gflags_declare.h. Update issue 79 Added a test which uses gflags_declare.h as any other project would use it to avoid such avoidable build configuration mistakes. --- test/CMakeLists.txt | 7 +++++++ test/gflags_declare_flags.cc | 9 +++++++++ test/gflags_declare_test.cc | 12 ++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 test/gflags_declare_flags.cc create mode 100644 test/gflags_declare_test.cc diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 49c97ea..ff07474 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -155,6 +155,13 @@ add_gflags_test(always_fail 1 "ERROR: failed validation of new value 'true' for #add_gflags_test(deadlock_if_cant_lock 0 "PASS" "" gflags_unittest --deadlock_if_cant_lock) # ---------------------------------------------------------------------------- +# use gflags_declare.h +add_executable (gflags_declare_test gflags_declare_test.cc gflags_declare_flags.cc) + +add_test(NAME gflags_declare COMMAND gflags_declare_test --message "Hello gflags!") +set_tests_properties(gflags_declare PROPERTIES PASS_REGULAR_EXPRESSION "Hello gflags!") + +# ---------------------------------------------------------------------------- # (negative) compilation tests if (BUILD_NC_TESTS) find_package (PythonInterp) diff --git a/test/gflags_declare_flags.cc b/test/gflags_declare_flags.cc new file mode 100644 index 0000000..dc53de5 --- /dev/null +++ b/test/gflags_declare_flags.cc @@ -0,0 +1,9 @@ +#include +#include + +DECLARE_string(message); // in gflags_delcare_test.cc + +void print_message() +{ + std::cout << FLAGS_message << std::endl; +} diff --git a/test/gflags_declare_test.cc b/test/gflags_declare_test.cc new file mode 100644 index 0000000..707bcc0 --- /dev/null +++ b/test/gflags_declare_test.cc @@ -0,0 +1,12 @@ +#include + +DEFINE_string(message, "", "The message to print"); +void print_message(); // in gflags_declare_flags.cc + +int main(int argc, char **argv) +{ + gflags::SetUsageMessage("Test compilation and use of gflags_declare.h"); + gflags::ParseCommandLineFlags(&argc, &argv, true); + print_message(); + return 0; +} -- 2.7.4