Skip to content

Commit 157cda1

Browse files
test: Add tests for policy
1 parent 4694dc2 commit 157cda1

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/basic/test_policies.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <gtest/gtest.h>
2+
3+
import mcpplibs.primitive;
4+
5+
namespace {} // namespace
6+
7+
using namespace mcpplibs::primitive;
8+
9+
TEST(PolicyTraitsTest, BuiltinPoliciesHaveCategories) {
10+
using namespace policy;
11+
12+
EXPECT_TRUE((policy::traits<policy::checked_value>::enabled));
13+
EXPECT_EQ(policy::traits<policy::checked_value>::kind,
14+
policy::category::value);
15+
16+
EXPECT_TRUE((policy::traits<policy::relaxed_type>::enabled));
17+
EXPECT_EQ(policy::traits<policy::relaxed_type>::kind, policy::category::type);
18+
19+
EXPECT_TRUE((policy::traits<policy::throw_error>::enabled));
20+
EXPECT_EQ(policy::traits<policy::throw_error>::kind, policy::category::error);
21+
22+
EXPECT_TRUE((policy::traits<policy::single_thread>::enabled));
23+
EXPECT_EQ(policy::traits<policy::single_thread>::kind,
24+
policy::category::concurrency);
25+
26+
EXPECT_TRUE((policy_type<policy::checked_value>));
27+
EXPECT_FALSE((policy_type<int>));
28+
29+
EXPECT_TRUE((std::is_same_v<policy::default_policies::value,
30+
policy::unchecked_value>));
31+
}
32+
33+
// Use the existing test runner main from other test translation unit.

0 commit comments

Comments
 (0)