Skip to content

Commit ed3253a

Browse files
committed
Increased robustness for changed NonZeroU32 de error in test
1 parent f8c2b51 commit ed3253a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tests/203_error_positions.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::num::NonZeroU32;
22

33
use ron::error::{Error, ErrorCode, Position};
4+
use serde::de::{value::Error as DeError, Deserialize, IntoDeserializer};
45

56
#[derive(Debug, serde::Deserialize, PartialEq)]
67
enum Test {
@@ -23,15 +24,23 @@ fn test_error_positions() {
2324
assert_eq!(
2425
ron::from_str::<Test>("TupleVariant(1, 0)"),
2526
Err(Error {
26-
code: ErrorCode::Message(String::from("expected a non-zero value")),
27+
code: ErrorCode::Message(
28+
NonZeroU32::deserialize(IntoDeserializer::<DeError>::into_deserializer(0_u32))
29+
.unwrap_err()
30+
.to_string()
31+
),
2732
position: Position { line: 1, col: 18 },
2833
})
2934
);
3035

3136
assert_eq!(
3237
ron::from_str::<Test>("StructVariant(a: true, b: 0, c: -42)"),
3338
Err(Error {
34-
code: ErrorCode::Message(String::from("expected a non-zero value")),
39+
code: ErrorCode::Message(
40+
NonZeroU32::deserialize(IntoDeserializer::<DeError>::into_deserializer(0_u32))
41+
.unwrap_err()
42+
.to_string()
43+
),
3544
position: Position { line: 1, col: 28 },
3645
})
3746
);

0 commit comments

Comments
 (0)