Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increased coverage for unit tests #369

Merged
merged 2 commits into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/de/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::error::SpannedResult;
use crate::value::{Map, Number, Value};

impl std::str::FromStr for Value {
type Err = crate::SpannedError;
type Err = crate::error::SpannedError;

/// Creates a value from a string reference.
fn from_str(s: &str) -> SpannedResult<Self> {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub mod extensions;
pub mod options;

pub use de::{from_str, Deserializer};
pub use error::{Result, SpannedError};
pub use error::{Error, Result};
pub use options::Options;
pub use ser::{to_string, Serializer};
pub use value::{Map, Number, Value};
Expand Down
8 changes: 4 additions & 4 deletions tests/129_indexmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ tasks: {
Value::String("shell command".to_string())
);
}
_ => panic!(),
_ => panic!(), // GRCOV_EXCL_LINE
},
_ => panic!(),
_ => panic!(), // GRCOV_EXCL_LINE
}

let file = r#"(
Expand Down Expand Up @@ -69,8 +69,8 @@ tasks: {
Value::String("debug message".to_string())
);
}
_ => panic!(),
_ => panic!(), // GRCOV_EXCL_LINE
},
_ => panic!(),
_ => panic!(), // GRCOV_EXCL_LINE
}
}
11 changes: 2 additions & 9 deletions tests/147_empty_sets_serialisation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,13 @@ struct TupleStruct(UnitStruct, i8);
#[derive(Debug, PartialEq, Eq, Hash, Deserialize, Serialize)]
struct Key(u32);

#[derive(Debug, PartialEq, Eq, Hash, Deserialize, Serialize)]
enum Enum {
Unit,
Bool(bool),
Chars(char, String),
}

#[derive(Debug, PartialEq, Deserialize, Serialize)]
struct Struct {
tuple: ((), NewType, TupleStruct),
vec: Vec<Option<UnitStruct>>,
map: HashMap<Key, Enum>,
map: HashMap<Key, i32>,
deep_vec: HashMap<Key, Vec<()>>,
deep_map: HashMap<Key, HashMap<Key, Enum>>,
deep_map: HashMap<Key, HashMap<Key, i32>>,
}

#[test]
Expand Down
10 changes: 10 additions & 0 deletions tests/359_deserialize_seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,14 @@ fn test_deserialize_seed() {

assert_eq!(expected, deserialized);
}

assert_eq!(
ron::Options::default().from_str_seed("'a'", Seed(42)),
Err(ron::error::SpannedError {
code: ron::Error::Message(String::from(
"invalid type: string \"a\", expected an integer"
)),
position: ron::error::Position { line: 1, col: 4 },
})
);
}
8 changes: 1 addition & 7 deletions tests/preserve_sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ fn read_original(source: &str) -> String {
}

fn make_roundtrip(source: &str) -> String {
let config: Config = match from_str(source) {
Ok(x) => x,
Err(e) => {
println!("Failed to load config: {}", e);
std::process::exit(1);
}
};
let config: Config = from_str(source).unwrap();
let pretty = PrettyConfig::new()
.depth_limit(3)
.separate_tuple_members(true)
Expand Down