Skip to content

Commit af0a30d

Browse files
committed
make the jni throwing runtime test actually throw
1 parent ab9e0a1 commit af0a30d

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

Samples/SwiftJavaExtractJNISampleApp/Sources/MySwiftLibrary/Throw.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@
1515
import SwiftJava
1616

1717
public func throwString(input: String) throws -> String {
18-
input
18+
if input.isEmpty {
19+
throw MySwiftError.swiftError
20+
}
21+
return input
1922
}

Samples/SwiftJavaExtractJNISampleApp/src/test/java/com/example/swift/ThrowTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,13 @@ void throwString() throws Exception {
2525
String result = MySwiftLibrary.throwString("hey");
2626
assertEquals("hey", result);
2727
}
28+
29+
@Test
30+
void throwStringActuallyThrows() {
31+
Exception exception = assertThrows(Exception.class, () -> {
32+
MySwiftLibrary.throwString("");
33+
});
34+
assertNotNull(exception.getMessage());
35+
assertTrue(exception.getMessage().contains("swiftError"));
36+
}
2837
}

0 commit comments

Comments
 (0)