Skip to content

Commit 87ce567

Browse files
authored
fix #226 (#238)
1 parent 3242844 commit 87ce567

File tree

3 files changed

+304
-205
lines changed

3 files changed

+304
-205
lines changed

src/validator/cbor.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -822,9 +822,9 @@ where
822822
));
823823
}
824824
} else {
825-
if len <= *l || len >= *u {
825+
if len < *l || len >= *u {
826826
self.add_error(format!(
827-
"expected uint to be in range {} < value < {}, got Bytes({:?})",
827+
"expected uint to be in range {} <= value < {}, got Bytes({:?})",
828828
l, u, b
829829
));
830830
}
@@ -843,9 +843,9 @@ where
843843
}
844844

845845
return Ok(());
846-
} else if s.len() <= *l || s.len() >= *u {
846+
} else if s.len() < *l || s.len() >= *u {
847847
self.add_error(format!(
848-
"expected \"{}\" string length to be in the range {} < value < {}, got {}",
848+
"expected \"{}\" string length to be in the range {} <= value < {}, got {}",
849849
s, l, u, len
850850
));
851851
return Ok(());
@@ -865,9 +865,9 @@ where
865865
));
866866
}
867867
} else {
868-
if i128::from(*i) <= *l as i128 || i128::from(*i) >= *u as i128 {
868+
if i128::from(*i) < *l as i128 || i128::from(*i) >= *u as i128 {
869869
self.add_error(format!(
870-
"expected integer to be in range {} < value < {}, got {:?}",
870+
"expected integer to be in range {} <= value < {}, got {:?}",
871871
l, u, i
872872
));
873873
}
@@ -3893,7 +3893,7 @@ mod tests {
38933893
let mut cv = CBORValidator::new(&cddl, valid_cbor);
38943894
assert!(cv.validate().is_ok());
38953895

3896-
// Test boundary case (16 bytes - should fail)
3896+
// Test boundary case (16 bytes - should pass)
38973897
let boundary_bytes = vec![0u8; 16];
38983898
let boundary_cbor = ciborium::value::Value::Map(vec![(
38993899
ciborium::value::Value::Text("field".to_string()),
@@ -3904,7 +3904,7 @@ mod tests {
39043904
let mut cv = CBORValidator::new(&cddl, boundary_cbor, None);
39053905
#[cfg(not(feature = "additional-controls"))]
39063906
let mut cv = CBORValidator::new(&cddl, boundary_cbor);
3907-
assert!(cv.validate().is_err());
3907+
assert!(cv.validate().is_ok());
39083908

39093909
Ok(())
39103910
}

0 commit comments

Comments
 (0)