Skip to content

Commit

Permalink
Add tests for ExpectationError messages
Browse files Browse the repository at this point in the history
This commit introduces unit tests for the `ExpectationError` enum to ensure that error messages are formatted correctly. Additionally, it updates the package versions in `Cargo.toml` for both `borsh-serde-adapter` and `borsh-schema-writer`.
  • Loading branch information
wkennedy committed Aug 15, 2024
1 parent 9f8344b commit b21fbf0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion borsh-schema-writer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "borsh-schema-writer"
version = "1.0.1"
version = "1.0.2"
edition = "2021"
authors = ["Will Kennedy"]
description = "Write a BorshSchemaContainer to a binary file"
Expand Down
2 changes: 1 addition & 1 deletion borsh-serde-adapter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "borsh-serde-adapter"
version = "1.0.2"
version = "1.0.3"
edition = "2021"
authors = ["Will Kennedy"]
description = "Adapter to go from borsh to serde and vice versa"
Expand Down
16 changes: 16 additions & 0 deletions borsh-serde-adapter/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,20 @@ pub enum ExpectationError {

#[error("Expected object")]
Object
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_error_messages() {
assert_eq!(format!("{}", ExpectationError::Null), "Expected null");
assert_eq!(format!("{}", ExpectationError::Array), "Expected array");
assert_eq!(format!("{}", ExpectationError::ArrayOfLength(5)), "Expected array of length 5");
assert_eq!(format!("{}", ExpectationError::Number), "Expected number");
assert_eq!(format!("{}", ExpectationError::String), "Expected string");
assert_eq!(format!("{}", ExpectationError::Boolean), "Expected boolean");
assert_eq!(format!("{}", ExpectationError::Object), "Expected object");
}
}

0 comments on commit b21fbf0

Please sign in to comment.