forked from chinedufn/swift-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringTests.swift
More file actions
72 lines (59 loc) · 2.07 KB
/
Copy pathStringTests.swift
File metadata and controls
72 lines (59 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// SwiftRustIntegrationTestRunnerTests.swift
// SwiftRustIntegrationTestRunnerTests
//
// Created by Frankie Nwafili on 11/14/21.
//
import XCTest
@testable import SwiftRustIntegrationTestRunner
@MainActor
class StringTests: XCTestCase {
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func testRunRustCallsSwiftTests() throws {
run_string_tests()
}
/// Verify that we can get a RustString's length
func testRustStringLen() throws {
let string = " hello "
let rustString: RustString = create_string(string)
XCTAssertEqual(rustString.len(), 7)
}
/// Verify that we can trim a RustString
func testTrimRustString() throws {
let string = " hello "
let rustString: RustString = create_string(string)
let trimmed: RustStr = rustString.trim()
XCTAssertEqual(trimmed.len, 5)
}
func testRustStringToString() throws {
let string = "hi"
XCTAssertEqual(
create_string(string).toString(),
"hi"
)
}
func testRustStrEqualityOperator() throws {
XCTContext.runActivity(named: "Should be equal"){
_ in
let hello1 = create_string("hello")
let hello2 = create_string("hello")
XCTAssertEqual(hello1.as_str(), hello2.as_str())
}
XCTContext.runActivity(named: "Should not be equal"){
_ in
//Not equal length
let hi = create_string("hi")
let hello = create_string("hello")
XCTAssertNotEqual(hi.as_str(), hello.as_str())
//Equal length
let foo = create_string("foo")
let bar = create_string("bar")
XCTAssertNotEqual(foo.as_str(), bar.as_str())
}
}
}