GIDGoogleUser+Testing.m 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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/Tests/Unit/GIDAuthentication+Testing.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.authentication isEqual:other.authentication] &&
  31. [self.userID isEqual:other.userID] &&
  32. [self.profile isEqual:other.profile] &&
  33. [self.configuration isEqual:other.configuration];
  34. }
  35. // Not the hash implemention you want to use on prod, but just to match |isEqual:| here.
  36. - (NSUInteger)hash {
  37. return [self.authentication hash] ^ [self.userID hash] ^ [self.configuration hash] ^
  38. [self.profile hash] ;
  39. }
  40. @end