Skip to content

Commit

Permalink
add swift-testing variants of StubTest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arovge authored and MatyasKriz committed Nov 3, 2024
1 parent 184eb06 commit 904ac6b
Showing 1 changed file with 96 additions and 1 deletion.
97 changes: 96 additions & 1 deletion Tests/Swift/StubTest.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import XCTest
import Cuckoo
import Testing
import XCTest
@testable import CuckooMocks

final class StubTest: XCTestCase {
Expand Down Expand Up @@ -86,3 +87,97 @@ final class StubTest: XCTestCase {
stub.voidFunction()
}
}

struct StubSwiftTestingTests {
let stub = ClassForStubTestingStub()

@Test
func intProperty() {
stub.intProperty = 1
#expect(stub.intProperty == 0)
}

@Test
func arrayProperty() {
stub.arrayProperty = [1]
#expect(stub.arrayProperty == [])
}

@Test
func setProperty() {
stub.setProperty = Set([1])
#expect(stub.setProperty == Set())
}

@Test
func dictionaryProperty() {
stub.dictionaryProperty = ["a": 1]
#expect(stub.dictionaryProperty == [:])
}

@Test
func tuple1() {
stub.tuple1 = (2)
#expect(stub.tuple1 == (0))
}

@Test
func tuple2() {
stub.tuple2 = (2, 1)
#expect(stub.tuple2 == (0, 0))
}

@Test
func tuple3() {
stub.tuple3 = (2, 1, true)
#expect(stub.tuple3 == (0, 0, false))
}

@Test
func tuple4() {
stub.tuple4 = (2, 1, 1, 1)
#expect(stub.tuple4 == (0, 0, 0, 0))
}

@Test
func tuple5() {
stub.tuple5 = (2, 1, 1, 1, 1)
#expect(stub.tuple5 == (0, 0, 0, 0, 0))
}

@Test
func tuple6() {
stub.tuple6 = (2, "A", 1, 1, 1, 1)
#expect(stub.tuple6 == (0, "", 0, 0, 0, 0))
}

@Test
func intFunction() {
stub.intProperty = 1
#expect(stub.intFunction() == 0)
}

@Test
func arrayFunction() {
stub.arrayProperty = [1]
#expect(stub.arrayFunction() == [])
}

@Test
func setFunction() {
stub.setProperty = Set([1])
#expect(stub.setFunction() == Set())
}

@Test
func dictionaryFunction() {
stub.dictionaryProperty = ["a": 1]
#expect(stub.dictionaryFunction() == [:])
}

@Test
func testVoidFunction() {
// Test for crash
stub.voidFunction()
}
}

0 comments on commit 904ac6b

Please sign in to comment.