| 1964 | |
| 1965 | template <TypeKind KIND> |
| 1966 | void testNullConstant(const TypePtr& type) { |
| 1967 | ASSERT_EQ(KIND, type->kind()); |
| 1968 | auto baseVector = BaseVector::createNullConstant(type, size_, pool()); |
| 1969 | auto simpleVector = baseVector->template as< |
| 1970 | SimpleVector<typename KindToFlatVector<KIND>::WrapperType>>(); |
| 1971 | ASSERT_TRUE(simpleVector != nullptr); |
| 1972 | |
| 1973 | ASSERT_EQ(KIND, simpleVector->typeKind()); |
| 1974 | ASSERT_TRUE(type->equivalent(*simpleVector->type())); |
| 1975 | ASSERT_EQ(size_, simpleVector->size()); |
| 1976 | ASSERT_EQ(simpleVector->isScalar(), TypeTraits<KIND>::isPrimitiveType); |
| 1977 | |
| 1978 | for (auto i = 0; i < simpleVector->size(); i++) { |
| 1979 | ASSERT_TRUE(simpleVector->isNullAt(i)); |
| 1980 | } |
| 1981 | |
| 1982 | auto expectedStr = fmt::format( |
| 1983 | "[CONSTANT {}: {} elements, null]", type->toString(), size_); |
| 1984 | EXPECT_EQ(expectedStr, baseVector->toString()); |
| 1985 | for (auto i = 1; i < baseVector->size(); ++i) { |
| 1986 | EXPECT_EQ(baseVector->toString(0), baseVector->toString(i)); |
| 1987 | } |
| 1988 | } |
| 1989 | |
| 1990 | protected: |
| 1991 | // Theoretical "size" of the constant vector created. |