mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-03-24 23:36:10 +00:00
* Add replacement training_mod_tui crate * Begin work on converting over to byteflags * Allow StatefulTable.iter_mut() * Additional merge work * Fixing more compile errors from the merge * Replace training_mod_tui with training_mod_tui_2, update byteflags dependency for random selection * Fix button_config, hero buffs, caps issues. Move button logic into App * Restore some functions that I cut too agressively * Move to_vec into byteflags crate * Fix src/training/ui * Set `_` match arms on byteflags to `unreachable!()` * Fix final few compiler errors * Run formatter * Reconsider whether unreachable parts are actually unreachable * Adjust logging and remove dead code * Fix some menu bugs * Adjust icon sizes * Separate checkmark from is_single_option * Allow fast increment / decrement of slider handles with up/down * Allow resetting current menu * Change button behavior: `R/Z` now resets either the whole menu or the selected submenu depending on app.page, and `Y` now clears the current toggle so you don't have to press A six times. Only show keyhelp for `Y` if its relevant. * Remove unneeded command line interface * Take care of some minor nomenclature TODO's * Increase stack size for menu::load_from_file() to avoid crashes * Implement confirmation page before restoring from defaults * Run rustfmt * Fix warnings
44 lines
802 B
Rust
44 lines
802 B
Rust
use training_mod_tui_2::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);
|
|
}
|