Mhurd has submitted this change and it was merged.
Change subject: Fix for multiple history entries bug
......................................................................
Fix for multiple history entries bug
Needed to implement 'hash' method on site/title objects to let them
be used correctly as dictionary keys, otherwise when getting objects
of different provenance we sometimes failed to account for matching
entries.
Change-Id: I5192f83530ac3ef3b2fa240ee38ef2ced78a3745
---
M MediaWikiKit/MediaWikiKit/MWKSite.m
M MediaWikiKit/MediaWikiKit/MWKTitle.m
M MediaWikiKit/MediaWikiKitTests/MWKHistoryListTests.m
3 files changed, 20 insertions(+), 0 deletions(-)
Approvals:
Mhurd: Verified; Looks good to me, approved
diff --git a/MediaWikiKit/MediaWikiKit/MWKSite.m
b/MediaWikiKit/MediaWikiKit/MWKSite.m
index 826abb9..069b589 100644
--- a/MediaWikiKit/MediaWikiKit/MWKSite.m
+++ b/MediaWikiKit/MediaWikiKit/MWKSite.m
@@ -67,4 +67,9 @@
return site;
}
+- (NSUInteger)hash
+{
+ return [self.domain hash] ^ [self.language hash];
+}
+
@end
diff --git a/MediaWikiKit/MediaWikiKit/MWKTitle.m
b/MediaWikiKit/MediaWikiKit/MWKTitle.m
index b4ef7eb..4956917 100644
--- a/MediaWikiKit/MediaWikiKit/MWKTitle.m
+++ b/MediaWikiKit/MediaWikiKit/MWKTitle.m
@@ -125,4 +125,9 @@
return self;
}
+- (NSUInteger)hash
+{
+ return [self.site hash] ^ [self.prefixedText hash] ^ [self.fragment hash];
+}
+
@end
diff --git a/MediaWikiKit/MediaWikiKitTests/MWKHistoryListTests.m
b/MediaWikiKit/MediaWikiKitTests/MWKHistoryListTests.m
index 20dc756..ee56683 100644
--- a/MediaWikiKit/MediaWikiKitTests/MWKHistoryListTests.m
+++ b/MediaWikiKit/MediaWikiKitTests/MWKHistoryListTests.m
@@ -65,6 +65,16 @@
XCTAssertEqual(historyList.length, 1, @"Should have length 1 after adding
a duplicate, not 2");
}
+- (void)testAddCount2SameButDiffObjects {
+ MWKTitle *title1 = [titleSFEn.site titleWithString:@"This is a title"];
+ MWKTitle *title2 = [titleSFEn.site titleWithString:@"This is a title"];
+ [historyList addEntry:[[MWKHistoryEntry alloc] initWithTitle:title1
+
discoveryMethod:MWK_DISCOVERY_METHOD_SEARCH]];
+ [historyList addEntry:[[MWKHistoryEntry alloc] initWithTitle:title2
+
discoveryMethod:MWK_DISCOVERY_METHOD_SEARCH]];
+ XCTAssertEqual(historyList.length, 1, @"Should have length 1 after adding
a duplicate, not 2");
+}
+
- (void)testAddCount2DiffLanguages {
[historyList addEntry:[[MWKHistoryEntry alloc] initWithTitle:titleSFEn
discoveryMethod:MWK_DISCOVERY_METHOD_SEARCH]];
--
To view, visit https://gerrit.wikimedia.org/r/178599
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5192f83530ac3ef3b2fa240ee38ef2ced78a3745
Gerrit-PatchSet: 1
Gerrit-Project: apps/ios/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Mhurd <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits