|
11 | 11 | #include "model/table/agree_set_factory.h"
|
12 | 12 | #include "model/table/column_layout_relation_data.h"
|
13 | 13 | #include "model/table/identifier_set.h"
|
| 14 | +#include "separator_validator.h" |
14 | 15 |
|
15 | 16 | namespace tests {
|
16 | 17 |
|
@@ -230,4 +231,34 @@ INSTANTIATE_TEST_SUITE_P(TestLevenshteinSuite, TestLevenshtein,
|
230 | 231 | TestLevenshteinParam("", "book", 4),
|
231 | 232 | TestLevenshteinParam("randomstring", "juststring", 6)));
|
232 | 233 |
|
| 234 | +struct TestSeparatorValidationParam { |
| 235 | + std::filesystem::path csv_path; |
| 236 | + char separator; |
| 237 | + char expected; |
| 238 | + |
| 239 | + TestSeparatorValidationParam(std::filesystem::path const& path, char sep, char exp) |
| 240 | + : csv_path(path), separator(sep), expected(exp) {} |
| 241 | +}; |
| 242 | + |
| 243 | +class TestSeparatorValidation : public ::testing::TestWithParam<TestSeparatorValidationParam> {}; |
| 244 | + |
| 245 | +TEST_P(TestSeparatorValidation, Default) { |
| 246 | + TestSeparatorValidationParam const& p = GetParam(); |
| 247 | + std::optional<char> actual = util::ValidateSeparator(p.csv_path, p.separator); |
| 248 | + EXPECT_EQ(actual.value_or('\0'), p.expected); |
| 249 | +} |
| 250 | + |
| 251 | +INSTANTIATE_TEST_SUITE_P( |
| 252 | + TestSeparatorValidationSuite, TestSeparatorValidation, |
| 253 | + ::testing::Values(TestSeparatorValidationParam(test_data_dir / "Test1.csv", ',', ','), |
| 254 | + TestSeparatorValidationParam(test_data_dir / "Test1.csv", ';', ';'), |
| 255 | + TestSeparatorValidationParam(test_data_dir / "Test1.csv", '1', '\0'), |
| 256 | + TestSeparatorValidationParam(test_data_dir / "TestFD.csv", ',', ','), |
| 257 | + TestSeparatorValidationParam(test_data_dir / "TestFD.csv", ';', ','), |
| 258 | + TestSeparatorValidationParam(test_data_dir / "adult.csv", ';', ';'), |
| 259 | + TestSeparatorValidationParam(test_data_dir / "adult.csv", ',', ';'), |
| 260 | + TestSeparatorValidationParam(test_data_dir / "abalone.csv", ',', ','), |
| 261 | + TestSeparatorValidationParam(test_data_dir / "abalone.csv", '.', ','), |
| 262 | + TestSeparatorValidationParam(test_data_dir / "TestParse.csv", ',', ','))); |
| 263 | + |
233 | 264 | } // namespace tests
|
0 commit comments