Skip to content

Commit

Permalink
fix tag in StaticSingletonManager tests
Browse files Browse the repository at this point in the history
Summary: The tag type should be per-type-param, not shared between type-params.

Reviewed By: Gownta

Differential Revision: D56318056

fbshipit-source-id: c53a79d26e80a1b63f420f8b143dc880b8bd148b
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Apr 19, 2024
1 parent e410c28 commit 0540a52
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions folly/detail/test/StaticSingletonManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ template <typename Impl>
struct StaticSingletonManagerTest : public testing::TestWithParam<Impl> {};
TYPED_TEST_SUITE_P(StaticSingletonManagerTest);

template <typename T>
template <typename Impl, typename T>
struct Tag {};

template <int I>
Expand All @@ -59,18 +59,18 @@ TYPED_TEST_P(StaticSingletonManagerTest, example) {

using T = std::integral_constant<int, 3>;

auto& i = K::template create<T, Tag<char>>();
auto& i = K::template create<T, Tag<K, char>>();
EXPECT_EQ(T::value, i);

auto& j = K::template create<T, Tag<char>>();
auto& j = K::template create<T, Tag<K, char>>();
EXPECT_EQ(&i, &j);
EXPECT_EQ(T::value, j);

auto& k = K::template create<T, Tag<char*>>();
auto& k = K::template create<T, Tag<K, char*>>();
EXPECT_NE(&i, &k);
EXPECT_EQ(T::value, k);

static typename K::template ArgCreate<true> m_arg{tag<T, Tag<int>>};
static typename K::template ArgCreate<true> m_arg{tag<T, Tag<K, int>>};
auto& m = K::template create<T>(m_arg);
EXPECT_NE(&i, &m);
EXPECT_EQ(T::value, m);
Expand All @@ -86,22 +86,23 @@ INSTANTIATE_TYPED_TEST_SUITE_P(
INSTANTIATE_TYPED_TEST_SUITE_P(
with_rtti, StaticSingletonManagerTest, StaticSingletonManagerWithRtti);
#endif
struct StaticSingletonManagerTestType : StaticSingletonManager {};
INSTANTIATE_TYPED_TEST_SUITE_P(
selection, StaticSingletonManagerTest, StaticSingletonManager);
selection, StaticSingletonManagerTest, StaticSingletonManagerTestType);

struct CreateGlobalTest : testing::Test {};

TEST_F(CreateGlobalTest, example) {
using T = std::integral_constant<int, 3>;

auto& i = createGlobal<T, Tag<char>>();
auto& i = createGlobal<T, Tag<void, char>>();
EXPECT_EQ(T::value, i);

auto& j = createGlobal<T, Tag<char>>();
auto& j = createGlobal<T, Tag<void, char>>();
EXPECT_EQ(&i, &j);
EXPECT_EQ(T::value, j);

auto& k = createGlobal<T, Tag<char*>>();
auto& k = createGlobal<T, Tag<void, char*>>();
EXPECT_NE(&i, &k);
EXPECT_EQ(T::value, k);
}
Expand Down

0 comments on commit 0540a52

Please sign in to comment.