Skip to content

Commit

Permalink
Stop including af-enums.h in Darwin unit tests. (#32044)
Browse files Browse the repository at this point in the history
These are Objective-C files, and should not be including potentially-C++
headers.

A bunch of "test that the code is 0" checks were replaced with "error is nil"
checks (and some were removed, if "error is nil" was already being tested).

The macro definition reformatting in MTRBackwardsCompatTests.m is just from
updates to our clang-format version, looks like.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Feb 22, 2024
1 parent 6172415 commit 1151844
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 124 deletions.
40 changes: 19 additions & 21 deletions src/darwin/Framework/CHIPTests/MTRBackwardsCompatTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#import "MTRTestResetCommissioneeHelper.h"
#import "MTRTestStorage.h"

#import <app/util/af-enums.h>

#import <math.h> // For INFINITY

// system dependencies
Expand Down Expand Up @@ -203,34 +201,34 @@ - (void)test000_SetUp
// tests.
}

#define CHECK_RETURN_TYPE(sig, type) \
do { \
XCTAssertNotNil(sig); \
XCTAssertTrue(strcmp([sig methodReturnType], @encode(type)) == 0); \
#define CHECK_RETURN_TYPE(sig, type) \
do { \
XCTAssertNotNil(sig); \
XCTAssertTrue(strcmp([sig methodReturnType], @encode(type)) == 0); \
} while (0)

/**
* Arguments 0 and 1 are the implicit self and _cmd arguments; the real arguments begin at index 2.
*/
#define CHECK_ARGUMENT(sig, index, type) \
do { \
XCTAssertTrue(strcmp([sig getArgumentTypeAtIndex:(index) + 2], @encode(type)) == 0); \
#define CHECK_ARGUMENT(sig, index, type) \
do { \
XCTAssertTrue(strcmp([sig getArgumentTypeAtIndex:(index) + 2], @encode(type)) == 0); \
} while (0)

#define CHECK_READONLY_PROPERTY(instance, propName, type) \
do { \
NSMethodSignature * signature = [instance methodSignatureForSelector:@selector(propName)]; \
CHECK_RETURN_TYPE(signature, type); \
/* Check that getting the property directly compiles too */ \
(void) instance.propName; \
#define CHECK_READONLY_PROPERTY(instance, propName, type) \
do { \
NSMethodSignature * signature = [instance methodSignatureForSelector:@selector(propName)]; \
CHECK_RETURN_TYPE(signature, type); \
/* Check that getting the property directly compiles too */ \
(void) instance.propName; \
} while (0)

#define CHECK_PROPERTY(instance, propName, setterName, type) \
do { \
CHECK_READONLY_PROPERTY(instance, propName, type); \
NSMethodSignature * signature = [instance methodSignatureForSelector:@selector(setterName:)]; \
CHECK_RETURN_TYPE(signature, void); \
CHECK_ARGUMENT(signature, 0, type); \
#define CHECK_PROPERTY(instance, propName, setterName, type) \
do { \
CHECK_READONLY_PROPERTY(instance, propName, type); \
NSMethodSignature * signature = [instance methodSignatureForSelector:@selector(setterName:)]; \
CHECK_RETURN_TYPE(signature, void); \
CHECK_ARGUMENT(signature, 0, type); \
} while (0)

/**
Expand Down
Loading

0 comments on commit 1151844

Please sign in to comment.