Skip to content

Commit 2515d5b

Browse files
committed
a reformat code
1 parent a70e356 commit 2515d5b

File tree

2 files changed

+41
-49
lines changed

2 files changed

+41
-49
lines changed

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

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,61 +17,56 @@ public class InlineApprovalsTest
1717
public void testWithBuiltinReporter()
1818
{
1919
var expected = """
20-
Hello Lada***
21-
""";
22-
20+
Hello Lada***
21+
""";
2322
Options inline = Options.inline(expected);
2423
Approvals.verify("Hello Lada***", inline);
25-
assertEquals(0, ((InlineComparator)inline.getComparator()).fileWrites);
24+
assertEquals(0, ((InlineComparator) inline.getComparator()).fileWrites);
2625
}
2726
@UseReporter(DiffMergeReporter.class)
2827
@Test
2928
public void testWithSpecificReporter()
3029
{
3130
var expected = """
32-
Hello Lada***
33-
""";
34-
31+
Hello Lada***
32+
""";
3533
Options inline = Options.inline(expected).withReporter(DiffMergeReporter.INSTANCE);
3634
Approvals.verify("Hello Lada***", inline);
37-
assertEquals(0, ((InlineComparator)inline.getComparator()).fileWrites);
35+
assertEquals(0, ((InlineComparator) inline.getComparator()).fileWrites);
3836
}
3937
//Does this work with annotations on tests
4038
//Concatenating strings
4139
//There's some code before verify that is not replacing the result
42-
4340
@Test
4441
public void testCreateReceivedFileText()
4542
{
46-
var inputs = List.of( """
47-
@Test
48-
public void testyMctest() {
49-
var expected = ""\"
50-
Hello World***
51-
""\";
52-
Approvals.verify("", Options.inline(expected));
53-
}
54-
""",
55-
"""
56-
@Test
57-
public void testyMctest()
58-
{
59-
var expected = ""\"
60-
Hello World***
61-
""\";
62-
Approvals.verify("", Options.inline(expected));
63-
}
64-
""",
65-
"""
66-
@Test
67-
public void testyMctest(int foo) {
68-
var expected = ""\"
69-
Hello World***
70-
""\";
71-
Approvals.verify("", Options.inline(expected));
72-
}
73-
"""
74-
);
75-
Approvals.verifyAll("Substitution",inputs, i -> InlineComparator.createNewReceivedFileText(i, "1\n2", "testyMctest"));
43+
var inputs = List.of("""
44+
@Test
45+
public void testyMctest() {
46+
var expected = ""\"
47+
Hello World***
48+
""\";
49+
Approvals.verify("", Options.inline(expected));
50+
}
51+
""", """
52+
@Test
53+
public void testyMctest()
54+
{
55+
var expected = ""\"
56+
Hello World***
57+
""\";
58+
Approvals.verify("", Options.inline(expected));
59+
}
60+
""", """
61+
@Test
62+
public void testyMctest(int foo) {
63+
var expected = ""\"
64+
Hello World***
65+
""\";
66+
Approvals.verify("", Options.inline(expected));
67+
}
68+
""");
69+
Approvals.verifyAll("Substitution", inputs,
70+
i -> InlineComparator.createNewReceivedFileText(i, "1\n2", "testyMctest"));
7671
}
7772
}

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class InlineComparator
3131
private String actual;
3232
private File approvedFile;
3333
private File receivedFile;
34-
public int fileWrites = 0;
34+
public int fileWrites = 0;
3535
public InlineComparator(String expected)
3636
{
3737
this.expected = expected;
@@ -51,22 +51,21 @@ public VerifyResult call(File received, File approved)
5151
return VerifyResult.FAILURE;
5252
}
5353
}
54-
55-
private void writeFiles() {
54+
private void writeFiles()
55+
{
5656
FileUtils.writeFile(approvedFile, expected);
5757
fileWrites++;
5858
FileUtils.writeFile(receivedFile, actual);
5959
fileWrites++;
6060
}
61-
6261
@Override
6362
public File getApprovedFile(String extensionWithDot)
6463
{
6564
if (approvedFile == null)
6665
{
6766
try
6867
{
69-
this.approvedFile = File.createTempFile("temp", approved+extensionWithDot);
68+
this.approvedFile = File.createTempFile("temp", approved + extensionWithDot);
7069
}
7170
catch (IOException e)
7271
{
@@ -82,7 +81,7 @@ public File getReceivedFile(String extensionWithDot)
8281
{
8382
try
8483
{
85-
this.receivedFile = File.createTempFile("temp", received+extensionWithDot);
84+
this.receivedFile = File.createTempFile("temp", received + extensionWithDot);
8685
}
8786
catch (IOException e)
8887
{
@@ -134,7 +133,6 @@ public boolean report(String received, String approved)
134133
String newSource = createReceived();
135134
return reporter.report(newSource, sourceFile);
136135
}
137-
138136
private String createReceived()
139137
{
140138
String file = sourceFilePath + stackTraceNamer.getInfo().getClassName() + ".java";
@@ -144,8 +142,8 @@ private String createReceived()
144142
FileUtils.writeFile(new File(received), fullText);
145143
return received;
146144
}
147-
148-
public static String createNewReceivedFileText(String text, String actual, String methodName) {
145+
public static String createNewReceivedFileText(String text, String actual, String methodName)
146+
{
149147
int start = text.indexOf("void " + methodName + "(");
150148
start = text.indexOf("{", start);
151149
int next = text.indexOf("\n", start);
@@ -165,7 +163,6 @@ public static String createNewReceivedFileText(String text, String actual, Strin
165163
part2);
166164
return fullText;
167165
}
168-
169166
public static String indent(String actual)
170167
{
171168
String[] split = actual.split("\n");

0 commit comments

Comments
 (0)