int run() { char *foo = (char*)malloc(sizeof(char)); basics(); gets(foo); clearAndRefresh(); clearBodies(); draw(); }
TEST(SynchronizedPtrTest, Optional) { folly::SynchronizedPtr<folly::Optional<int>, folly::RWSpinLock> pInt{0}; basics(pInt); EXPECT_TRUE( (std::is_same<folly::Optional<int>&, decltype(*pInt.wlockPointer())>:: value)); EXPECT_TRUE(static_cast<bool>(pInt.rlock())); pInt.withWLockPointer([](auto&& ptr) { EXPECT_TRUE((std::is_same<folly::Optional<int>&, decltype(ptr)>::value)); ptr.clear(); }); EXPECT_FALSE(static_cast<bool>(pInt.rlock())); }
TEST(SynchronizedPtrTest, Replaceable) { folly::SynchronizedPtr<folly::Replaceable<int>> pInt{0}; folly::SynchronizedPtr<folly::Replaceable<int const>> pcInt{2}; basics(pInt); EXPECT_TRUE( (std::is_same<folly::Replaceable<int>&, decltype(*pInt.wlockPointer())>:: value)); EXPECT_TRUE((std::is_same< folly::Replaceable<int const>&, decltype(*pcInt.wlockPointer())>::value)); pcInt.withWLockPointer([](auto&& ptr) { EXPECT_TRUE( (std::is_same<folly::Replaceable<int const>&, decltype(ptr)>::value)); ptr.emplace(4); }); EXPECT_EQ(4, *pcInt.rlock()); }
TEST(SynchronizedPtrTest, UniqueDeleter) { bool calledDeleter = false; auto x = [&](int* ptr) { delete ptr; calledDeleter = true; }; { folly::SynchronizedPtr<std::unique_ptr<int, decltype(x)>> pInt{ std::unique_ptr<int, decltype(x)>(new int(0), x)}; basics(pInt); EXPECT_TRUE((std::is_same< std::unique_ptr<int, decltype(x)>&, decltype(*pInt.wlockPointer())>::value)); pInt.wlockPointer()->reset(new int(5)); EXPECT_TRUE(calledDeleter); calledDeleter = false; } EXPECT_TRUE(calledDeleter); }
int main(void) { /* Declare YOUR variables here ! */ int menu_choice, retval; my_clearscrn(); prompt_and_pause(INITIAL_INFO); /* Enter menu loop.. */ do { menu_choice = menu(MAIN_MENU_ROW, 0, 3); switch (menu_choice) { case 1: if ((retval = basics()) != OK) { exit(EXIT_FAILURE); } break; case 2: if ((retval = bfs()) != OK) { exit(EXIT_FAILURE); } break; case 3: if ((retval = dfs()) != OK) { exit(EXIT_FAILURE); } break; default: prompt_and_pause("\nThat's all folks - Bye..!"); break; } } while (menu_choice); return 0; }
int main(int argc, char **argv) { try { ict::command line("multivectorcli", "ict::multivector exerciser", "mvcli [options]"); line.add(ict::option("basics", 'b', "Display basic multivector calls", []{ basics(); } )); line.add(ict::option("iterate", 'i', "Display iterator calls", []{ iterate(); } )); line.add(ict::option("strings", 's', "Display string multivector calls", []{ strings(); } )); line.add(ict::option("custom", 'c', "Display custom multivector calls", []{ custom(); } )); line.add(ict::option("generate", 'g', "generate advanced multivector", []{ generate(); } )); line.add(ict::option("constness", 'C', "const iterators/cursors", []{ constness(); } )); line.add(ict::option("All", 'A', "run all", []{ basics(); iterate(); strings(); custom(); generate(); constness(); } )); line.parse(argc, argv); } catch (std::exception & e) { std::cerr << e.what() << std::endl; } }
TEST(SynchronizedPtrTest, UniqueBasic) { folly::SynchronizedPtr<std::unique_ptr<int>> pInt{std::make_unique<int>(0)}; basics(pInt); }
TEST(SynchronizedPtrTest, Shared) { folly::SynchronizedPtr<std::shared_ptr<int>> pInt{std::make_shared<int>(0)}; basics(pInt); }