Last active
January 4, 2016 00:38
-
-
Save geekuillaume/8542576 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
#include "ex00.hh" | |
const Cluedo::Weapon::Name Cluedo::Weapon::PartOfTheCrime = Corde; | |
const Cluedo::Suspect::Name Cluedo::Suspect::PartOfTheCrime = Pr_Violet; | |
const Cluedo::Room::Name Cluedo::Room::PartOfTheCrime = Veranda; | |
int main() | |
{ | |
Cluedo::Weapon* w[] = { | |
new Cluedo::Weapon((Cluedo::Weapon::Name)0, true), | |
new Cluedo::Weapon((Cluedo::Weapon::Name)1, false), | |
new Cluedo::Weapon((Cluedo::Weapon::Name)2, true), | |
NULL | |
}; | |
Cluedo::Room* r[] = { | |
new Cluedo::Room((Cluedo::Room::Name)0, true), | |
new Cluedo::Room((Cluedo::Room::Name)1, false), | |
new Cluedo::Room((Cluedo::Room::Name)2, true), | |
NULL | |
}; | |
Cluedo::Suspect* s[] = { | |
new Cluedo::Suspect((Cluedo::Suspect::Name)0, true), | |
new Cluedo::Suspect((Cluedo::Suspect::Name)1, false), | |
new Cluedo::Suspect((Cluedo::Suspect::Name)2, true), | |
NULL | |
}; | |
std::cout << "Should return 1 : " << Cluedo::Game::CaseSolved(w, s, r) << std::endl; | |
w[0] = new Cluedo::Weapon((Cluedo::Weapon::Name)5, true); | |
try { | |
Cluedo::Game::CaseSolved(w, s, r); | |
} | |
catch (WeaponException *e) | |
{ | |
std::cout << "Should say : Weapon ne contient pas la bonne carte!" << std::endl; | |
std::cout << e->getMessage() << std::endl; | |
std::cout << "Should return 1 : " << (e->getCards() == w) << std::endl; | |
} | |
s[1] = new Cluedo::Suspect((Cluedo::Suspect::Name)5, true); | |
std::cout << "Should return 0 : " << Cluedo::Game::CaseSolved(w, s, r) << std::endl; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
#include "ex01.hh" | |
const Cluedo::Weapon::Name Cluedo::Weapon::PartOfTheCrime = Corde; | |
const Cluedo::Suspect::Name Cluedo::Suspect::PartOfTheCrime = Pr_Violet; | |
const Cluedo::Room::Name Cluedo::Room::PartOfTheCrime = Veranda; | |
int main() | |
{ | |
Cluedo::Weapon* w[] = { | |
new Cluedo::Weapon((Cluedo::Weapon::Name)0, true), | |
new Cluedo::Weapon((Cluedo::Weapon::Name)1, false), | |
new Cluedo::Weapon((Cluedo::Weapon::Name)2, true), | |
NULL | |
}; | |
Cluedo::Room* r[] = { | |
new Cluedo::Room((Cluedo::Room::Name)0, true), | |
new Cluedo::Room((Cluedo::Room::Name)1, false), | |
new Cluedo::Room((Cluedo::Room::Name)2, true), | |
NULL | |
}; | |
Cluedo::Suspect* s[] = { | |
new Cluedo::Suspect((Cluedo::Suspect::Name)0, true), | |
new Cluedo::Suspect((Cluedo::Suspect::Name)1, false), | |
new Cluedo::Suspect((Cluedo::Suspect::Name)2, true), | |
NULL | |
}; | |
std::cout << "Should return 1 : " << Cluedo::Game::CaseSolved(w, s, r) << std::endl; | |
w[0] = new Cluedo::Weapon((Cluedo::Weapon::Name)5, true); | |
std::cout << "Should say : Weapon ne contient pas la bonne carte!" << std::endl; | |
try { | |
Cluedo::Game::CaseSolved(w, s, r); | |
} | |
catch (WeaponException *e) | |
{ | |
std::cout << e->getMessage() << std::endl; | |
std::cout << "Should return 1 : " << (e->getCards() == w) << std::endl; | |
} | |
s[1] = new Cluedo::Suspect((Cluedo::Suspect::Name)5, true); | |
std::cout << "Should return 0 : " << Cluedo::Game::CaseSolved(w, s, r) << std::endl; | |
std::cout << std::endl << "----Testing ex01" << std::endl; | |
Cluedo::Card* c[] = { | |
new Cluedo::Weapon((Cluedo::Weapon::Name)0, true), | |
new Cluedo::Weapon((Cluedo::Weapon::Name)1, false), | |
new Cluedo::Weapon((Cluedo::Weapon::Name)2, true), | |
new Cluedo::Room((Cluedo::Room::Name)0, true), | |
new Cluedo::Room((Cluedo::Room::Name)1, false), | |
new Cluedo::Room((Cluedo::Room::Name)2, true), | |
new Cluedo::Suspect((Cluedo::Suspect::Name)0, true), | |
new Cluedo::Suspect((Cluedo::Suspect::Name)1, false), | |
new Cluedo::Suspect((Cluedo::Suspect::Name)2, true), | |
NULL | |
}; | |
std::cout << "Should return 1 : " << Cluedo::Game::CaseSolved(c) << std::endl; | |
c[0] = new Cluedo::Weapon((Cluedo::Weapon::Name)5, true); | |
std::cout << "Should return 0 : " << Cluedo::Game::CaseSolved(c) << std::endl; | |
c[5] = new Cluedo::Room((Cluedo::Room::Name)5, false); | |
c[7] = new Cluedo::Suspect((Cluedo::Suspect::Name)5, true); | |
std::cout << "Should say : Aucune des cartes ne correspond!" << std::endl; | |
try { | |
Cluedo::Game::CaseSolved(c); | |
} | |
catch (CardException *e) | |
{ | |
std::cout << e->what() << std::endl; | |
std::cout << "Should return 1 : " << (e->getCards() == c) << std::endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment