diff --git a/src/app/zap-templates/common/ClusterTestGeneration.js b/src/app/zap-templates/common/ClusterTestGeneration.js index 936611a8c71acc..2b67190434656c 100644 --- a/src/app/zap-templates/common/ClusterTestGeneration.js +++ b/src/app/zap-templates/common/ClusterTestGeneration.js @@ -288,19 +288,13 @@ function setDefaultResponse(test) throwError(test, errorStr); } - const name = test.isAttribute ? test.attribute : test.event; - const response = test[kResponseName]; - if (hasResponseValue) { - const value = { name, value : response.value, saveAs : response.saveAs }; - response.values.push(value); - } + if (hasResponseValueOrConstraints) { + const name = test.isAttribute ? test.attribute : test.event; + const response = test[kResponseName]; + const responseValue = hasResponseValue ? { value : response.value } : null; + const constraintsValue = hasResponseConstraints ? { constraints : response.constraints } : null; - if (hasResponseConstraints) { - let constraints = { name : name, constraints : response.constraints }; - if ('saveAs' in response && !hasResponseValue) { - constraints.saveAs = response.saveAs; - } - response.values.push(constraints); + response.values.push({ name, saveAs : response.saveAs, ...responseValue, ...constraintsValue }); } delete test[kResponseName].value; diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index e5340ef7df3223..835eb5fa2b4999 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -20086,6 +20086,18 @@ - (void)testSendClusterTest_TC_TSTAT_2_2_000001_ReadAttribute id actualValue = value; XCTAssertEqual([actualValue shortValue], 2600); } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue shortValue], 1600); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue shortValue], 2600); + } + } [expectation fulfill]; }]; @@ -20213,6 +20225,18 @@ - (void)testSendClusterTest_TC_TSTAT_2_2_000006_ReadAttribute id actualValue = value; XCTAssertEqual([actualValue shortValue], 2000); } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue shortValue], 700); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue shortValue], 3000); + } + } [expectation fulfill]; }]; @@ -20339,6 +20363,18 @@ - (void)testSendClusterTest_TC_TSTAT_2_2_000011_ReadAttribute id actualValue = value; XCTAssertEqual([actualValue shortValue], 700); } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue shortValue], 700); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue shortValue], 3000); + } + } [expectation fulfill]; }]; @@ -20465,6 +20501,18 @@ - (void)testSendClusterTest_TC_TSTAT_2_2_000016_ReadAttribute id actualValue = value; XCTAssertEqual([actualValue shortValue], 3000); } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue shortValue], 700); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue shortValue], 3000); + } + } [expectation fulfill]; }]; @@ -20591,6 +20639,18 @@ - (void)testSendClusterTest_TC_TSTAT_2_2_000021_ReadAttribute id actualValue = value; XCTAssertEqual([actualValue shortValue], 1600); } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue shortValue], 1600); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue shortValue], 3200); + } + } [expectation fulfill]; }]; @@ -20717,6 +20777,18 @@ - (void)testSendClusterTest_TC_TSTAT_2_2_000026_ReadAttribute id actualValue = value; XCTAssertEqual([actualValue shortValue], 3200); } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue shortValue], 1600); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue shortValue], 3200); + } + } [expectation fulfill]; }]; @@ -21042,6 +21114,18 @@ - (void)testSendClusterTest_TC_TSTAT_2_2_000039_ReadAttribute id actualValue = value; XCTAssertEqual([actualValue unsignedCharValue], 4); } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertGreaterThanOrEqual([actualValue unsignedCharValue], 0); + } + } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertLessThanOrEqual([actualValue unsignedCharValue], 5); + } + } [expectation fulfill]; }]; @@ -38512,6 +38596,12 @@ - (void)testSendClusterTestSaveAs_000097_ReadAttribute XCTAssertTrue([actualValue isEqualToString:@"NotDefault"]); readAttributeCharStringNotDefaultValue = [NSMutableString stringWithString:actualValue]; } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertNotEqualObjects(actualValue, readAttributeCharStringDefaultValue); + } + } [expectation fulfill]; }]; @@ -38537,6 +38627,12 @@ - (void)testSendClusterTestSaveAs_000098_ReadAttribute id actualValue = value; XCTAssertEqualObjects(actualValue, readAttributeCharStringNotDefaultValue); } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertNotEqualObjects(actualValue, readAttributeCharStringDefaultValue); + } + } [expectation fulfill]; }]; @@ -38706,6 +38802,12 @@ - (void)testSendClusterTestSaveAs_000105_ReadAttribute XCTAssertTrue([actualValue isEqualToData:[[NSData alloc] initWithBytes:"NotDefault" length:10]]); readAttributeOctetStringNotDefaultValue = [NSMutableData dataWithData:actualValue]; } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertNotEqualObjects(actualValue, readAttributeOctetStringDefaultValue); + } + } [expectation fulfill]; }]; @@ -38731,6 +38833,12 @@ - (void)testSendClusterTestSaveAs_000106_ReadAttribute id actualValue = value; XCTAssertEqualObjects(actualValue, readAttributeOctetStringNotDefaultValue); } + { + id actualValue = value; + if (actualValue != nil) { + XCTAssertNotEqualObjects(actualValue, readAttributeOctetStringDefaultValue); + } + } [expectation fulfill]; }]; diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index f0c9d3765f78f3..bff0c88cffa561 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -16065,7 +16065,7 @@ class Test_TC_DM_2_2 : public TestCommand VerifyOrReturn(CheckValueAsString("fabricsList[0].label", iter_0.GetValue().label, chip::CharSpan("", 0))); VerifyOrReturn(CheckNoMoreListItems("fabricsList", iter_0, 1)); } - + VerifyOrReturn(CheckConstraintType("fabricsList", "", "list")); NextTest(); } @@ -16086,7 +16086,7 @@ class Test_TC_DM_2_2 : public TestCommand void OnSuccessResponse_2(uint8_t supportedFabrics) { VerifyOrReturn(CheckValue("supportedFabrics", supportedFabrics, 16)); - + VerifyOrReturn(CheckConstraintType("supportedFabrics", "", "uint8")); NextTest(); } @@ -16107,7 +16107,7 @@ class Test_TC_DM_2_2 : public TestCommand void OnSuccessResponse_3(uint8_t commissionedFabrics) { VerifyOrReturn(CheckValue("commissionedFabrics", commissionedFabrics, 1)); - + VerifyOrReturn(CheckConstraintType("commissionedFabrics", "", "uint8")); NextTest(); } @@ -17893,7 +17893,7 @@ class Test_TC_LVL_2_1 : public TestCommand void OnSuccessResponse_3(uint8_t currentLevel) { VerifyOrReturn(CheckValue("currentLevel", currentLevel, 254)); - + VerifyOrReturn(CheckConstraintType("currentLevel", "", "uint8")); NextTest(); } @@ -17913,7 +17913,7 @@ class Test_TC_LVL_2_1 : public TestCommand void OnSuccessResponse_4(uint16_t remainingTime) { VerifyOrReturn(CheckValue("remainingTime", remainingTime, 0U)); - + VerifyOrReturn(CheckConstraintType("remainingTime", "", "uint16")); NextTest(); } @@ -17933,7 +17933,7 @@ class Test_TC_LVL_2_1 : public TestCommand void OnSuccessResponse_5(uint8_t minLevel) { VerifyOrReturn(CheckValue("minLevel", minLevel, 0)); - + VerifyOrReturn(CheckConstraintType("minLevel", "", "uint8")); NextTest(); } @@ -17972,7 +17972,7 @@ class Test_TC_LVL_2_1 : public TestCommand void OnSuccessResponse_7(uint16_t currentFrequency) { VerifyOrReturn(CheckValue("currentFrequency", currentFrequency, 0U)); - + VerifyOrReturn(CheckConstraintType("currentFrequency", "", "uint16")); NextTest(); } @@ -17992,7 +17992,7 @@ class Test_TC_LVL_2_1 : public TestCommand void OnSuccessResponse_8(uint16_t minFrequency) { VerifyOrReturn(CheckValue("minFrequency", minFrequency, 0U)); - + VerifyOrReturn(CheckConstraintType("minFrequency", "", "uint16")); NextTest(); } @@ -18012,7 +18012,7 @@ class Test_TC_LVL_2_1 : public TestCommand void OnSuccessResponse_9(uint16_t maxFrequency) { VerifyOrReturn(CheckValue("maxFrequency", maxFrequency, 0U)); - + VerifyOrReturn(CheckConstraintType("maxFrequency", "", "uint16")); NextTest(); } @@ -18032,7 +18032,7 @@ class Test_TC_LVL_2_1 : public TestCommand void OnSuccessResponse_10(uint16_t onOffTransitionTime) { VerifyOrReturn(CheckValue("onOffTransitionTime", onOffTransitionTime, 0U)); - + VerifyOrReturn(CheckConstraintType("onOffTransitionTime", "", "uint16")); NextTest(); } @@ -18128,7 +18128,7 @@ class Test_TC_LVL_2_1 : public TestCommand void OnSuccessResponse_15(uint8_t options) { VerifyOrReturn(CheckValue("options", options, 0)); - + VerifyOrReturn(CheckConstraintType("options", "", "map8")); NextTest(); } }; @@ -18404,7 +18404,7 @@ class Test_TC_LVL_2_2 : public TestCommand void OnSuccessResponse_1(uint16_t onOffTransitionTime) { VerifyOrReturn(CheckValue("onOffTransitionTime", onOffTransitionTime, 0U)); - + VerifyOrReturn(CheckConstraintType("onOffTransitionTime", "", "uint16")); NextTest(); } @@ -18442,7 +18442,7 @@ class Test_TC_LVL_2_2 : public TestCommand void OnSuccessResponse_3(uint16_t onOffTransitionTime) { VerifyOrReturn(CheckValue("onOffTransitionTime", onOffTransitionTime, 10U)); - + VerifyOrReturn(CheckConstraintType("onOffTransitionTime", "", "uint16")); NextTest(); } @@ -18500,7 +18500,7 @@ class Test_TC_LVL_2_2 : public TestCommand { VerifyOrReturn(CheckValueNonNull("onLevel", onLevel)); VerifyOrReturn(CheckValue("onLevel.Value()", onLevel.Value(), 254)); - + VerifyOrReturn(CheckConstraintType("onLevel", "", "uint8")); NextTest(); } @@ -18540,7 +18540,7 @@ class Test_TC_LVL_2_2 : public TestCommand { VerifyOrReturn(CheckValueNonNull("onTransitionTime", onTransitionTime)); VerifyOrReturn(CheckValue("onTransitionTime.Value()", onTransitionTime.Value(), 100U)); - + VerifyOrReturn(CheckConstraintType("onTransitionTime", "", "uint16")); NextTest(); } @@ -18580,7 +18580,7 @@ class Test_TC_LVL_2_2 : public TestCommand { VerifyOrReturn(CheckValueNonNull("offTransitionTime", offTransitionTime)); VerifyOrReturn(CheckValue("offTransitionTime.Value()", offTransitionTime.Value(), 100U)); - + VerifyOrReturn(CheckConstraintType("offTransitionTime", "", "uint16")); NextTest(); } @@ -18601,7 +18601,7 @@ class Test_TC_LVL_2_2 : public TestCommand { VerifyOrReturn(CheckValueNonNull("defaultMoveRate", defaultMoveRate)); VerifyOrReturn(CheckValue("defaultMoveRate.Value()", defaultMoveRate.Value(), 0)); - + VerifyOrReturn(CheckConstraintType("defaultMoveRate", "", "uint8")); NextTest(); } @@ -18641,7 +18641,7 @@ class Test_TC_LVL_2_2 : public TestCommand { VerifyOrReturn(CheckValueNonNull("defaultMoveRate", defaultMoveRate)); VerifyOrReturn(CheckValue("defaultMoveRate.Value()", defaultMoveRate.Value(), 100)); - + VerifyOrReturn(CheckConstraintType("defaultMoveRate", "", "uint8")); NextTest(); } @@ -18681,7 +18681,7 @@ class Test_TC_LVL_2_2 : public TestCommand { VerifyOrReturn(CheckValueNonNull("startUpCurrentLevel", startUpCurrentLevel)); VerifyOrReturn(CheckValue("startUpCurrentLevel.Value()", startUpCurrentLevel.Value(), 254)); - + VerifyOrReturn(CheckConstraintType("startUpCurrentLevel", "", "uint8")); NextTest(); } }; @@ -22717,7 +22717,7 @@ class Test_TC_MC_9_1 : public TestCommand void OnSuccessResponse_3(uint16_t vendorId) { VerifyOrReturn(CheckValue("vendorId", vendorId, 0U)); - + VerifyOrReturn(CheckConstraintType("vendorId", "", "vendor-id")); NextTest(); } @@ -33957,7 +33957,9 @@ class Test_TC_TSTAT_2_2 : public TestCommand void OnSuccessResponse_1(int16_t occupiedCoolingSetpoint) { VerifyOrReturn(CheckValue("occupiedCoolingSetpoint", occupiedCoolingSetpoint, 2600)); - + VerifyOrReturn(CheckConstraintType("occupiedCoolingSetpoint", "", "int16")); + VerifyOrReturn(CheckConstraintMinValue("occupiedCoolingSetpoint", occupiedCoolingSetpoint, 1600)); + VerifyOrReturn(CheckConstraintMaxValue("occupiedCoolingSetpoint", occupiedCoolingSetpoint, 2600)); NextTest(); } @@ -34051,7 +34053,9 @@ class Test_TC_TSTAT_2_2 : public TestCommand void OnSuccessResponse_6(int16_t occupiedHeatingSetpoint) { VerifyOrReturn(CheckValue("occupiedHeatingSetpoint", occupiedHeatingSetpoint, 2000)); - + VerifyOrReturn(CheckConstraintType("occupiedHeatingSetpoint", "", "int16")); + VerifyOrReturn(CheckConstraintMinValue("occupiedHeatingSetpoint", occupiedHeatingSetpoint, 700)); + VerifyOrReturn(CheckConstraintMaxValue("occupiedHeatingSetpoint", occupiedHeatingSetpoint, 3000)); NextTest(); } @@ -34145,7 +34149,9 @@ class Test_TC_TSTAT_2_2 : public TestCommand void OnSuccessResponse_11(int16_t minHeatSetpointLimit) { VerifyOrReturn(CheckValue("minHeatSetpointLimit", minHeatSetpointLimit, 700)); - + VerifyOrReturn(CheckConstraintType("minHeatSetpointLimit", "", "int16")); + VerifyOrReturn(CheckConstraintMinValue("minHeatSetpointLimit", minHeatSetpointLimit, 700)); + VerifyOrReturn(CheckConstraintMaxValue("minHeatSetpointLimit", minHeatSetpointLimit, 3000)); NextTest(); } @@ -34239,7 +34245,9 @@ class Test_TC_TSTAT_2_2 : public TestCommand void OnSuccessResponse_16(int16_t maxHeatSetpointLimit) { VerifyOrReturn(CheckValue("maxHeatSetpointLimit", maxHeatSetpointLimit, 3000)); - + VerifyOrReturn(CheckConstraintType("maxHeatSetpointLimit", "", "int16")); + VerifyOrReturn(CheckConstraintMinValue("maxHeatSetpointLimit", maxHeatSetpointLimit, 700)); + VerifyOrReturn(CheckConstraintMaxValue("maxHeatSetpointLimit", maxHeatSetpointLimit, 3000)); NextTest(); } @@ -34333,7 +34341,9 @@ class Test_TC_TSTAT_2_2 : public TestCommand void OnSuccessResponse_21(int16_t minCoolSetpointLimit) { VerifyOrReturn(CheckValue("minCoolSetpointLimit", minCoolSetpointLimit, 1600)); - + VerifyOrReturn(CheckConstraintType("minCoolSetpointLimit", "", "int16")); + VerifyOrReturn(CheckConstraintMinValue("minCoolSetpointLimit", minCoolSetpointLimit, 1600)); + VerifyOrReturn(CheckConstraintMaxValue("minCoolSetpointLimit", minCoolSetpointLimit, 3200)); NextTest(); } @@ -34427,7 +34437,9 @@ class Test_TC_TSTAT_2_2 : public TestCommand void OnSuccessResponse_26(int16_t maxCoolSetpointLimit) { VerifyOrReturn(CheckValue("maxCoolSetpointLimit", maxCoolSetpointLimit, 3200)); - + VerifyOrReturn(CheckConstraintType("maxCoolSetpointLimit", "", "int16")); + VerifyOrReturn(CheckConstraintMinValue("maxCoolSetpointLimit", maxCoolSetpointLimit, 1600)); + VerifyOrReturn(CheckConstraintMaxValue("maxCoolSetpointLimit", maxCoolSetpointLimit, 3200)); NextTest(); } @@ -34666,7 +34678,9 @@ class Test_TC_TSTAT_2_2 : public TestCommand void OnSuccessResponse_39(uint8_t controlSequenceOfOperation) { VerifyOrReturn(CheckValue("controlSequenceOfOperation", controlSequenceOfOperation, 4)); - + VerifyOrReturn(CheckConstraintType("controlSequenceOfOperation", "", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("controlSequenceOfOperation", controlSequenceOfOperation, 0)); + VerifyOrReturn(CheckConstraintMaxValue("controlSequenceOfOperation", controlSequenceOfOperation, 5)); NextTest(); } @@ -63300,6 +63314,7 @@ class TestSaveAs : public TestCommand void OnSuccessResponse_97(chip::CharSpan charString) { VerifyOrReturn(CheckValueAsString("charString", charString, chip::CharSpan("NotDefault", 10))); + VerifyOrReturn(CheckConstraintNotValue("charString", charString, readAttributeCharStringDefaultValue)); if (readAttributeCharStringNotDefaultValueBuffer != nullptr) { @@ -63327,6 +63342,7 @@ class TestSaveAs : public TestCommand void OnSuccessResponse_98(chip::CharSpan charString) { VerifyOrReturn(CheckValueAsString("charString", charString, readAttributeCharStringNotDefaultValue)); + VerifyOrReturn(CheckConstraintNotValue("charString", charString, readAttributeCharStringDefaultValue)); NextTest(); } @@ -63469,6 +63485,7 @@ class TestSaveAs : public TestCommand { VerifyOrReturn( CheckValueAsString("octetString", octetString, chip::ByteSpan(chip::Uint8::from_const_char("NotDefault"), 10))); + VerifyOrReturn(CheckConstraintNotValue("octetString", octetString, readAttributeOctetStringDefaultValue)); if (readAttributeOctetStringNotDefaultValueBuffer != nullptr) { @@ -63496,6 +63513,7 @@ class TestSaveAs : public TestCommand void OnSuccessResponse_106(chip::ByteSpan octetString) { VerifyOrReturn(CheckValueAsString("octetString", octetString, readAttributeOctetStringNotDefaultValue)); + VerifyOrReturn(CheckConstraintNotValue("octetString", octetString, readAttributeOctetStringDefaultValue)); NextTest(); }