@@ -169,3 +169,91 @@ TEST_CASE("ChordGame Completely Incorrect") {
169169 game.stop ();
170170 if (gameThread.joinable ()) gameThread.join ();
171171}
172+
173+ // / Vérifie l'insensibilité à l'octave pour le jeu d'accords simples
174+ TEST_CASE (" ChordGame Octave Insensitivity Simple Chords" ) {
175+ MockTransport transport;
176+ MockMidiInput midi;
177+ ChallengeFactory factory;
178+ GameConfig config;
179+ config.scale = " c" ;
180+ config.mode = " maj" ;
181+ config.maxChallenges = 1 ;
182+ ChordGame game (transport, midi, factory, config, false );
183+
184+ transport.waitForClient ();
185+ game.start ();
186+ std::thread gameThread ([&game]() { game.play (); });
187+
188+ Message msg1 = transport.waitForSentMessage ();
189+ CHECK (msg1.getType () == " chord" );
190+ std::string notesStr = msg1.getField (" notes" );
191+
192+ std::vector<std::string> notes;
193+ std::stringstream ss (notesStr);
194+ std::string segment;
195+ while (std::getline (ss, segment, ' ' )) notes.push_back (segment);
196+
197+ // Décale toutes les notes d'un octave vers le bas pour tester
198+ // l'insensibilité
199+ std::vector<std::string> playedNotes;
200+ for (const auto & note : notes) {
201+ int oct = note.back () - ' 0' ;
202+ playedNotes.push_back (note.substr (0 , note.size () - 1 ) +
203+ std::to_string (oct - 1 ));
204+ }
205+
206+ midi.pushNotes (playedNotes);
207+
208+ Message res1 = transport.waitForSentMessage ();
209+ CHECK (res1.getType () == " result" );
210+ CHECK (res1.hasField (" correct" ));
211+ CHECK_FALSE (res1.hasField (" incorrect" ));
212+
213+ game.stop ();
214+ if (gameThread.joinable ()) gameThread.join ();
215+ }
216+
217+ // / Vérifie l'insensibilité à l'octave pour le jeu d'accords avec renversements
218+ TEST_CASE (" ChordGame Octave Insensitivity Inversed Chords" ) {
219+ MockTransport transport;
220+ MockMidiInput midi;
221+ ChallengeFactory factory;
222+ GameConfig config;
223+ config.scale = " c" ;
224+ config.mode = " maj" ;
225+ config.maxChallenges = 1 ;
226+ ChordGame game (transport, midi, factory, config, true );
227+
228+ transport.waitForClient ();
229+ game.start ();
230+ std::thread gameThread ([&game]() { game.play (); });
231+
232+ Message msg1 = transport.waitForSentMessage ();
233+ CHECK (msg1.getType () == " chord" );
234+ std::string notesStr = msg1.getField (" notes" );
235+
236+ std::vector<std::string> notes;
237+ std::stringstream ss (notesStr);
238+ std::string segment;
239+ while (std::getline (ss, segment, ' ' )) notes.push_back (segment);
240+
241+ // Décale toutes les notes d'un octave vers le bas pour tester
242+ // l'insensibilité
243+ std::vector<std::string> playedNotes;
244+ for (const auto & note : notes) {
245+ int oct = note.back () - ' 0' ;
246+ playedNotes.push_back (note.substr (0 , note.size () - 1 ) +
247+ std::to_string (oct - 1 ));
248+ }
249+
250+ midi.pushNotes (playedNotes);
251+
252+ Message res1 = transport.waitForSentMessage ();
253+ CHECK (res1.getType () == " result" );
254+ CHECK (res1.hasField (" correct" ));
255+ CHECK_FALSE (res1.hasField (" incorrect" ));
256+
257+ game.stop ();
258+ if (gameThread.joinable ()) gameThread.join ();
259+ }
0 commit comments