forked from mjanicek/rembulan
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test for #4 - Magic chars in StringPattern character groups …
…behaving incorrectly
- Loading branch information
Showing
1 changed file
with
99 additions
and
0 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
rembulan-tests/src/test/java/net/sandius/rembulan/lib/StringLib_Issue_4_Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package net.sandius.rembulan.lib; | ||
|
||
import org.junit.FixMethodOrder; | ||
import org.junit.Test; | ||
import org.junit.runners.MethodSorters; | ||
|
||
import net.sandius.rembulan.testenv.TestBase; | ||
|
||
@FixMethodOrder(MethodSorters.NAME_ASCENDING) | ||
public class StringLib_Issue_4_Test extends TestBase { | ||
@Test | ||
public void _test_a_match_a() throws Exception { | ||
// Given: | ||
String program = "return string.match(\"a\",\"a\")"; | ||
|
||
// When: | ||
Object[] actual = run(program); | ||
|
||
// Then: | ||
assertThat(actual).isEqualTo(new Object[] {"a"}); | ||
} | ||
|
||
@Test | ||
public void _test_1_match_not_1() throws Exception { | ||
|
||
// Given: | ||
String program = "return string.match(\"1\",\"[^1]\")"; | ||
|
||
// When: | ||
Object[] actual = run(program); | ||
|
||
// Then: | ||
assertThat(actual).isEqualTo(new Object[] {null}); | ||
} | ||
|
||
@Test | ||
public void _test_1_match_not_0() throws Exception { | ||
|
||
// Given: | ||
String program = "return string.match(\"1\",\"[^0]\")"; | ||
|
||
// When: | ||
Object[] actual = run(program); | ||
|
||
// Then: | ||
assertThat(actual).isEqualTo(new Object[] {"1"}); | ||
} | ||
|
||
@Test | ||
public void _test_1_match_1() throws Exception { | ||
|
||
// Given: | ||
String program = "return string.match(\"1\",\"[1]\")"; | ||
|
||
// When: | ||
Object[] actual = run(program); | ||
|
||
// Then: | ||
assertThat(actual).isEqualTo(new Object[] {"1"}); | ||
} | ||
|
||
@Test | ||
public void _test_1_match_0() throws Exception { | ||
|
||
// Given: | ||
String program = "return string.match(\"1\",\"[0]\")"; | ||
|
||
// When: | ||
Object[] actual = run(program); | ||
|
||
// Then: | ||
assertThat(actual).isEqualTo(new Object[] {null}); | ||
} | ||
|
||
@Test | ||
public void _test_plus_match_plus() throws Exception { | ||
|
||
// Given: | ||
String program = "return string.match(\"+\",\"[+]\")"; | ||
|
||
// When: | ||
Object[] actual = run(program); | ||
|
||
// Then: | ||
assertThat(actual).isEqualTo(new Object[] {null}); | ||
} | ||
|
||
@Test | ||
public void test() throws Exception { | ||
// Given: | ||
String program = "string.match(tostring(0.5), \"([^05+])\")"; | ||
|
||
// When: | ||
Object[] actual = run(program); | ||
|
||
// Then: | ||
assertThat(actual).isEqualTo(new Object[] {"."}); | ||
} | ||
} |