chore: checkpoint before Python removal

This commit is contained in:
2026-03-26 22:33:59 +00:00
parent 683cec9307
commit e568ddf82a
29972 changed files with 11269302 additions and 2 deletions

View File

@@ -0,0 +1,184 @@
use assert_json_diff::{
assert_json_eq, assert_json_include, assert_json_matches, assert_json_matches_no_panic,
CompareMode, Config, NumericMode,
};
use serde::Serialize;
use serde_json::json;
#[test]
fn can_pass() {
assert_json_include!(
actual: json!({ "a": { "b": true }, "c": [true, null, 1] }),
expected: json!({ "a": { "b": true }, "c": [true, null, 1] })
);
assert_json_include!(
actual: json!({ "a": { "b": true } }),
expected: json!({ "a": {} })
);
assert_json_include!(
actual: json!({ "a": { "b": true } }),
expected: json!({ "a": {} }),
);
assert_json_include!(
expected: json!({ "a": {} }),
actual: json!({ "a": { "b": true } }),
);
}
#[test]
#[should_panic]
fn can_fail() {
assert_json_include!(
actual: json!({ "a": { "b": true }, "c": [true, null, 1] }),
expected: json!({ "a": { "b": false }, "c": [false, null, {}] })
);
}
#[test]
#[should_panic]
fn different_numeric_types_include_should_fail() {
assert_json_include!(
actual: json!({ "a": { "b": true }, "c": 1 }),
expected: json!({ "a": { "b": true }, "c": 1.0 })
);
}
#[test]
#[should_panic]
fn different_numeric_types_eq_should_fail() {
assert_json_eq!(
json!({ "a": { "b": true }, "c": 1 }),
json!({ "a": { "b": true }, "c": 1.0 })
);
}
#[test]
fn different_numeric_types_assume_float() {
let actual = json!({ "a": { "b": true }, "c": [true, null, 1] });
let expected = json!({ "a": { "b": true }, "c": [true, null, 1.0] });
let config = Config::new(CompareMode::Inclusive).numeric_mode(NumericMode::AssumeFloat);
assert_json_matches!(actual, expected, config.clone());
assert_json_matches!(actual, expected, config.compare_mode(CompareMode::Strict))
}
#[test]
fn can_pass_with_exact_match() {
assert_json_eq!(json!({ "a": { "b": true } }), json!({ "a": { "b": true } }));
assert_json_eq!(json!({ "a": { "b": true } }), json!({ "a": { "b": true } }),);
}
#[test]
#[should_panic]
fn can_fail_with_exact_match() {
assert_json_eq!(json!({ "a": { "b": true } }), json!({ "a": {} }));
}
#[test]
fn inclusive_match_without_panicking() {
assert!(assert_json_matches_no_panic(
&json!({ "a": 1, "b": 2 }),
&json!({ "b": 2}),
Config::new(CompareMode::Inclusive,).numeric_mode(NumericMode::Strict),
)
.is_ok());
assert!(assert_json_matches_no_panic(
&json!({ "a": 1, "b": 2 }),
&json!("foo"),
Config::new(CompareMode::Inclusive,).numeric_mode(NumericMode::Strict),
)
.is_err());
}
#[test]
fn exact_match_without_panicking() {
assert!(assert_json_matches_no_panic(
&json!([1, 2, 3]),
&json!([1, 2, 3]),
Config::new(CompareMode::Strict).numeric_mode(NumericMode::Strict)
)
.is_ok());
assert!(assert_json_matches_no_panic(
&json!([1, 2, 3]),
&json!("foo"),
Config::new(CompareMode::Strict).numeric_mode(NumericMode::Strict)
)
.is_err());
}
#[derive(Serialize)]
struct User {
id: i32,
username: String,
}
#[test]
fn include_with_serializable() {
let user = User {
id: 1,
username: "bob".to_string(),
};
assert_json_include!(
actual: json!({
"id": 1,
"username": "bob",
"email": "bob@example.com"
}),
expected: user,
);
}
#[test]
fn include_with_serializable_ref() {
let user = User {
id: 1,
username: "bob".to_string(),
};
assert_json_include!(
actual: &json!({
"id": 1,
"username": "bob",
"email": "bob@example.com"
}),
expected: &user,
);
}
#[test]
fn eq_with_serializable() {
let user = User {
id: 1,
username: "bob".to_string(),
};
assert_json_eq!(
json!({
"id": 1,
"username": "bob"
}),
user,
);
}
#[test]
fn eq_with_serializable_ref() {
let user = User {
id: 1,
username: "bob".to_string(),
};
assert_json_eq!(
&json!({
"id": 1,
"username": "bob"
}),
&user,
);
}

View File

@@ -0,0 +1,12 @@
#[macro_use]
extern crate version_sync;
#[test]
fn test_readme_deps() {
assert_markdown_deps_updated!("README.md");
}
#[test]
fn test_html_root_url() {
assert_html_root_url_updated!("src/lib.rs");
}