| 81 | |
| 82 | template <typename Encoder, typename DfTest> |
| 83 | void TestOrdinalEncoderInts() { |
| 84 | Encoder encoder; |
| 85 | auto sol = std::vector<std::int32_t>{0, 3, 1}; |
| 86 | |
| 87 | { |
| 88 | auto df = DfTest::Make(DfTest::MakeInts(2, 1, 3, 0)); |
| 89 | auto orig_dict = df.View(); |
| 90 | |
| 91 | auto new_df = DfTest::Make(DfTest::MakeInts(2, 0, 1)); |
| 92 | auto new_dict = new_df.View(); |
| 93 | |
| 94 | encoder.Recode(orig_dict, new_dict, new_df.MappingView()); |
| 95 | ASSERT_EQ(new_df.Mapping(), sol); |
| 96 | } |
| 97 | { |
| 98 | // Test error message. |
| 99 | auto df = DfTest::Make(DfTest::MakeInts(2, 1, 3, 0)); |
| 100 | auto orig_dict = df.View(); |
| 101 | |
| 102 | auto new_df = DfTest::Make(DfTest::MakeInts(2, 0, 5)); |
| 103 | auto new_dict = new_df.View(); |
| 104 | ASSERT_THAT([&] { encoder.Recode(orig_dict, new_dict, new_df.MappingView()); }, |
| 105 | ::testing::ThrowsMessage<std::logic_error>(::testing::HasSubstr("`5`"))); |
| 106 | } |
| 107 | { |
| 108 | auto df = DfTest::Make(DfTest::MakeInts(0), DfTest::MakeInts(0, 1)); |
| 109 | auto orig_dict = df.View(); |
| 110 | |
| 111 | auto new_df = DfTest::Make(DfTest::MakeInts(0), DfTest::MakeInts(0, 1)); |
| 112 | auto new_dict = new_df.View(); |
| 113 | |
| 114 | encoder.Recode(orig_dict, new_dict, new_df.MappingView()); |
| 115 | auto mapping = new_df.Mapping(); |
| 116 | std::vector<std::int32_t> sol{0, 0, 1}; |
| 117 | ASSERT_EQ(mapping, sol); |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | template <typename Encoder, typename DfTest> |
| 122 | void TestOrdinalEncoderMixed() { |
nothing calls this directly
no test coverage detected