| Crates.io | assert-str |
| lib.rs | assert-str |
| version | 0.2.0 |
| created_at | 2020-07-14 17:03:24.868235+00 |
| updated_at | 2025-04-04 23:38:50.450586+00 |
| description | Macros for asserting multiline strings |
| homepage | https://github.com/AnderEnder/assert-str |
| repository | https://github.com/AnderEnder/assert-str |
| max_upload_size | |
| id | 265144 |
| size | 33,482 |
Macros for Asserting Multiline Strings
This is a set of macros designed to assert strings that may be generated on different operating systems, potentially containing different newline characters or varying levels of indentation. These macros allow you to compare prettified JSON or XML with their compressed versions.
Add the dependency to your Cargo.toml:
[dependencies]
assert-str = "0.1"
Or
[dev-dependencies]
assert-str = "0.1"
Import the macros in your test module or main file:
use assert_str::{assert_str_eq, assert_str_ne};
use assert_str::{assert_str_trim_eq, assert_str_trim_ne};
use assert_str::{assert_str_trim_all_eq, assert_str_trim_all_ne};
Or if you want to import all macros:
use assert_str::*;
Use the macros:
#[test]
fn test_trimmed_string_assertions() {
assert_str_trim_eq!(
"<html>\t \n\t<head> \n\t</head></html>",
"<html>\r\n<head>\r\n</head></html>",
"Responses should be equal"
);
assert_str_trim_all_eq!(
"<html>\t \n\t<head> \n\t</head></html>",
"<html><head></head></html>",
"Responses should be equal"
);
}