GIDGoogleUser+Testing.m 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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/Sources/Public/GoogleSignIn/GIDConfiguration.h"
  16. #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDToken.h"
  17. #import "GoogleSignIn/Tests/Unit/GIDConfiguration+Testing.h"
  18. #import "GoogleSignIn/Tests/Unit/GIDProfileData+Testing.h"
  19. @implementation GIDGoogleUser (Testing)
  20. - (BOOL)isEqual:(id)object {
  21. if (self == object) {
  22. return YES;
  23. }
  24. if (![object isKindOfClass:[GIDGoogleUser class]]) {
  25. return NO;
  26. }
  27. return [self isEqualToGoogleUser:(GIDGoogleUser *)object];
  28. }
  29. - (BOOL)isEqualToGoogleUser:(GIDGoogleUser *)other {
  30. return [self.userID isEqual:other.userID] &&
  31. [self.profile isEqual:other.profile] &&
  32. [self.configuration isEqual:other.configuration] &&
  33. [self.idToken isEqual:other.idToken] &&
  34. [self.refreshToken isEqual:other.refreshToken] &&
  35. [self.accessToken isEqual:other.accessToken];
  36. }
  37. // Not the hash implemention you want to use on prod, but just to match |isEqual:| here.
  38. - (NSUInteger)hash {
  39. return [self.userID hash] ^ [self.configuration hash] ^
  40. [self.profile hash] ^ [self.idToken hash] ^ [self.refreshToken hash] ^
  41. [self.accessToken hash];
  42. }
  43. @end