//---------------------------------------------------------------------------// // test the plant class void test_plant() { std::cout << "plant test" << std::endl; // make a plant. Plant kale("kale", .7, 2, 5000); // try to clone the kale and check that they have the same name. Organism *kale2 = kale.clone(); if (kale2->getName() != kale.getName()) throw CppException("Failed to create plant using Organism clone function"); // now try the other constructor mechanism. Plant kale3(kale); if (kale3.getName() != kale.getName()) throw CppException("Failed to create plant using Plant(plant) function"); }
//---------------------------------------------------------------------------// // test the animal class void test_animal() { std::cout << "animal test" << std::endl; std::vector<std::string> food; food.push_back("goats"); // make an animal. Animal chupacabra("chupacabra", .7,2, food); // try to clone the animal Organism *chupacabra2 = chupacabra.clone(); if (chupacabra2->getName() != chupacabra.getName()) throw CppException("Failed to create animal using Organism clone function"); }
int main() { CppException(); return 0; }