Skip to content

Commit a81d250

Browse files
committed
more tests
1 parent 567f582 commit a81d250

11 files changed

+1103
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
2+
#[test]
3+
fn test_banzai_initially_empty() {
4+
let emu = crate::emu64();
5+
6+
// Banzai should have no API params by default
7+
// We test this by trying to get params for a non-existent function (which should panic)
8+
// Since we can't test panics easily here, we just verify the structure exists
9+
}
10+
11+
#[test]
12+
fn test_banzai_add_function() {
13+
let mut emu = crate::emu64();
14+
15+
// Add a function to banazai list
16+
emu.banzai_add("CreateFileA", 7);
17+
18+
// Verify it was added by trying to get params
19+
let params = emu.banzai.get_params("CreateFileA");
20+
assert_eq!(params, 7, "Parameter count should match");
21+
}
22+
23+
#[test]
24+
fn test_banzai_add_multiple_functions() {
25+
let mut emu = crate::emu64();
26+
27+
// Add multiple functions
28+
emu.banzai_add("CreateFileA", 7);
29+
emu.banzai_add("ReadFile", 5);
30+
emu.banzai_add("WriteFile", 5);
31+
32+
// Verify all were added
33+
assert_eq!(emu.banzai.get_params("CreateFileA"), 7);
34+
assert_eq!(emu.banzai.get_params("ReadFile"), 5);
35+
assert_eq!(emu.banzai.get_params("WriteFile"), 5);
36+
}
37+
38+
#[test]
39+
fn test_banzai_different_param_counts() {
40+
let mut emu = crate::emu64();
41+
42+
// Add functions with different parameter counts
43+
emu.banzai_add("Func0", 0);
44+
emu.banzai_add("Func1", 1);
45+
emu.banzai_add("Func10", 10);
46+
47+
assert_eq!(emu.banzai.get_params("Func0"), 0);
48+
assert_eq!(emu.banzai.get_params("Func1"), 1);
49+
assert_eq!(emu.banzai.get_params("Func10"), 10);
50+
}
51+
52+
#[test]
53+
fn test_banzai_add_overwrite() {
54+
let mut emu = crate::emu64();
55+
56+
// Add a function
57+
emu.banzai_add("TestFunc", 5);
58+
assert_eq!(emu.banzai.get_params("TestFunc"), 5);
59+
60+
// Add it again with different param count
61+
emu.banzai_add("TestFunc", 10);
62+
63+
// Should be overwritten
64+
assert_eq!(emu.banzai.get_params("TestFunc"), 10, "Parameter count should be updated");
65+
}
66+
67+
#[test]
68+
fn test_banzai_32bit_mode() {
69+
let mut emu = crate::emu32();
70+
71+
emu.banzai_add("TestFunc32", 3);
72+
assert_eq!(emu.banzai.get_params("TestFunc32"), 3, "Banzai should work in 32-bit mode");
73+
}
74+
75+
#[test]
76+
fn test_banzai_enable_works() {
77+
let mut emu = crate::emu64();
78+
79+
// enable_banzai and disable_banzai exist and should not panic
80+
emu.enable_banzai();
81+
emu.disable_banzai();
82+
}
83+
84+
#[test]
85+
fn test_banzai_add_clears_previous() {
86+
let mut emu = crate::emu64();
87+
88+
emu.banzai_add("Func1", 1);
89+
emu.banzai_add("Func2", 2);
90+
91+
assert_eq!(emu.banzai.get_params("Func1"), 1);
92+
assert_eq!(emu.banzai.get_params("Func2"), 2);
93+
}
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
use crate::config::Config;
2+
3+
#[test]
4+
fn test_config_default_values() {
5+
let cfg = Config::new();
6+
7+
// Test default values
8+
assert!(!cfg.is_64bits, "Default should be 32-bit mode");
9+
assert_eq!(cfg.verbose, 0, "Default verbose should be 0");
10+
}
11+
12+
#[test]
13+
fn test_config_64bit_mode() {
14+
let mut cfg = Config::new();
15+
cfg.is_64bits = true;
16+
17+
assert!(cfg.is_64bits, "Should be in 64-bit mode");
18+
}
19+
20+
#[test]
21+
fn test_config_32bit_mode() {
22+
let mut cfg = Config::new();
23+
cfg.is_64bits = false;
24+
25+
assert!(!cfg.is_64bits, "Should be in 32-bit mode");
26+
}
27+
28+
#[test]
29+
fn test_config_verbose_levels() {
30+
let mut cfg = Config::new();
31+
32+
// Test different verbose levels
33+
cfg.verbose = 0;
34+
assert_eq!(cfg.verbose, 0);
35+
36+
cfg.verbose = 1;
37+
assert_eq!(cfg.verbose, 1);
38+
39+
cfg.verbose = 2;
40+
assert_eq!(cfg.verbose, 2);
41+
42+
cfg.verbose = 3;
43+
assert_eq!(cfg.verbose, 3);
44+
}
45+
46+
#[test]
47+
fn test_config_console_default() {
48+
let cfg = Config::new();
49+
50+
// Check default console state (whatever it is)
51+
let _console_state = cfg.console_enabled;
52+
}
53+
54+
#[test]
55+
fn test_config_console_toggle() {
56+
let mut cfg = Config::new();
57+
58+
cfg.console_enabled = false;
59+
assert!(!cfg.console_enabled);
60+
61+
cfg.console_enabled = true;
62+
assert!(cfg.console_enabled);
63+
}
64+
65+
#[test]
66+
fn test_config_threading_disabled_by_default() {
67+
let cfg = Config::new();
68+
69+
assert!(!cfg.enable_threading, "Threading should be disabled by default");
70+
}
71+
72+
#[test]
73+
fn test_config_threading_enable() {
74+
let mut cfg = Config::new();
75+
76+
cfg.enable_threading = true;
77+
assert!(cfg.enable_threading, "Threading should be enabled");
78+
}
79+
80+
#[test]
81+
fn test_config_multiple_settings() {
82+
let mut cfg = Config::new();
83+
84+
// Set multiple configuration options
85+
cfg.is_64bits = true;
86+
cfg.verbose = 2;
87+
cfg.console_enabled = false;
88+
cfg.enable_threading = true;
89+
90+
// Verify all are set correctly
91+
assert!(cfg.is_64bits);
92+
assert_eq!(cfg.verbose, 2);
93+
assert!(!cfg.console_enabled);
94+
assert!(cfg.enable_threading);
95+
}
96+
97+
#[test]
98+
fn test_emu64_default_config() {
99+
let emu = crate::emu64();
100+
101+
assert!(emu.cfg.is_64bits, "emu64() should create 64-bit emulator");
102+
}
103+
104+
#[test]
105+
fn test_emu32_default_config() {
106+
let emu = crate::emu32();
107+
108+
assert!(!emu.cfg.is_64bits, "emu32() should create 32-bit emulator");
109+
}
110+
111+
#[test]
112+
fn test_config_independence() {
113+
let cfg1 = Config::new();
114+
let mut cfg2 = Config::new();
115+
116+
cfg2.verbose = 5;
117+
118+
// cfg1 should not be affected
119+
assert_eq!(cfg1.verbose, 0, "Configs should be independent");
120+
assert_eq!(cfg2.verbose, 5);
121+
}
122+
123+
#[test]
124+
fn test_set_config() {
125+
let mut emu = crate::emu64();
126+
127+
let mut custom_cfg = Config::new();
128+
custom_cfg.verbose = 3;
129+
custom_cfg.console_enabled = false;
130+
131+
emu.set_config(custom_cfg);
132+
133+
assert_eq!(emu.cfg.verbose, 3, "Custom config should be applied");
134+
assert!(!emu.cfg.console_enabled, "Custom config should be applied");
135+
}
136+
137+
#[test]
138+
fn test_config_verbose_range() {
139+
let mut cfg = Config::new();
140+
141+
// Test edge cases
142+
cfg.verbose = 0;
143+
assert_eq!(cfg.verbose, 0);
144+
145+
cfg.verbose = 10;
146+
assert_eq!(cfg.verbose, 10);
147+
148+
cfg.verbose = 100;
149+
assert_eq!(cfg.verbose, 100);
150+
}

0 commit comments

Comments
 (0)