Improve test for String.intern
We add a version of the test which should fail in addition to the one that should pass.
This commit is contained in:
parent
e6a5a11a4e
commit
524c13ff2d
|
@ -1,8 +1,8 @@
|
||||||
CORE
|
CORE
|
||||||
test_intern.class
|
test_intern.class
|
||||||
--max-nondet-string-length 1000 --function test_intern.main --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --unwind 10
|
--max-nondet-string-length 1000 --function test_intern.testPass --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --unwind 10
|
||||||
^EXIT=0$
|
^EXIT=0$
|
||||||
^SIGNAL=0$
|
^SIGNAL=0$
|
||||||
^\[.*assertion.1\].* line 9.* SUCCESS$
|
^\[.*assertion.1\].* line 12.* SUCCESS$
|
||||||
--
|
--
|
||||||
non equal types
|
non equal types
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
CORE
|
||||||
|
test_intern.class
|
||||||
|
--max-nondet-string-length 1000 --function test_intern.testFail --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --unwind 10
|
||||||
|
^EXIT=10$
|
||||||
|
^SIGNAL=0$
|
||||||
|
^\[.*assertion.1\].* line 24.* FAILURE$
|
||||||
|
--
|
||||||
|
non equal types
|
Binary file not shown.
|
@ -1,11 +1,26 @@
|
||||||
public class test_intern
|
public class test_intern
|
||||||
{
|
{
|
||||||
public static void main()
|
public static void testPass()
|
||||||
{
|
{
|
||||||
String s1 = "abc";
|
// Arrange
|
||||||
String s3 = "abc";
|
String s1 = "abc";
|
||||||
String x = s1.intern();
|
String s2 = "abc";
|
||||||
String y = s3.intern();
|
// Act
|
||||||
assert(x == y);
|
String x = s1.intern();
|
||||||
|
String y = s2.intern();
|
||||||
|
// Assert
|
||||||
|
assert(x == y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void testFail()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
String s1 = "abc";
|
||||||
|
String s2 = "abd";
|
||||||
|
// Act
|
||||||
|
String x = s1.intern();
|
||||||
|
String y = s2.intern();
|
||||||
|
// Assert
|
||||||
|
assert(x == y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue