/*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <folly/Memory.h>
#include <folly/Arena.h>
#include <folly/String.h>
+#include <folly/portability/GTest.h>
#include <glog/logging.h>
-#include <gtest/gtest.h>
#include <type_traits>
using namespace folly;
+TEST(make_unique, compatible_with_std_make_unique) {
+ // HACK: To enforce that `folly::` is imported here.
+ to_shared_ptr(std::unique_ptr<std::string>());
+
+ using namespace std;
+ make_unique<string>("hello, world");
+}
+
+TEST(to_weak_ptr, example) {
+ auto s = std::make_shared<int>(17);
+ EXPECT_EQ(1, s.use_count());
+ EXPECT_EQ(2, (to_weak_ptr(s).lock(), s.use_count())) << "lvalue";
+ EXPECT_EQ(3, (to_weak_ptr(decltype(s)(s)).lock(), s.use_count())) << "rvalue";
+}
+
+TEST(allocate_sys_buffer, compiles) {
+ auto buf = allocate_sys_buffer(256);
+ // Freed at the end of the scope.
+}
+
template <std::size_t> struct T {};
template <std::size_t> struct S {};
template <std::size_t> struct P {};
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();
-}