1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-24 10:54:16 +00:00
UltimateTrainingModpack/training_mod_tui/tests/test_toggle.rs
jugeeya b2ef9b85a7
Fix Clippy again (#657)
* Fix clippy

* More fixes

* More fixes

* More fixes

* More fixes

* More fixes

* More fixes

* More fixes

* Fix test

* More fixes
2023-12-13 17:52:54 -08:00

44 lines
800 B
Rust

use training_mod_tui::Toggle;
#[test]
fn toggle_serialize() {
let t = Toggle {
title: "Title",
value: 5,
max: 10,
};
let json = serde_json::to_string(&t).unwrap();
assert_eq!(json, "5");
}
#[test]
fn toggle_increment() {
let mut t = Toggle {
title: "Title",
value: 5,
max: 10,
};
t.increment();
assert_eq!(t.value, 6);
t.value = 9;
t.increment();
assert_eq!(t.value, 10);
t.increment();
assert_eq!(t.value, 0);
}
#[test]
fn toggle_decrement() {
let mut t = Toggle {
title: "Title",
value: 5,
max: 10,
};
t.decrement();
assert_eq!(t.value, 4);
t.value = 1;
t.decrement();
assert_eq!(t.value, 0);
t.decrement();
assert_eq!(t.value, 10);
}