int main() { Toy *b = new Buzz("buzziiiii"); Toy *w = new Woody("wood"); Toy *t = new Toy(Toy::ALIEN, "ET", "alien.txt"); b->speak("To the code, and beyond !!!!!!!!"); w->speak("There’s a snake in my boot."); t->speak("the claaaaaaw"); return (0); }
int main() { // PICTURE Tester *tester = new Tester("Picture"); Picture p; tester->test(p.data, std::string(""), "constructor without filename make an empty string"); p.getPictureFromFile(std::string("file.test")); tester->test(p.data, std::string("this is a test\ncool"), "when a correct filename is provided, it correctly reads the file"); p.getPictureFromFile(std::string("notExistingFile.test")); tester->test(p.data, std::string("ERROR"), "when there is an error, the string is set to ERROR"); delete tester; // PICTURE // TOY tester = new Tester("Toy"); Toy t; tester->test(t.getType(), Toy::BASIC_TOY, "default constructor set the type to BASIC_TOY"); tester->test(t.getName(), std::string("toy"), "default constructor set the name to toy"); tester->test(t.getAscii(), std::string(""), "default constructor set the ascii to ''"); Toy t2(Toy::ALIEN, std::string("E.T"), std::string("file.test")); tester->test(t2.getType(), Toy::ALIEN, "constructor set the type correctly"); tester->test(t2.getName(), std::string("E.T"), "constructor set the name correctly"); tester->test(t2.getAscii(), std::string("this is a test\ncool"), "constructor set the ascii correctly"); t = t2; tester->test(t.getType(), t2.getType() , "operator= set the type correctly"); tester->test(t.getName(), t2.getName(), "operator= set the name correctly"); tester->test(t.getAscii(), t2.getAscii(), "operator= set the ascii correctly"); delete tester; // TOY // BUZZ + WOODY tester = new Tester("Buzz and Woody"); Buzz buzz(std::string("foo")); Woody woody(std::string("bar"), std::string("file.test")); tester->test(buzz.getType(), Toy::BUZZ, "Buzz constructor (no file) set the type correctly"); tester->test(buzz.getName(), std::string("foo"), "Buzz constructor (no file) set the name correctly"); tester->test(buzz.getAscii(), std::string("Buzz !!!"), "Buzz constructor (no file) set the ascii correctly"); tester->test(woody.getType(), Toy::WOODY, "Woody constructor set the type correctly"); tester->test(woody.getName(), std::string("bar"), "Woody constructor set the name correctly"); tester->test(woody.getAscii(), std::string("this is a test\ncool"), "Woody constructor set the ascii correctly"); tester->warn("The following tests cannot be unit tested, please check by hand"); t.speak("I cannot unit test this... Does it work ? (toy)"); buzz.speak("I cannot unit test this... Does it work ? (buzz)"); woody.speak("I cannot unit test this... Does it work ? (woody)"); delete tester; // BUZZ + WOODY // OPERATOR<< tester = new Tester("operator<<"); t << "woohoo"; tester->test(t.getAscii(), std::string("woohoo"), "operator<< with TOY and STRING"); tester->warn("The following test cannot be unit tested, please check by hand"); std::cout << t; delete tester; // OPERATOR<< return 0; }