Skip to content

Commit 776a0f0

Browse files
bzbarsky-applew8floosh
authored and
w8floosh
committed
Add tests for MTR*NameForID APIs. (project-chip#34687)
1 parent 56640c9 commit 776a0f0

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Copyright (c) 2024 Project CHIP Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <Matter/Matter.h>
18+
#import <XCTest/XCTest.h>
19+
20+
@interface MTRClusterNamesTests : XCTestCase
21+
22+
@end
23+
24+
@implementation MTRClusterNamesTests
25+
26+
- (void)testClusterNames
27+
{
28+
XCTAssertEqualObjects(MTRClusterNameForID(MTRClusterIDTypeOnOffID), @"OnOff");
29+
XCTAssertEqualObjects(MTRClusterNameForID(0x0101), @"DoorLock");
30+
XCTAssertEqualObjects(MTRClusterNameForID(12345678), @"<Unknown clusterID 12345678>");
31+
}
32+
33+
- (void)testAttributeNames
34+
{
35+
XCTAssertEqualObjects(MTRAttributeNameForID(MTRClusterIDTypeOnOffID, MTRAttributeIDTypeClusterOnOffAttributeOnOffID), @"OnOff");
36+
XCTAssertEqualObjects(MTRAttributeNameForID(MTRClusterIDTypeOnOffID, MTRAttributeIDTypeClusterOnOffAttributeOnTimeID), @"OnTime");
37+
XCTAssertEqualObjects(MTRAttributeNameForID(12345678, 0), @"<Unknown clusterID 12345678>");
38+
XCTAssertEqualObjects(MTRAttributeNameForID(MTRClusterIDTypeOnOffID, 12345678), @"<Unknown attributeID 12345678>");
39+
}
40+
41+
- (void)testEventNames
42+
{
43+
XCTAssertEqualObjects(MTREventNameForID(MTRClusterIDTypeAccessControlID, MTREventIDTypeClusterAccessControlEventAccessControlEntryChangedID), @"AccessControlEntryChanged");
44+
XCTAssertEqualObjects(MTREventNameForID(12345678, 0), @"<Unknown clusterID 12345678>");
45+
XCTAssertEqualObjects(MTREventNameForID(MTRClusterIDTypeAccessControlID, 12345678), @"<Unknown eventID 12345678>");
46+
}
47+
48+
@end

src/darwin/Framework/Matter.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@
182182
516415FD2B6ACA8300D5CE11 /* MTRServerAccessControl.h in Headers */ = {isa = PBXBuildFile; fileRef = 516415FB2B6ACA8300D5CE11 /* MTRServerAccessControl.h */; };
183183
516415FF2B6B132200D5CE11 /* DataModelHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 516415FE2B6B132200D5CE11 /* DataModelHandler.cpp */; };
184184
516416012B6B483C00D5CE11 /* MTRIMDispatch.mm in Sources */ = {isa = PBXBuildFile; fileRef = 516416002B6B483C00D5CE11 /* MTRIMDispatch.mm */; };
185+
5165A4B32C5AB978002B9799 /* MTRClusterNamesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5165A4B22C5AB978002B9799 /* MTRClusterNamesTests.m */; };
185186
51669AF02913204400F4AA36 /* MTRBackwardsCompatTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 51669AEF2913204400F4AA36 /* MTRBackwardsCompatTests.m */; };
186187
5173A47529C0E2ED00F67F48 /* MTRFabricInfo_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 5173A47229C0E2ED00F67F48 /* MTRFabricInfo_Internal.h */; };
187188
5173A47629C0E2ED00F67F48 /* MTRFabricInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5173A47329C0E2ED00F67F48 /* MTRFabricInfo.mm */; };
@@ -596,6 +597,7 @@
596597
516415FB2B6ACA8300D5CE11 /* MTRServerAccessControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRServerAccessControl.h; sourceTree = "<group>"; };
597598
516415FE2B6B132200D5CE11 /* DataModelHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DataModelHandler.cpp; path = util/DataModelHandler.cpp; sourceTree = "<group>"; };
598599
516416002B6B483C00D5CE11 /* MTRIMDispatch.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRIMDispatch.mm; sourceTree = "<group>"; };
600+
5165A4B22C5AB978002B9799 /* MTRClusterNamesTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTRClusterNamesTests.m; sourceTree = "<group>"; };
599601
51669AEF2913204400F4AA36 /* MTRBackwardsCompatTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTRBackwardsCompatTests.m; sourceTree = "<group>"; };
600602
5173A47229C0E2ED00F67F48 /* MTRFabricInfo_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRFabricInfo_Internal.h; sourceTree = "<group>"; };
601603
5173A47329C0E2ED00F67F48 /* MTRFabricInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRFabricInfo.mm; sourceTree = "<group>"; };
@@ -1407,6 +1409,7 @@
14071409
3DFCB3282966684500332B35 /* MTRCertificateInfoTests.m */,
14081410
517BF3F2282B62CB00A8B7DB /* MTRCertificateTests.m */,
14091411
51339B1E2A0DA64D00C798C1 /* MTRCertificateValidityTests.m */,
1412+
5165A4B22C5AB978002B9799 /* MTRClusterNamesTests.m */,
14101413
1EE0805C2A448756008A03C2 /* MTRCommissionableBrowserTests.m */,
14111414
518D3F842AA14006008E0007 /* MTRControllerAdvertisingTests.m */,
14121415
99C65E0F267282F1003402F6 /* MTRControllerTests.m */,
@@ -2050,6 +2053,7 @@
20502053
51E24E73274E0DAC007CCF6E /* MTRErrorTestUtils.mm in Sources */,
20512054
519498322A25581C00B3BABE /* MTRSetupPayloadInitializationTests.m in Sources */,
20522055
51A2F1322A00402A00F03298 /* MTRDataValueParserTests.m in Sources */,
2056+
5165A4B32C5AB978002B9799 /* MTRClusterNamesTests.m in Sources */,
20532057
51E95DF82A78110900A434F0 /* MTRPerControllerStorageTests.m in Sources */,
20542058
51D9CB0B2BA37DCE0049D6DB /* MTRDSTOffsetTests.m in Sources */,
20552059
);

0 commit comments

Comments
 (0)