| 90 | } |
| 91 | |
| 92 | std::vector<WriterTestParams> GenerateTestCases() { |
| 93 | // Dummy schema and data for testing invalid options. |
| 94 | auto dummy_schema = schema({field("a", uint8())}); |
| 95 | std::string dummy_batch_data = R"([{"a": null}])"; |
| 96 | |
| 97 | auto header_without_structural_charaters = |
| 98 | schema({field("a ", uint64()), field("b", int32())}); |
| 99 | std::string expected_header_without_structural_charaters = |
| 100 | std::string(R"(a ,b)") + "\n"; |
| 101 | auto expected_status_no_quotes_with_structural_in_header = [](const char* header) { |
| 102 | return Status::Invalid( |
| 103 | "CSV header may not contain structural characters if quoting " |
| 104 | "style is \"None\". See RFC4180. Invalid value: ", |
| 105 | header); |
| 106 | }; |
| 107 | |
| 108 | // Schema to test various types. |
| 109 | auto abc_schema = schema({ |
| 110 | field("a", uint64()), |
| 111 | field("b\"", utf8()), |
| 112 | field("c ", int32()), |
| 113 | field("d", date32()), |
| 114 | field("e", date64()), |
| 115 | field("f", timestamp(TimeUnit::SECOND)), |
| 116 | field("g", duration(TimeUnit::SECOND)), |
| 117 | field("h", large_utf8()), |
| 118 | }); |
| 119 | auto populated_batch = R"([{"a": 1, "c ": -1}, |
| 120 | { "a": 1, "b\"": "abc\"efg", "c ": 2324}, |
| 121 | { "b\"": "abcd", "c ": 5467, "h": "efghi"}, |
| 122 | { }, |
| 123 | { "a": 546, "b\"": "", "c ": 517 }, |
| 124 | { "a": 124, "b\"": "a\"\"b\"" }, |
| 125 | { "d": 0, "h": "jklm" }, |
| 126 | { "e": 86400000 }, |
| 127 | { "f": 1078016523 }, |
| 128 | { "g": 3600 }, |
| 129 | { "b\"": "NA" }])"; |
| 130 | |
| 131 | std::string expected_header = |
| 132 | std::string(R"("a","b""","c ","d","e","f","g","h")") + "\n"; |
| 133 | |
| 134 | // Expected output without header when using default QuotingStyle::Needed. |
| 135 | std::string expected_without_header = UtilGetExpectedWithEOL("\n"); |
| 136 | |
| 137 | std::string expected_with_custom_eol = UtilGetExpectedWithEOL("_EOL_"); |
| 138 | |
| 139 | // Expected output without header when using QuotingStyle::AllValid. |
| 140 | std::string expected_quoting_style_all_valid = |
| 141 | std::string(R"("1",,"-1",,,,,)") + "\n" + // line 1 |
| 142 | R"("1","abc""efg","2324",,,,,)" + "\n" + // line 2 |
| 143 | R"(,"abcd","5467",,,,,"efghi")" + "\n" + // line 3 |
| 144 | R"(,,,,,,,)" + "\n" + // line 4 |
| 145 | R"("546","","517",,,,,)" + "\n" + // line 5 |
| 146 | R"("124","a""""b""",,,,,,)" + "\n" + // line 6 |
| 147 | R"(,,,"1970-01-01",,,,"jklm")" + "\n" + // line 7 |
| 148 | R"(,,,,"1970-01-02",,,)" + "\n" + // line 8 |
| 149 | R"(,,,,,"2004-02-29 01:02:03",,)" + "\n" + // line 9 |
no test coverage detected