Skip to content

Commit c5ed2ba

Browse files
committed
test_set_or_list_general_type_errors: Test more cases
1 parent 9d5e5cf commit c5ed2ba

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

scylla-cql/src/deserialize/value_tests.rs

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,17 +1934,51 @@ fn test_secrecy_08_errors() {
19341934

19351935
#[test]
19361936
fn test_set_or_list_general_type_errors() {
1937+
// Types that are not even collections
1938+
{
1939+
assert_type_check_error!(
1940+
&Bytes::new(),
1941+
Vec<i64>,
1942+
ColumnType::Native(NativeType::Float),
1943+
BuiltinTypeCheckErrorKind::NotDeserializableToVec
1944+
);
1945+
1946+
assert_type_check_error!(
1947+
&Bytes::new(),
1948+
BTreeSet<i64>,
1949+
ColumnType::Native(NativeType::Float),
1950+
BuiltinTypeCheckErrorKind::SetOrListError(SetOrListTypeCheckErrorKind::NotSet)
1951+
);
1952+
1953+
assert_type_check_error!(
1954+
&Bytes::new(),
1955+
HashSet<i64>,
1956+
ColumnType::Native(NativeType::Float),
1957+
BuiltinTypeCheckErrorKind::SetOrListError(SetOrListTypeCheckErrorKind::NotSet)
1958+
);
1959+
1960+
assert_type_check_error!(
1961+
&Bytes::new(),
1962+
ListlikeIterator<i64>,
1963+
ColumnType::Native(NativeType::Float),
1964+
BuiltinTypeCheckErrorKind::SetOrListError(SetOrListTypeCheckErrorKind::NotSetOrList)
1965+
);
1966+
}
1967+
1968+
// Type check of Rust set against CQL list must fail, because it would be lossy.
19371969
assert_type_check_error!(
19381970
&Bytes::new(),
1939-
Vec<i64>,
1940-
ColumnType::Native(NativeType::Float),
1941-
BuiltinTypeCheckErrorKind::NotDeserializableToVec
1971+
BTreeSet<i32>,
1972+
ColumnType::Collection {
1973+
frozen: false,
1974+
typ: CollectionType::List(Box::new(ColumnType::Native(NativeType::Int))),
1975+
},
1976+
BuiltinTypeCheckErrorKind::SetOrListError(SetOrListTypeCheckErrorKind::NotSet)
19421977
);
19431978

1944-
// Type check of Rust set against CQL list must fail, because it would be lossy.
19451979
assert_type_check_error!(
19461980
&Bytes::new(),
1947-
BTreeSet<i32>,
1981+
HashSet<i32>,
19481982
ColumnType::Collection {
19491983
frozen: false,
19501984
typ: CollectionType::List(Box::new(ColumnType::Native(NativeType::Int))),

0 commit comments

Comments
 (0)