Skip to content

Commit c71528d

Browse files
committed
Add tests for separator validation
1 parent a44e7ea commit c71528d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/tests/test_util.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "model/table/agree_set_factory.h"
1212
#include "model/table/column_layout_relation_data.h"
1313
#include "model/table/identifier_set.h"
14+
#include "separator_validator.h"
1415

1516
namespace tests {
1617

@@ -230,4 +231,34 @@ INSTANTIATE_TEST_SUITE_P(TestLevenshteinSuite, TestLevenshtein,
230231
TestLevenshteinParam("", "book", 4),
231232
TestLevenshteinParam("randomstring", "juststring", 6)));
232233

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+
233264
} // namespace tests

0 commit comments

Comments
 (0)