Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utilize as NSString bridging on Linux as well #778

Merged
merged 1 commit into from
May 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Tests/NimbleTests/Matchers/BeEmptyTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class BeEmptyTest: XCTestCase {
expect(NSIndexSet(index: 1)).toNot(beEmpty())

expect(NSString()).to(beEmpty())
expect(NSString(string: "hello")).toNot(beEmpty())
expect("hello" as NSString).toNot(beEmpty())

expect("").to(beEmpty())
expect("foo").toNot(beEmpty())
Expand Down Expand Up @@ -89,6 +89,13 @@ final class BeEmptyTest: XCTestCase {
}

func testNilMatches() {
failsWithErrorMessageForNil("expected to be empty, got <nil>") {
expect(nil as String?).to(beEmpty())
}
failsWithErrorMessageForNil("expected to not be empty, got <nil>") {
expect(nil as String?).toNot(beEmpty())
}

failsWithErrorMessageForNil("expected to be empty, got <nil>") {
expect(nil as NSString?).to(beEmpty())
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/NimbleTests/Matchers/BeIdenticalToTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ final class BeIdenticalToTest: XCTestCase {
}

func testBeIdenticalToNegative() {
expect(NSNumber(value: 1)).toNot(beIdenticalTo(NSString(string: "yo")))
expect(NSNumber(value: 1)).toNot(beIdenticalTo("yo" as NSString))
expect(NSArray(array: [NSNumber(value: 1)])).toNot(beIdenticalTo(NSArray(array: [NSNumber(value: 1)])))
}

Expand Down Expand Up @@ -40,7 +40,7 @@ final class BeIdenticalToTest: XCTestCase {
func testBeAlias() {
let value = NSDate()
expect(value).to(be(value))
expect(NSNumber(value: 1)).toNot(be(NSString(string: "turtles")))
expect(NSNumber(value: 1)).toNot(be("turtles" as NSString))
#if canImport(Darwin)
expect([1]).toNot(be([1]))
#else
Expand Down
8 changes: 4 additions & 4 deletions Tests/NimbleTests/Matchers/BeginWithTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ final class BeginWithTest: XCTestCase {

expect("foobarfoo").to(beginWith("foo"))

expect(NSString(string: "foobar").description).to(beginWith("foo"))
expect(NSString(string: "foobar").description).toNot(beginWith("oo"))
expect(("foobar" as NSString).description).to(beginWith("foo"))
expect(("foobar" as NSString).description).toNot(beginWith("oo"))

expect(NSArray(array: ["a", "b"])).to(beginWith("a"))
expect(NSArray(array: ["a", "b"])).toNot(beginWith("b"))
}

func testNegativeMatches() {
failsWithErrorMessageForNil("expected to begin with <b>, got <nil>") {
expect(nil as NSArray?).to(beginWith(NSString(string: "b")))
expect(nil as NSArray?).to(beginWith("b" as NSString))
}
failsWithErrorMessageForNil("expected to not begin with <b>, got <nil>") {
expect(nil as NSArray?).toNot(beginWith(NSString(string: "b")))
expect(nil as NSArray?).toNot(beginWith("b" as NSString))
}

failsWithErrorMessage("expected to begin with <2>, got <[1, 2, 3]>") {
Expand Down
16 changes: 8 additions & 8 deletions Tests/NimbleTests/Matchers/ContainTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ final class ContainTest: XCTestCase {
expect(["foo", "bar", "baz"]).to(contain("baz"))
expect(["foo", "bar", "baz"]).toNot(contain("ba"))
#if canImport(Darwin)
expect(NSArray(array: ["a"])).to(contain(NSString(string: "a")))
expect(NSArray(array: ["a"])).toNot(contain(NSString(string: "b")))
expect(NSArray(array: ["a"])).to(contain("a" as NSString))
expect(NSArray(array: ["a"])).toNot(contain("b" as NSString))
expect(NSArray(object: 1) as NSArray?).to(contain(1))
#endif

Expand Down Expand Up @@ -85,12 +85,12 @@ final class ContainTest: XCTestCase {
}
}

func testContainObjCSubstring() {
let str = NSString(string: "foo")
expect(str).to(contain(NSString(string: "o")))
expect(str).to(contain(NSString(string: "oo")))
expect(str).toNot(contain(NSString(string: "z")))
expect(str).toNot(contain(NSString(string: "zz")))
func testContainNSStringSubstring() {
let str = "foo" as NSString
expect(str).to(contain("o" as NSString))
expect(str).to(contain("oo" as NSString))
expect(str).toNot(contain("z" as NSString))
expect(str).toNot(contain("zz" as NSString))
}

func testVariadicArguments() {
Expand Down
4 changes: 2 additions & 2 deletions Tests/NimbleTests/Matchers/EndWithTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ final class EndWithTest: XCTestCase {
expect("foobar").toNot(endWith("oo"))
expect("foobarfoo").to(endWith("foo"))

expect(NSString(string: "foobar").description).to(endWith("bar"))
expect(NSString(string: "foobar").description).toNot(endWith("oo"))
expect(("foobar" as NSString).description).to(endWith("bar"))
expect(("foobar" as NSString).description).toNot(endWith("oo"))

expect(NSArray(array: ["a", "b"])).to(endWith("b"))
expect(NSArray(array: ["a", "b"])).toNot(endWith("a"))
Expand Down