GIDGoogleUser+Testing.m 1.9 KB

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