Skip to content

Commit

Permalink
Random Annotation: add UT for "any" annotation should work
Browse files Browse the repository at this point in the history
Summary:
rework of: D63428747

this is to add UT coverage for any annotation should not break hybrid_cow

Differential Revision:
D64433851

Privacy Context Container: L1125642

fbshipit-source-id: 69d656832a29f01345ee52276107c7cc5aa3e00c
  • Loading branch information
Wei-Cheng Lin authored and facebook-github-bot committed Oct 16, 2024
1 parent b1c6f0e commit a9f64a4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
22 changes: 15 additions & 7 deletions fboss/thrift_cow/nodes/tests/ThriftHybridStructNodeTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,27 @@ TEST(ThriftHybridStructNodeTests, ReadThriftStructAnnotation) {
}

TEST(ThriftHybridStructNodeTests, ThriftStructNodeAnnotations) {
ThriftStructFields<TestStruct> fields;
{
ThriftStructFields<TestStruct> fields;

#ifdef __ENABLE_HYBRID_THRIFT_COW_TESTS__
static_assert(fields.isSkipThriftCowEnabled<k::hybridMap>() == true);
static_assert(fields.isSkipThriftCowEnabled<k::hybridMap>() == true);
#endif // __ENABLE_HYBRID_THRIFT_COW_TESTS__
static_assert(fields.isSkipThriftCowEnabled<k::cowMap>() == false);

ThriftStructNode<TestStruct> node;
static_assert(fields.isSkipThriftCowEnabled<k::cowMap>() == false);
}
{
ThriftStructNode<TestStruct> node;

#ifdef __ENABLE_HYBRID_THRIFT_COW_TESTS__
ASSERT_EQ(node.isSkipThriftCowEnabled<k::hybridMap>(), true);
ASSERT_EQ(node.isSkipThriftCowEnabled<k::hybridMap>(), true);
#endif // __ENABLE_HYBRID_THRIFT_COW_TESTS__
ASSERT_EQ(node.isSkipThriftCowEnabled<k::cowMap>(), false);
ASSERT_EQ(node.isSkipThriftCowEnabled<k::cowMap>(), false);
}
// annotation that is other than `allow_skip_thrift_cow`
{
ThriftStructNode<TestStruct2> node;
ASSERT_EQ(node.isSkipThriftCowEnabled<k::deprecatedField>(), false);
}
}

TEST(ThriftHybridStructNodeTests, TestHybridNodeTypes) {
Expand Down
4 changes: 3 additions & 1 deletion fboss/thrift_cow/nodes/tests/test.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,6 @@ struct ParentTestStruct {
1: TestStruct childStruct;
} (random_annotation)

struct TestStruct2 {} (deprecated, allow_skip_thrift_cow = false)
struct TestStruct2 {
10: i32 deprecatedField (deprecated);
} (deprecated, allow_skip_thrift_cow = false)

0 comments on commit a9f64a4

Please sign in to comment.