#include "pch.h" #include "NapTree.h" TEST(NapTree, No) { auto* tree = create_tree(); ASSERT_NE(tree, nullptr); Params params; params.want_to_nap = false; ASSERT_FALSE(tree->process(params)); delete tree; } TEST(NapTree, NegativePath) { auto* tree = create_tree(); ASSERT_NE(tree, nullptr); Params params; params.want_to_nap = true; ASSERT_FALSE(tree->process(params)); delete tree; } TEST(NapTree, PositivePath) { auto* tree = create_tree(); ASSERT_NE(tree, nullptr); Params params; params.want_to_nap = true; params.trouble_sleeping_at_night = true; ASSERT_FALSE(tree->process(params)); delete tree; } TEST(NapTree, Path1) { auto* tree = create_tree(); ASSERT_NE(tree, nullptr); Params params; params.want_to_nap = true; params.trouble_sleeping_at_night = false; params.after_4_pm = true; ASSERT_FALSE(tree->process(params)); delete tree; } TEST(NapTree, Path2a) { auto* tree = create_tree(); ASSERT_NE(tree, nullptr); Params params; params.want_to_nap = true; params.trouble_sleeping_at_night = false; params.after_4_pm = false; params.at_work = true; params.will_boss_be_mad = false; params.have_30_minutes = false; params.have_10_minutes = true; ASSERT_TRUE(tree->process(params)); delete tree; } TEST(NapTree, Path2b) { auto* tree = create_tree(); ASSERT_NE(tree, nullptr); Params params; params.want_to_nap = true; params.trouble_sleeping_at_night = false; params.after_4_pm = false; params.at_work = true; params.will_boss_be_mad = false; params.have_30_minutes = false; params.have_10_minutes = false; ASSERT_FALSE(tree->process(params)); delete tree; } TEST(NapTree, Path3) { auto* tree = create_tree(); ASSERT_NE(tree, nullptr); Params params; params.want_to_nap = true; params.trouble_sleeping_at_night = false; params.after_4_pm = false; params.at_work = true; params.will_boss_be_mad = true; ASSERT_FALSE(tree->process(params)); } TEST(NapTree, Path4) { auto* tree = create_tree(); ASSERT_NE(tree, nullptr); Params params; params.want_to_nap = true; params.trouble_sleeping_at_night = false; params.after_4_pm = false; params.at_work = false; params.have_30_minutes = true; ASSERT_TRUE(tree->process(params)); delete tree; } TEST(NapTree, Path5) { auto* tree = create_tree(); ASSERT_NE(tree, nullptr); Params params; params.want_to_nap = true; params.trouble_sleeping_at_night = false; params.after_4_pm = false; params.at_work = true; params.have_30_minutes = true; ASSERT_TRUE(tree->process(params)); delete tree; } //you can use this main to debug your code int main(int argc, char* argv[]) { const auto* nap_tree = create_tree(); //change parameters here Params params; params.want_to_nap = false; const bool result = nap_tree->process(params); std::cout << "Should I Nap? " << (result ? "YES" : "NO") << std::endl; testing::InitGoogleTest(&argc, argv); RUN_ALL_TESTS(); }