X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Ftest%2FMemoryTest.cpp;h=d61934024738f0fa1391ebedee4ad171f5b7bf42;hb=8cf0c3e0f10e74e89f0b868e4168ec019ed9b998;hp=03c53ee7508474af90e2a910b3b6b7ec0cd980af;hpb=74a1c03549d4ae3374eba514b6bcb564e7779929;p=folly.git diff --git a/folly/test/MemoryTest.cpp b/folly/test/MemoryTest.cpp index 03c53ee7..d6193402 100644 --- a/folly/test/MemoryTest.cpp +++ b/folly/test/MemoryTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 Facebook, Inc. + * Copyright 2016 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,40 +25,12 @@ using namespace folly; -namespace { -class disposable { - public: - explicit disposable(std::function onDispose) : - onDispose_(std::move(onDispose)) {} - static void dispose(disposable* f) { - ASSERT_NE(nullptr, f); - f->onDispose_(); - delete f; - } - private: - std::function onDispose_; -}; -} - -TEST(static_function_deleter, example) { - size_t count = 0; - using disposable_deleter = - static_function_deleter; - make_unique([&] { ++count; }); - EXPECT_EQ(1, count); -} - -TEST(static_function_deleter, nullptr) { - using disposable_deleter = - static_function_deleter; - std::unique_ptr(nullptr); -} +TEST(make_unique, compatible_with_std_make_unique) { + // HACK: To enforce that `folly::` is imported here. + to_shared_ptr(std::unique_ptr()); -TEST(shared_ptr, example) { - auto uptr = make_unique("hello"); - auto sptr = to_shared_ptr(std::move(uptr)); - EXPECT_EQ(nullptr, uptr); - EXPECT_EQ("hello", *sptr); + using namespace std; + make_unique("hello, world"); } template struct T {}; @@ -121,11 +93,3 @@ TEST(rebind_allocator, sanity_check) { s.reset(); ASSERT_EQ(nullptr, s.get()); } - -int main(int argc, char **argv) { - FLAGS_logtostderr = true; - google::InitGoogleLogging(argv[0]); - testing::InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -}