GIDGoogleUser+Testing.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2021 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import "GoogleSignIn/Tests/Unit/GIDGoogleUser+Testing.h"
  15. #import "GoogleSignIn/Tests/Unit/GIDAuthentication+Testing.h"
  16. #import "GoogleSignIn/Tests/Unit/GIDProfileData+Testing.h"
  17. @implementation GIDGoogleUser (Testing)
  18. - (BOOL)isEqual:(id)object {
  19. if (self == object) {
  20. return YES;
  21. }
  22. if (![object isKindOfClass:[GIDGoogleUser class]]) {
  23. return NO;
  24. }
  25. return [self isEqualToGoogleUser:(GIDGoogleUser *)object];
  26. }
  27. - (BOOL)isEqualToGoogleUser:(GIDGoogleUser *)other {
  28. return [self.authentication isEqual:other.authentication] &&
  29. [self.userID isEqual:other.userID] &&
  30. [self.serverAuthCode isEqual:other.serverAuthCode] &&
  31. [self.profile isEqual:other.profile] &&
  32. [self.hostedDomain isEqual:other.hostedDomain];
  33. }
  34. // Not the hash implemention you want to use on prod, but just to match |isEqual:| here.
  35. - (NSUInteger)hash {
  36. return [self.authentication hash] ^ [self.userID hash] ^ [self.serverAuthCode hash] ^
  37. [self.profile hash] ^ [self.hostedDomain hash];
  38. }
  39. @end