Validate that `func` succeeds on supported (Type, Encoding) combinations, and raises on unsupported ones.
| 59 | // Validate that `func` succeeds on supported (Type, Encoding) combinations, and |
| 60 | // raises on unsupported ones. |
| 61 | void TestSupportedEncodingsConsistentWith( |
| 62 | std::function<void(Type::type, Encoding::type, const ColumnDescriptor&)> func) { |
| 63 | // Try all possible types and encodings |
| 64 | for (int int_type = 0; int_type < static_cast<int>(Type::UNDEFINED); ++int_type) { |
| 65 | const auto type = static_cast<Type::type>(int_type); |
| 66 | const auto supported_encodings = SupportedEncodings(type); |
| 67 | ARROW_SCOPED_TRACE("Type = ", TypeToString(type)); |
| 68 | const auto descr = |
| 69 | ColumnDescriptor(schema::PrimitiveNode::Make("col", Repetition::REQUIRED, type, |
| 70 | ConvertedType::NONE, /*length=*/2), |
| 71 | /*max_definition_level=*/0, /*max_repetition_level=*/0); |
| 72 | |
| 73 | for (int int_encoding = 0; int_encoding < static_cast<int>(Encoding::UNDEFINED); |
| 74 | ++int_encoding) { |
| 75 | const auto encoding = static_cast<Encoding::type>(int_encoding); |
| 76 | ARROW_SCOPED_TRACE("Encoding = ", EncodingToString(encoding)); |
| 77 | if (std::find(supported_encodings.begin(), supported_encodings.end(), encoding) != |
| 78 | supported_encodings.end()) { |
| 79 | ASSERT_NO_THROW(func(type, encoding, descr)); |
| 80 | } else { |
| 81 | ASSERT_THROW(func(type, encoding, descr), ParquetException); |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | TEST(SupportedEncodings, TestMakeDecoder) { |
| 88 | auto make_decoder = [](Type::type type, Encoding::type encoding, |
no test coverage detected