diff --git a/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h b/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h index 445758958fd169..b3d08ecf051774 100644 --- a/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h +++ b/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h @@ -396,25 +396,37 @@ class TestCommandBridge : public CHIPCommandBridge, using ConstraintsChecker::CheckConstraintMinLength; - bool CheckConstraintMinLength(const char * _Nonnull itemName, NSString * _Nonnull current, uint64_t expected) + bool CheckConstraintMinLength(const char * _Nonnull itemName, NSString * _Nullable current, uint64_t expected) { + if (current == nil) { + return true; + } return CheckConstraintMinLength(itemName, [current length], expected); } - bool CheckConstraintMinLength(const char * _Nonnull itemName, NSArray * _Nonnull current, uint64_t expected) + bool CheckConstraintMinLength(const char * _Nonnull itemName, NSArray * _Nullable current, uint64_t expected) { + if (current == nil) { + return true; + } return CheckConstraintMinLength(itemName, [current count], expected); } using ConstraintsChecker::CheckConstraintMaxLength; - bool CheckConstraintMaxLength(const char * _Nonnull itemName, NSString * _Nonnull current, uint64_t expected) + bool CheckConstraintMaxLength(const char * _Nonnull itemName, NSString * _Nullable current, uint64_t expected) { + if (current == nil) { + return true; + } return CheckConstraintMaxLength(itemName, [current length], expected); } - bool CheckConstraintMaxLength(const char * _Nonnull itemName, NSArray * _Nonnull current, uint64_t expected) + bool CheckConstraintMaxLength(const char * _Nonnull itemName, NSArray * _Nullable current, uint64_t expected) { + if (current == nil) { + return true; + } return CheckConstraintMaxLength(itemName, [current count], expected); } @@ -423,20 +435,29 @@ class TestCommandBridge : public CHIPCommandBridge, // Used when the minValue is a saved variable, since ConstraintsChecker does // not expect Core Foundation types. template ::value && std::is_signed::value, int> = 0> - bool CheckConstraintMinValue(const char * _Nonnull itemName, T current, const NSNumber * _Nonnull expected) + bool CheckConstraintMinValue(const char * _Nonnull itemName, T current, const NSNumber * _Nullable expected) { + if (expected == nil) { + return true; + } return ConstraintsChecker::CheckConstraintMinValue(itemName, current, [expected longLongValue]); } template ::value && !std::is_signed::value, int> = 0> - bool CheckConstraintMinValue(const char * _Nonnull itemName, T current, const NSNumber * _Nonnull expected) + bool CheckConstraintMinValue(const char * _Nonnull itemName, T current, const NSNumber * _Nullable expected) { + if (expected == nil) { + return true; + } return ConstraintsChecker::CheckConstraintMinValue(itemName, current, [expected unsignedLongLongValue]); } template ::value, int> = 0> - bool CheckConstraintMinValue(const char * _Nonnull itemName, T current, const NSNumber * _Nonnull expected) + bool CheckConstraintMinValue(const char * _Nonnull itemName, T current, const NSNumber * _Nullable expected) { + if (expected == nil) { + return true; + } return ConstraintsChecker::CheckConstraintMinValue(itemName, current, [expected doubleValue]); } @@ -445,20 +466,29 @@ class TestCommandBridge : public CHIPCommandBridge, // Used when the maxValue is a saved variable, since ConstraintsChecker does // not expect Core Foundation types. template ::value && std::is_signed::value, int> = 0> - bool CheckConstraintMaxValue(const char * _Nonnull itemName, T current, const NSNumber * _Nonnull expected) + bool CheckConstraintMaxValue(const char * _Nonnull itemName, T current, const NSNumber * _Nullable expected) { + if (expected == nil) { + return true; + } return ConstraintsChecker::CheckConstraintMaxValue(itemName, current, [expected longLongValue]); } template ::value && !std::is_signed::value, int> = 0> - bool CheckConstraintMaxValue(const char * _Nonnull itemName, T current, const NSNumber * _Nonnull expected) + bool CheckConstraintMaxValue(const char * _Nonnull itemName, T current, const NSNumber * _Nullable expected) { + if (expected == nil) { + return true; + } return ConstraintsChecker::CheckConstraintMaxValue(itemName, current, [expected unsignedLongLongValue]); } template ::value, int> = 0> - bool CheckConstraintMaxValue(const char * _Nonnull itemName, T current, const NSNumber * _Nonnull expected) + bool CheckConstraintMaxValue(const char * _Nonnull itemName, T current, const NSNumber * _Nullable expected) { + if (expected == nil) { + return true; + } return ConstraintsChecker::CheckConstraintMaxValue(itemName, current, [expected doubleValue]); }