Skip to content

Commit d1e6b8b

Browse files
committed
test: use assert-cmp for the order comparisons in json_input_no_sort
Replace the bare boolean `assert!` comparisons with `assert_op!` from the already-declared `assert-cmp` crate so a failure reports both operand values. Bind the positions to locals first, as the simple macro form and the `perfectionist::macro-argument-binding` lint both require. https://claude.ai/code/session_01Nj3xEp1eoDKRp1MUCxNQRQ
1 parent f5c94ba commit d1e6b8b

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

tests/json.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
pub mod _utils;
55
pub use _utils::*;
66

7+
use assert_cmp::assert_op;
78
use command_extra::CommandExtra;
89
use parallel_disk_usage::{
910
bytes_format::BytesFormat,
@@ -251,8 +252,12 @@ fn json_input_no_sort() {
251252
// `--no-sort` preserves the ascending input order `a, b, c`, whereas the
252253
// default sorts by descending size, so their relative positions flip.
253254
let position = |text: &str, name: &str| text.find(name).expect("entry must be present");
254-
assert!(position(&actual, "a") > position(&actual, "c"));
255-
assert!(position(&sorted, "a") < position(&sorted, "c"));
255+
let actual_a = position(&actual, "a");
256+
let actual_c = position(&actual, "c");
257+
assert_op!(actual_a > actual_c);
258+
let sorted_a = position(&sorted, "a");
259+
let sorted_c = position(&sorted, "c");
260+
assert_op!(sorted_a < sorted_c);
256261
}
257262

258263
#[test]

0 commit comments

Comments
 (0)