Skip to content

Commit 2b66e65

Browse files
committed
- B Fixed bug in InlineApprovals where spaces prevented a function from being found
1 parent 6b7638b commit 2b66e65

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

approvaltests-tests/src/test/java/org/approvaltests/inline/InlineApprovalsTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ public void testyMctest() {
4848
""\";
4949
Approvals.verify("", Options.inline(expected));
5050
}
51+
""","""
52+
@Test
53+
public void testyMctest () {
54+
var expected = ""\"
55+
Hello World***
56+
""\";
57+
Approvals.verify("", Options.inline(expected));
58+
}
5159
""", """
5260
\t@Test
5361
\tpublic void testyMctest()

approvaltests-tests/src/test/java/org/approvaltests/inline/InlineApprovalsTest.testCreateReceivedFileText.approved.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,25 @@ Becomes:
2020
Approvals.verify("", Options.inline(expected));
2121
}
2222

23+
******
24+
@Test
25+
public void testyMctest () {
26+
var expected = """
27+
Hello World***
28+
""";
29+
Approvals.verify("", Options.inline(expected));
30+
}
31+
32+
Becomes:
33+
@Test
34+
public void testyMctest () {
35+
var expected = """
36+
1
37+
2
38+
""";
39+
Approvals.verify("", Options.inline(expected));
40+
}
41+
2342
******
2443
@Test
2544
public void testyMctest()

approvaltests/src/main/java/org/approvaltests/inline/CodeParts.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ public static CodeParts splitCode(String text, String methodName)
2222
String line = lines[i];
2323
if (start == 0)
2424
{
25-
if (line.contains("void " + methodName + "("))
25+
// Do a regex search to check if a line contains the text "void"
26+
27+
if (line.matches(".*void\\s+" + methodName + "\\s*\\(.*"))
2628
{
2729
start = i;
2830
codeParts.tab = extractLeadingWhitespace(line);

0 commit comments

Comments
 (0)