| 24 | using namespace paddle::flags; // NOLINT |
| 25 | |
| 26 | void 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 | |
| 45 | TEST(flags_native_test, ParseCommandLineFlags) { |
| 46 | uint32_t test_int32 = 2; |