Swift collections in unit tests -
Swift collections in unit tests -
i new swift , don't understand implicit type casting, have in unit test:
let protocols: anyobject? = nsbundle.mainbundle().infodictionary?["uisupportedexternalaccessoryprotocols"];
i need test protocols
exists, array , contains "foo" , "bar".
i came solution:
let protocols: anyobject? = nsbundle.mainbundle().infodictionary?["uisupportedexternalaccessoryprotocols"]; if allow p = protocols as? [string] { xctasserttrue(contains(p, "foo")); xctasserttrue(contains(p, "bar")); } else { xctfail("uisupportedexternalaccessoryprotocols must array"); }
is there improve way handle it?
unit-testing swift
Comments
Post a Comment