Commit b05020b2 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Test cases for StaticSingletonManager

Summary: [Folly] Test cases for `StaticSingletonManager`.

Differential Revision: D9735443

fbshipit-source-id: e922d7742c12e6ca7725dc7782cc683cf71fb6a7
parent 88324bac
......@@ -440,6 +440,9 @@ if (BUILD_TESTS)
SOURCES DynamicBoundedQueueTest.cpp
TEST unbounded_queue_test SOURCES UnboundedQueueTest.cpp
DIRECTORY detail/test/
TEST static_singleton_manager_test SOURCES StaticSingletonManagerTest.cpp
DIRECTORY executors/test/
TEST async_helpers_test SOURCES AsyncTest.cpp
TEST codel_test SOURCES CodelTest.cpp
......
/*
* Copyright 2018-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <folly/detail/StaticSingletonManager.h>
#include <folly/portability/GTest.h>
namespace folly {
namespace detail {
struct StaticSingletonManagerTest : public testing::Test {};
template <typename T>
struct Tag {};
TEST_F(StaticSingletonManagerTest, example) {
auto make3 = [n = 3] { return new int(n); };
auto i = createGlobal<int, Tag<char>>(make3);
ASSERT_NE(nullptr, i);
EXPECT_EQ(3, *i);
auto const make4 = [n = 4] { return new int(n); };
auto j = createGlobal<int, Tag<char>>(make4);
ASSERT_NE(nullptr, j);
EXPECT_EQ(i, j);
EXPECT_EQ(3, *j);
auto make5 = [n = 5] { return new int(n); };
auto k = createGlobal<int, Tag<char*>>(std::move(make5));
ASSERT_NE(nullptr, k);
EXPECT_NE(i, k);
EXPECT_EQ(5, *k);
}
} // namespace detail
} // namespace folly
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment