Skip to content

Commit

Permalink
One more test for invalid ember usage
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Jul 3, 2024
1 parent 10090b6 commit 1647108
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/app/codegen-data-model/tests/TestCodegenModelViaMocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2247,3 +2247,26 @@ TEST(TestCodegenModelViaMocks, EmberWriteAttributeAccessInterfaceReturningError)
AttributeValueDecoder decoder = test.DecoderFor(testValue);
ASSERT_EQ(model.WriteAttribute(test.request, decoder), CHIP_ERROR_KEY_NOT_FOUND);
}

TEST(TestCodegenModelViaMocks, EmberWriteInvalidDataType)
{
UseMockNodeConfig config(gTestNodeConfig);
chip::app::CodegenDataModel model;
ScopedMockAccessControl accessControl;

// Embed specifically DOES NOT support structures. Without AAI, we expect a constraint error
const ConcreteAttributePath kStructPath(kMockEndpoint3, MockClusterId(4),
MOCK_ATTRIBUTE_ID_FOR_NON_NULLABLE_TYPE(ZCL_STRUCT_ATTRIBUTE_TYPE));

TestWriteRequest test(kAdminSubjectDescriptor, kStructPath);
Clusters::UnitTesting::Structs::SimpleStruct::Type testValue{
.a = 112,
.b = true,
.e = "aai_write_test"_span,
.g = 0.5,
.h = 0.125,
};

AttributeValueDecoder decoder = test.DecoderFor(testValue);
ASSERT_EQ(model.WriteAttribute(test.request, decoder), CHIP_IM_GLOBAL_STATUS(ConstraintError));
}

0 comments on commit 1647108

Please sign in to comment.