NSDictionary Tests
lfarah opened this issue · 6 comments
lfarah commented
We have a problem on NSDictionaryExtensions.swift
test coverage.
NSDictionaryExtensionTests
class NSDictionaryTests: XCTestCase {
func testDicToJSON() {
let dic: NSDictionary = ["foo":"bar"]
let json = dic.formatJSON()
let str = "{\"foo\":\"bar\"}"
XCTAssertEqual(json, str)
}
func testJSONtoDic() {
let str = "{\"foo\":\"bar\"}"
let dic = NSDictionary(json: str)
let dicExpected: NSDictionary = ["foo":"bar"]
XCTAssertEqual(dic, dicExpected)
}
}
Coverage
piv199 commented
Hm, what it could be?
lfarah commented
@piv199 I'm thinking about it now... Should we have NSDictionaryExtensions at all? Ray Wenderlich's Style Guide says this:
Types
Always use Swift's native types when available. Swift offers bridging to Objective-C so you can still use the full set of methods as needed.
Preferred:
let width = 120.0 // Double
let widthString = (width as NSNumber).stringValue // String
Not Preferred:
let width: NSNumber = 120.0 // NSNumber
let widthString: NSString = width.stringValue // NSString
lfarah commented
Esqarrouth commented
Whats the problem, I don't get it?
Changing this to standard Dictionary would work the same right? If it does no problem in changing it
piv199 commented
@lfarah I agree with @goktugyil, change everything to Dictionary 👍