Skip to content

Commit 7f93a67

Browse files
committed
Add more tests for optional
1 parent a0da213 commit 7f93a67

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

unittest/src/test/java/score/CallTest.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.List;
3131

3232
import static org.junit.jupiter.api.Assertions.assertEquals;
33+
import static org.junit.jupiter.api.Assertions.assertNull;
3334
import static org.junit.jupiter.api.Assertions.assertThrows;
3435

3536
public class CallTest extends TestBase {
@@ -47,6 +48,16 @@ public String echo(@Optional String message) {
4748
return message;
4849
}
4950

51+
@External(readonly=true)
52+
public Address echoAddress(@Optional Address _addr) {
53+
return _addr;
54+
}
55+
56+
@External(readonly=true)
57+
public byte[] echoByteArray(@Optional byte[] _data) {
58+
return _data;
59+
}
60+
5061
@External(readonly=true)
5162
public boolean echoBoolean(@Optional boolean bool) {
5263
return bool;
@@ -145,12 +156,15 @@ void parameterConversions_array() {
145156

146157
@Test
147158
void parameterConversions_Optional() {
148-
assertEquals(null, echoScore.call("echo"));
149-
assertEquals(BigInteger.ZERO, echoScore.call( "echoBigInteger"));
150-
assertEquals(0, echoScore.call( "echoInteger"));
159+
assertNull(echoScore.call("echo"));
160+
assertNull(echoScore.call("echoAddress"));
161+
assertNull(echoScore.call("echoByteArray"));
162+
assertEquals(BigInteger.ZERO, echoScore.call("echoBigInteger"));
163+
assertEquals(BigInteger.ONE, echoScore.call("echoBigInteger", BigInteger.ONE));
164+
165+
assertEquals(0, echoScore.call("echoInteger"));
151166
assertEquals(Short.valueOf("0"), echoScore.call("echoShort"));
152167
assertEquals(Long.valueOf("0"), echoScore.call("echoLong"));
153-
154168
assertEquals(Character.MIN_VALUE, echoScore.call("echoChar"));
155169
assertEquals(Byte.valueOf("0"), echoScore.call("echoByte"));
156170
assertEquals(Boolean.FALSE, echoScore.call("echoBoolean"));

0 commit comments

Comments
 (0)