Digital PCT265 story PCT-135: Switch to shallow equals with deep compare on parent in order to pinpoint midmatched models. Unit testing setup.

This commit is contained in:
Hedden, Kyle Matthew 2024-05-17 21:24:18 -04:00
parent 009bb01e1b
commit 71689b957b
2 changed files with 14 additions and 2 deletions

View File

@ -52,7 +52,7 @@ extension ModelProtocol {
} }
public protocol ModelComparisonProtocol { public protocol ModelComparisonProtocol {
/// Deep checks if the curent model is equal to another model. Defaults to false unless implemented otherwise. /// Shallow checks if the curent model is equal to another model. Defaults to false unless implemented otherwise.
func isEqual(to model: ModelComparisonProtocol) -> Bool func isEqual(to model: ModelComparisonProtocol) -> Bool
} }
@ -97,3 +97,15 @@ public extension Optional where Wrapped: Collection {
return self.isEqual(to: models) return self.isEqual(to: models)
} }
} }
public extension Optional {
/// Checks if
func matchExistence(with anotherOptional: Optional) -> Bool {
switch(self) {
case .none:
return anotherOptional == nil
case .some(_):
return anotherOptional != nil
}
}
}

View File

@ -105,7 +105,7 @@ public struct ModelRegistry {
MVMCoreLoggingHandler.shared()?.addError(toLog: errorObject) MVMCoreLoggingHandler.shared()?.addError(toLog: errorObject)
#if DEBUG #if DEBUG
triggerCrashInDebug() //triggerCrashInDebug()
#endif #endif
} }