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

Function SplitCommandlineArg

test/cpp/utils/flags_native_test.cc:26–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24using namespace paddle::flags; // NOLINT
25
26void SplitCommandlineArg(const std::string& commandline,
27 int* argc,
28 char*** argv) {
29 static std::vector<std::string> args;
30 args.clear();
31 for (size_t start_pos = 0, end_pos = 0;
32 start_pos < commandline.size() && end_pos != std::string::npos;
33 start_pos = end_pos + 1) {
34 end_pos = commandline.find(' ', start_pos);
35 args.push_back(commandline.substr(start_pos, end_pos - start_pos));
36 }
37 args.push_back(""); // test empty argument
38 *argc = static_cast<int>(args.size());
39 *argv = new char*[*argc];
40 for (size_t i = 0; i < args.size(); i++) {
41 (*argv)[i] = const_cast<char*>(args[i].c_str());
42 }
43}
44
45TEST(flags_native_test, ParseCommandLineFlags) {
46 uint32_t test_int32 = 2;

Callers 1

TESTFunction · 0.85

Calls 5

c_strMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected