| 1 |
#include <fstream> |
| 2 |
#include <iostream> |
| 3 |
#include <string> |
| 4 |
|
| 5 |
int main(int argc, char** argv) |
| 6 |
{ |
| 7 |
// Note: GoogleTest.cmake doesn't actually depend on Google Test as such; |
| 8 |
// it only requires that we produces output in the expected format when |
| 9 |
// invoked with --gtest_list_tests. Thus, we fake that here. This allows us |
| 10 |
// to test the module without actually needing Google Test. |
| 11 |
if (argc > 2 && std::string(argv[1]) == "--gtest_list_tests" && |
| 12 |
std::string(argv[2]).find("--gtest_output=json:") != std::string::npos) { |
| 13 |
std::cout << "test_list_test/test.\n"; |
| 14 |
std::cout << " case/0 # GetParam() = \"semicolon;\"\n"; |
| 15 |
std::cout << " case/1 # GetParam() = 'osb['\n"; |
| 16 |
std::cout << " case/2 # GetParam() = 'csb]'\n"; |
| 17 |
std::cout << " case/3 # GetParam() = 'S p a c e s'\n"; |
| 18 |
|
| 19 |
std::string output_param(argv[2]); |
| 20 |
std::string::size_type split = output_param.find(":"); |
| 21 |
std::string filepath = output_param.substr(split + 1); |
| 22 |
// The full file path is passed |
| 23 |
std::ofstream ostrm(filepath.c_str(), std::ios::binary); |
| 24 |
if (!ostrm) { |
| 25 |
std::cerr << "Failed to create file: " << filepath.c_str() << std::endl; |
| 26 |
return 1; |
| 27 |
} |
| 28 |
ostrm |
| 29 |
<< "{\n" |
| 30 |
" \"tests\": 4,\n" |
| 31 |
" \"name\": \"AllTests\",\n" |
| 32 |
" \"testsuites\": [\n" |
| 33 |
" {\n" |
| 34 |
" \"name\": \"test_list_test/test\",\n" |
| 35 |
" \"tests\": 4,\n" |
| 36 |
" \"testsuite\": [\n" |
| 37 |
" { \"name\": \"case/0\", \"value_param\": " |
| 38 |
"\"\\\"semicolon;\\\"\", \"file\": \"file.cpp\", \"line\": 42 },\n" |
| 39 |
" { \"name\": \"case/1\", \"value_param\": " |
| 40 |
"\"'osb['\", \"file\": \"file.cpp\", \"line\": 42 },\n" |
| 41 |
" { \"name\": \"case/2\", \"value_param\": " |
| 42 |
"\"'csb]'\", \"file\": \"file.cpp\", \"line\": 42 },\n" |
| 43 |
" { \"name\": \"case/3\", \"value_param\": \"'S p a c " |
| 44 |
"e s'\", \"file\": \"file.cpp\", \"line\": 42 }\n" |
| 45 |
" ]\n" |
| 46 |
" }\n" |
| 47 |
" ]\n" |
| 48 |
"}"; |
| 49 |
} |
| 50 |
return 0; |
| 51 |
} |