MCPcopy Create free account
hub / github.com/apache/arrow / TestSupportedEncodingsConsistentWith

Function TestSupportedEncodingsConsistentWith

cpp/src/parquet/encoding_test.cc:61–85  ·  view source on GitHub ↗

Validate that `func` succeeds on supported (Type, Encoding) combinations, and raises on unsupported ones.

Source from the content-addressed store, hash-verified

59// Validate that `func` succeeds on supported (Type, Encoding) combinations, and
60// raises on unsupported ones.
61void 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
87TEST(SupportedEncodings, TestMakeDecoder) {
88 auto make_decoder = [](Type::type type, Encoding::type encoding,

Callers 1

TESTFunction · 0.85

Calls 8

SupportedEncodingsFunction · 0.85
TypeToStringFunction · 0.85
EncodingToStringFunction · 0.85
ColumnDescriptorClass · 0.70
MakeFunction · 0.70
funcFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected