MCPcopy Create free account
hub / github.com/apache/fory / test_fixed_width_read_bounds_checks

Function test_fixed_width_read_bounds_checks

rust/tests/tests/test_buffer.rs:102–119  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

100
101#[test]
102fn test_fixed_width_read_bounds_checks() {
103 let mut empty = Reader::new(&[]);
104 assert!(empty.read_u16().is_err());
105 assert!(empty.read_u32().is_err());
106 assert!(empty.read_u64().is_err());
107 assert!(empty.read_f16().is_err());
108 assert!(empty.read_f32().is_err());
109 assert!(empty.read_f64().is_err());
110 assert!(empty.read_u128().is_err());
111
112 let mut short = Reader::new(&[1, 2, 3]);
113 assert!(short.read_u32().is_err());
114
115 let mut bad_cursor = Reader::new(&[1, 2, 3, 4]);
116 bad_cursor.set_cursor(10);
117 assert!(bad_cursor.read_u16().is_err());
118 assert!(bad_cursor.read_var_u36_small().is_err());
119}
120
121#[test]
122fn test_utf8_string_read_rejects_invalid_payload() {

Callers

nothing calls this directly

Calls 1

set_cursorMethod · 0.80

Tested by

no test coverage detected