Skip to content

Commit

Permalink
Country bug fix relating to additional keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomHashTags committed Nov 4, 2022
1 parent 001bab4 commit 2c89f5b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Sources/SwiftSovereignStates/Country.swift
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,11 @@ public enum Country : String, CaseIterable, SovereignState {
}

public func getAdditionalKeywords() -> [String]? {
var keywords:[String] = [String]()
var keywords:[String] = getSovereignStateAdditionalKeywords() ?? [String]()
if let parentISOAlpha2:String = getISOAlpha2ParentGroup() {
keywords.append(parentISOAlpha2)
}
return keywords
return keywords.isEmpty ? nil : keywords
}

public func getWikipediaURL() -> String {
Expand Down
7 changes: 5 additions & 2 deletions Sources/SwiftSovereignStates/SovereignState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ public protocol SovereignState : SovereignRegion {
func getISOAlpha3() -> String?
}
public extension SovereignState {
func getAdditionalKeywords() -> [String]? {
func getSovereignStateAdditionalKeywords() -> [String]? {
var keywords:[String] = [String]()
if let isoAlpha2:String = getISOAlpha2() {
keywords.append(isoAlpha2)
}
if let isoAlpha3:String = getISOAlpha3() {
keywords.append(isoAlpha3)
}
return keywords
return keywords.isEmpty ? nil : keywords
}
func getAdditionalKeywords() -> [String]? {
return getSovereignStateAdditionalKeywords()
}
}
2 changes: 2 additions & 0 deletions Tests/SwiftSovereignStatesTests/SwiftSovereignStates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ final class SwiftSovereignStatesTests: XCTestCase {
print("SwiftSovereignStatesTests;testCountryMentions;shouldn't be=[" + notMentioned.map({ $0.getIdentifier() }).joined(separator: ",") + "]")
}
XCTAssert(mentioned.count == targetCountries.count)

XCTAssert(Country.valueOf("USA") != nil)
}
private func testSubdivisionMentions() {
let targetSubdivisions:[any SovereignStateSubdivision] = [SubdivisionsMexico.baja_california, SubdivisionsUnitedStates.california]
Expand Down

0 comments on commit 2c89f5b

Please sign in to comment.