• R/O
  • SSH

silny-kombat: コミット

Mercurial repo for silny-kombat project


コミットメタ情報

リビジョンdfe0c072686556c4e0c82e130887ce8ef50c53fe (tree)
日時2021-11-26 05:05:48
作者SecT
コミッターSecT

ログメッセージ

Added test for collision checking

変更サマリ

差分

diff -r 68d6bf767f60 -r dfe0c0726865 silny-kombat_integration_tests/src/main.rs
--- a/silny-kombat_integration_tests/src/main.rs Thu Nov 25 20:23:24 2021 +0100
+++ b/silny-kombat_integration_tests/src/main.rs Thu Nov 25 21:05:48 2021 +0100
@@ -15,23 +15,35 @@
1515
1616 // Send a key (press + release)
1717
18-println!("Moving both characters towards each other");
18+ runBasicControlTest();
19+ runCheckCollisionTest();
20+
21+
22+println!("Test application end");
23+
24+}
25+
26+pub fn runBasicControlTest()
27+{
28+ println!("Test 1 - basic key test");
29+
30+ println!("Moving both characters towards each other");
1931
2032 simulate::press(Key::Right).unwrap();
2133 simulate::press(Key::A).unwrap();
2234 //let mut n = 1;
2335 //while n < 25 {
2436 //simulate::send(Key::Right).unwrap();
25-thread::sleep(time::Duration::from_millis(2500));
37+ thread::sleep(time::Duration::from_millis(2500));
2638 //n+=1;
2739 //}
2840
29-simulate::release(Key::Right).unwrap();
30-simulate::release(Key::A).unwrap();
41+ simulate::release(Key::Right).unwrap();
42+ simulate::release(Key::A).unwrap();
3143
3244
3345 //n = 1;
34-println!("Moving both characters away from each other");
46+ println!("Moving both characters away from each other");
3547 //while n < 15 {
3648 //simulate::send(Key::Right).unwrap();
3749 simulate::press(Key::Left).unwrap();
@@ -41,30 +53,58 @@
4153 //}
4254
4355
44-simulate::release(Key::Left).unwrap();
45-simulate::release(Key::D).unwrap();
56+ simulate::release(Key::Left).unwrap();
57+ simulate::release(Key::D).unwrap();
4658
4759 //delay to check if the characters stopped after key release
4860 println!("Wait after key release...");
4961 thread::sleep(time::Duration::from_millis(1500));
5062
51-println!("Request state dump");
52-simulate::press(Key::F4).unwrap();
63+ println!("Request state dump");
64+ simulate::press(Key::F4).unwrap();
5365
5466 thread::sleep(time::Duration::from_millis(3000));
5567
5668
57-println!("Test results:");
58-match check_test_results() {
59- true => println!("PASS"),
60- false => println!("FAIL"),
69+ println!("Test 1 results:");
70+ match check_test_results(55, 65, 535, 545) {
71+ true => println!("PASS"),
72+ false => println!("FAIL"),
73+ }
6174 }
6275
63-println!("Test application end");
76+pub fn runCheckCollisionTest()
77+{
78+ //TEST 2 - check collision detection
79+ println!("Test 2 - collision detection");
6480
81+ println!("Moving both characters towards each other");
82+
83+ simulate::press(Key::Right).unwrap();
84+ simulate::press(Key::A).unwrap();
85+ thread::sleep(time::Duration::from_millis(4500));
86+
87+ simulate::release(Key::Right).unwrap();
88+ simulate::release(Key::A).unwrap();
89+
90+ //delay to check if the characters stopped after key release
91+ println!("Wait after key release...");
92+ thread::sleep(time::Duration::from_millis(1500));
93+
94+ println!("Request state dump");
95+ simulate::press(Key::F4).unwrap();
96+
97+ thread::sleep(time::Duration::from_millis(3000));
98+
99+
100+ println!("Test 2 results:");
101+ match check_test_results(235, 245, 355, 365) {
102+ true => println!("PASS"),
103+ false => println!("FAIL"),
104+ }
65105 }
66106
67-pub fn check_test_results() ->bool{
107+pub fn check_test_results(A_x_min: i32, A_x_max: i32, B_x_min: i32, B_x_max: i32) ->bool{
68108
69109 let values: Vec<i32> = get_test_values_from_dump_file();
70110
@@ -72,10 +112,17 @@
72112 println!("value: {}", value)
73113 }
74114
115+ // let A_x_min = 55;
116+ // let A_x_max = 65;
117+ //
118+ // let B_x_min = 535;
119+ // let B_x_max = 545;
120+
121+
75122 if values.len() >= 4 {
76123
77124 //Character A, X value
78- if values[0] < 55 || values[0] > 65 {
125+ if values[0] < A_x_min || values[0] > A_x_max {
79126 println!("FAIL values[0]: {}", values[0]);
80127 return false;
81128 }
@@ -87,7 +134,7 @@
87134 }
88135
89136 //Character B, X value
90- if values[2] < 535 || values[2] > 545 {
137+ if values[2] < B_x_min || values[2] > B_x_max {
91138 println!("FAIL values[2]: {}", values[2]);
92139 return false;
93140 }
旧リポジトリブラウザで表示