Skip to content

Commit dc8543a

Browse files
committed
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.
1 parent 94c2357 commit dc8543a

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

test/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ add_gflags_test(always_fail 1 "ERROR: failed validation of new value 'true' for
154154
# debugger abort() intervention in case of Debug configuration.
155155
#add_gflags_test(deadlock_if_cant_lock 0 "PASS" "" gflags_unittest --deadlock_if_cant_lock)
156156

157+
# ----------------------------------------------------------------------------
158+
# use gflags_declare.h
159+
add_executable (gflags_declare_test gflags_declare_test.cc gflags_declare_flags.cc)
160+
161+
add_test(NAME gflags_declare COMMAND gflags_declare_test --message "Hello gflags!")
162+
set_tests_properties(gflags_declare PROPERTIES PASS_REGULAR_EXPRESSION "Hello gflags!")
163+
157164
# ----------------------------------------------------------------------------
158165
# (negative) compilation tests
159166
if (BUILD_NC_TESTS)

test/gflags_declare_flags.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <iostream>
2+
#include <gflags/gflags_declare.h>
3+
4+
DECLARE_string(message); // in gflags_delcare_test.cc
5+
6+
void print_message()
7+
{
8+
std::cout << FLAGS_message << std::endl;
9+
}

test/gflags_declare_test.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <gflags/gflags.h>
2+
3+
DEFINE_string(message, "", "The message to print");
4+
void print_message(); // in gflags_declare_flags.cc
5+
6+
int main(int argc, char **argv)
7+
{
8+
gflags::SetUsageMessage("Test compilation and use of gflags_declare.h");
9+
gflags::ParseCommandLineFlags(&argc, &argv, true);
10+
print_message();
11+
return 0;
12+
}

0 commit comments

Comments
 (0)