| 1028 | } |
| 1029 | |
| 1030 | static void ConfirmConvertedTypeCompatibility( |
| 1031 | const std::shared_ptr<const LogicalType>& original, |
| 1032 | ConvertedType::type expected_converted_type) { |
| 1033 | ASSERT_TRUE(original->is_valid()) |
| 1034 | << original->ToString() << " logical type unexpectedly is not valid"; |
| 1035 | schema::DecimalMetadata converted_decimal_metadata; |
| 1036 | ConvertedType::type converted_type = |
| 1037 | original->ToConvertedType(&converted_decimal_metadata); |
| 1038 | ASSERT_EQ(converted_type, expected_converted_type) |
| 1039 | << original->ToString() |
| 1040 | << " logical type unexpectedly returns incorrect converted type"; |
| 1041 | ASSERT_FALSE(converted_decimal_metadata.isset) |
| 1042 | << original->ToString() |
| 1043 | << " logical type unexpectedly returns converted decimal metadata that is set"; |
| 1044 | ASSERT_TRUE(original->is_compatible(converted_type, converted_decimal_metadata)) |
| 1045 | << original->ToString() |
| 1046 | << " logical type unexpectedly is incompatible with converted type and decimal " |
| 1047 | "metadata it returned"; |
| 1048 | ASSERT_FALSE(original->is_compatible(converted_type, {true, 1, 1})) |
| 1049 | << original->ToString() |
| 1050 | << " logical type unexpectedly is compatible with converted decimal metadata that " |
| 1051 | "is " |
| 1052 | "set"; |
| 1053 | ASSERT_TRUE(original->is_compatible(converted_type)) |
| 1054 | << original->ToString() |
| 1055 | << " logical type unexpectedly is incompatible with converted type it returned"; |
| 1056 | std::shared_ptr<const LogicalType> reconstructed = |
| 1057 | LogicalType::FromConvertedType(converted_type, converted_decimal_metadata); |
| 1058 | ASSERT_TRUE(reconstructed->is_valid()) << "Reconstructed " << reconstructed->ToString() |
| 1059 | << " logical type unexpectedly is not valid"; |
| 1060 | ASSERT_TRUE(reconstructed->Equals(*original)) |
| 1061 | << "Reconstructed logical type (" << reconstructed->ToString() |
| 1062 | << ") unexpectedly not equivalent to original logical type (" |
| 1063 | << original->ToString() << ")"; |
| 1064 | return; |
| 1065 | } |
| 1066 | |
| 1067 | TEST(TestLogicalTypeConstruction, ConvertedTypeCompatibility) { |
| 1068 | // For each legacy converted type, ensure that the equivalent logical type |
no test coverage detected