MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / TEST

Function TEST

test/cpp/utils/flags_native_test.cc:45–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45TEST(flags_native_test, ParseCommandLineFlags) {
46 uint32_t test_int32 = 2;
47 ASSERT_EQ(FLAGS_paddle_test_int32, 1);
48 ASSERT_EQ(FLAGS_paddle_test_uint32, test_int32);
49 ASSERT_EQ(FLAGS_paddle_test_string, "raw");
50
51 // Construct commandline arguments input
52 std::string commandline =
53 "test --paddle_test_int32=3 --paddle_test_uint32=\"4\" "
54 "--paddle_test_string \"modified string\"";
55 int argc = 0;
56 char** argv = nullptr;
57 SplitCommandlineArg(commandline, &argc, &argv);
58
59 // Parse commandline flags and check
60 ParseCommandLineFlags(&argc, &argv);
61 delete argv;
62
63 test_int32 = 4;
64 ASSERT_EQ(FLAGS_paddle_test_int32, 3);
65 ASSERT_EQ(FLAGS_paddle_test_uint32, test_int32);
66 ASSERT_EQ(FLAGS_paddle_test_string, "modified string");
67
68 // test FindFlag and SetFlagValue
69 ASSERT_TRUE(FindFlag("paddle_test_int32"));
70
71 SetFlagValue("paddle_test_int32", "9");
72 ASSERT_EQ(FLAGS_paddle_test_int32, 9);
73}
74
75#if defined(_POSIX_C_SOURCE) && \
76 _POSIX_C_SOURCE >= 200112L // environment for use setenv

Callers

nothing calls this directly

Calls 6

SplitCommandlineArgFunction · 0.85
SetEnvVarFunction · 0.85
PrintAllFlagHelpFunction · 0.85
ParseCommandLineFlagsFunction · 0.50
FindFlagFunction · 0.50
SetFlagValueFunction · 0.50

Tested by

no test coverage detected