MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / test_dict_errors

Function test_dict_errors

src/repr/src/row.rs:3929–3952  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3927
3928 #[mz_ore::test]
3929 fn test_dict_errors() -> Result<(), Box<dyn std::error::Error>> {
3930 let pack = |ok| {
3931 let mut row = Row::default();
3932 row.packer().push_dict_with(|row| {
3933 if ok {
3934 row.push(Datum::String("key"));
3935 row.push(Datum::Int32(42));
3936 Ok(7)
3937 } else {
3938 Err("fail")
3939 }
3940 })?;
3941 Ok(row)
3942 };
3943
3944 assert_eq!(pack(false), Err("fail"));
3945
3946 let row = pack(true)?;
3947 let mut dict = row.unpack_first().unwrap_map().iter();
3948 assert_eq!(dict.next(), Some(("key", Datum::Int32(42))));
3949 assert_eq!(dict.next(), None);
3950
3951 Ok(())
3952 }
3953
3954 #[mz_ore::test]
3955 #[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `decNumberFromInt32` on OS `linux`

Callers

nothing calls this directly

Calls 8

StringClass · 0.85
packFunction · 0.85
push_dict_withMethod · 0.80
packerMethod · 0.80
unwrap_mapMethod · 0.80
unpack_firstMethod · 0.80
pushMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected