Skip to content

Commit aa7f21c

Browse files
author
Daniel Kroening
authored
Merge pull request #530 from lucasccordeiro/string-regression
added test cases to check the string-solver
2 parents 2cf0e70 + b1de100 commit aa7f21c

File tree

217 files changed

+1911
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

217 files changed

+1911
-0
lines changed
Binary file not shown.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.util.regex.Matcher;
2+
import java.util.regex.Pattern;
3+
4+
public class RegexMatches01
5+
{
6+
public static void main(String[] args)
7+
{
8+
Pattern expression =
9+
Pattern.compile("W.*\\d[0-35-9]-\\d\\d-\\d\\d");
10+
11+
String string1 = "XXXX's Birthday is 05-12-75\n" +
12+
"YYYY's Birthday is 11-04-68\n" +
13+
"ZZZZ's Birthday is 04-28-73\n" +
14+
"WWWW's Birthday is 12-17-77";
15+
16+
Matcher matcher = expression.matcher(string1);
17+
18+
while (matcher.find())
19+
{
20+
System.out.println(matcher.group());
21+
String tmp=matcher.group();
22+
assert tmp.equals("WWWW's Birthday is 12-17-77");
23+
}
24+
}
25+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FUTURE
2+
RegexMatches01.class
3+
--string-refine --unwind 100
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
Binary file not shown.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.util.regex.Matcher;
2+
import java.util.regex.Pattern;
3+
4+
public class RegexMatches02
5+
{
6+
public static void main(String[] args)
7+
{
8+
Pattern expression =
9+
Pattern.compile("W.*\\d[0-35-9]-\\d\\d-\\d\\d");
10+
11+
String string1 = "XXXX's Birthday is 05-12-75\n" +
12+
"YYYY's Birthday is 11-04-68\n" +
13+
"ZZZZ's Birthday is 04-28-73\n" +
14+
"WWWW's Birthday is 12-17-77";
15+
16+
Matcher matcher = expression.matcher(string1);
17+
18+
while (matcher.find())
19+
{
20+
System.out.println(matcher.group());
21+
String tmp=matcher.group();
22+
assert tmp.equals("WWWWW's Birthday is 12-17-77");
23+
}
24+
}
25+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FUTURE
2+
RegexMatches02.class
3+
--string-refine --unwind 100
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
--
8+
^warning: ignoring
Binary file not shown.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import java.util.Arrays;
2+
3+
public class RegexSubstitution01
4+
{
5+
public static void main(String[] args)
6+
{
7+
String firstString = "DiffBlue ***";
8+
String secondString = "Automatic Test Case Generation";
9+
10+
firstString = firstString.replaceAll("\\*", "^");
11+
12+
assert firstString.equals("DiffBlue ^^^");
13+
14+
secondString = secondString.replaceAll("Automatic", "Automated");
15+
16+
System.out.printf(
17+
"\"Automatic\" substituted for \"Automated\": %s\n", secondString);
18+
secondString.equals("Automated Test Case Generation");
19+
20+
System.out.printf("Every word replaced by \"word\": %s\n\n",
21+
firstString.replaceAll("\\w+", "word"));
22+
23+
System.out.printf("Original String 2: %s\n", secondString);
24+
secondString.equals("Automated Test Case Generation");
25+
26+
for (int i = 0; i < 3; i++)
27+
secondString = secondString.replaceFirst("\\A", "automated");
28+
29+
assert secondString.equals("automatedautomatedautomatedAutomated Test Case Generation");
30+
31+
System.out.print("String split at commas: ");
32+
String[] results = secondString.split(" \\s*");
33+
System.out.println(Arrays.toString(results));
34+
assert results[0].equals("automatedautomatedautomatedAutomated");
35+
assert results[1].equals("Test");
36+
assert results[2].equals("Case");
37+
assert results[3].equals("Generation");
38+
}
39+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FUTURE
2+
RegexSubstitution01.class
3+
--string-refine
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
Binary file not shown.

0 commit comments

Comments
 (0)