From: Andreas Schuh Date: Sun, 30 Mar 2014 14:16:00 +0000 (+0100) Subject: Add test which uses gflags_declare.h. X-Git-Tag: accepted/tizen/5.0/unified/20181102.024438~126^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dc8543a4738548dda6f210cca035693e19c7042d;p=platform%2Fupstream%2Fgflags.git 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. --- 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; +}