Skip to content

Commit

Permalink
Add tests for MTR*NameForID APIs. (project-chip#34687)
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple authored Aug 1, 2024
1 parent 923619a commit 6f84526
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/darwin/Framework/CHIPTests/MTRClusterNamesTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Copyright (c) 2024 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#import <Matter/Matter.h>
#import <XCTest/XCTest.h>

@interface MTRClusterNamesTests : XCTestCase

@end

@implementation MTRClusterNamesTests

- (void)testClusterNames
{
XCTAssertEqualObjects(MTRClusterNameForID(MTRClusterIDTypeOnOffID), @"OnOff");
XCTAssertEqualObjects(MTRClusterNameForID(0x0101), @"DoorLock");
XCTAssertEqualObjects(MTRClusterNameForID(12345678), @"<Unknown clusterID 12345678>");
}

- (void)testAttributeNames
{
XCTAssertEqualObjects(MTRAttributeNameForID(MTRClusterIDTypeOnOffID, MTRAttributeIDTypeClusterOnOffAttributeOnOffID), @"OnOff");
XCTAssertEqualObjects(MTRAttributeNameForID(MTRClusterIDTypeOnOffID, MTRAttributeIDTypeClusterOnOffAttributeOnTimeID), @"OnTime");
XCTAssertEqualObjects(MTRAttributeNameForID(12345678, 0), @"<Unknown clusterID 12345678>");
XCTAssertEqualObjects(MTRAttributeNameForID(MTRClusterIDTypeOnOffID, 12345678), @"<Unknown attributeID 12345678>");
}

- (void)testEventNames
{
XCTAssertEqualObjects(MTREventNameForID(MTRClusterIDTypeAccessControlID, MTREventIDTypeClusterAccessControlEventAccessControlEntryChangedID), @"AccessControlEntryChanged");
XCTAssertEqualObjects(MTREventNameForID(12345678, 0), @"<Unknown clusterID 12345678>");
XCTAssertEqualObjects(MTREventNameForID(MTRClusterIDTypeAccessControlID, 12345678), @"<Unknown eventID 12345678>");
}

@end
4 changes: 4 additions & 0 deletions src/darwin/Framework/Matter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
516415FD2B6ACA8300D5CE11 /* MTRServerAccessControl.h in Headers */ = {isa = PBXBuildFile; fileRef = 516415FB2B6ACA8300D5CE11 /* MTRServerAccessControl.h */; };
516415FF2B6B132200D5CE11 /* DataModelHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 516415FE2B6B132200D5CE11 /* DataModelHandler.cpp */; };
516416012B6B483C00D5CE11 /* MTRIMDispatch.mm in Sources */ = {isa = PBXBuildFile; fileRef = 516416002B6B483C00D5CE11 /* MTRIMDispatch.mm */; };
5165A4B32C5AB978002B9799 /* MTRClusterNamesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5165A4B22C5AB978002B9799 /* MTRClusterNamesTests.m */; };
51669AF02913204400F4AA36 /* MTRBackwardsCompatTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 51669AEF2913204400F4AA36 /* MTRBackwardsCompatTests.m */; };
5173A47529C0E2ED00F67F48 /* MTRFabricInfo_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 5173A47229C0E2ED00F67F48 /* MTRFabricInfo_Internal.h */; };
5173A47629C0E2ED00F67F48 /* MTRFabricInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5173A47329C0E2ED00F67F48 /* MTRFabricInfo.mm */; };
Expand Down Expand Up @@ -596,6 +597,7 @@
516415FB2B6ACA8300D5CE11 /* MTRServerAccessControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRServerAccessControl.h; sourceTree = "<group>"; };
516415FE2B6B132200D5CE11 /* DataModelHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DataModelHandler.cpp; path = util/DataModelHandler.cpp; sourceTree = "<group>"; };
516416002B6B483C00D5CE11 /* MTRIMDispatch.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRIMDispatch.mm; sourceTree = "<group>"; };
5165A4B22C5AB978002B9799 /* MTRClusterNamesTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTRClusterNamesTests.m; sourceTree = "<group>"; };
51669AEF2913204400F4AA36 /* MTRBackwardsCompatTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTRBackwardsCompatTests.m; sourceTree = "<group>"; };
5173A47229C0E2ED00F67F48 /* MTRFabricInfo_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRFabricInfo_Internal.h; sourceTree = "<group>"; };
5173A47329C0E2ED00F67F48 /* MTRFabricInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRFabricInfo.mm; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1407,6 +1409,7 @@
3DFCB3282966684500332B35 /* MTRCertificateInfoTests.m */,
517BF3F2282B62CB00A8B7DB /* MTRCertificateTests.m */,
51339B1E2A0DA64D00C798C1 /* MTRCertificateValidityTests.m */,
5165A4B22C5AB978002B9799 /* MTRClusterNamesTests.m */,
1EE0805C2A448756008A03C2 /* MTRCommissionableBrowserTests.m */,
518D3F842AA14006008E0007 /* MTRControllerAdvertisingTests.m */,
99C65E0F267282F1003402F6 /* MTRControllerTests.m */,
Expand Down Expand Up @@ -2050,6 +2053,7 @@
51E24E73274E0DAC007CCF6E /* MTRErrorTestUtils.mm in Sources */,
519498322A25581C00B3BABE /* MTRSetupPayloadInitializationTests.m in Sources */,
51A2F1322A00402A00F03298 /* MTRDataValueParserTests.m in Sources */,
5165A4B32C5AB978002B9799 /* MTRClusterNamesTests.m in Sources */,
51E95DF82A78110900A434F0 /* MTRPerControllerStorageTests.m in Sources */,
51D9CB0B2BA37DCE0049D6DB /* MTRDSTOffsetTests.m in Sources */,
);
Expand Down

0 comments on commit 6f84526

Please sign in to comment.