Skip to content

Commit 7a12b70

Browse files
committed
Formatting
1 parent 39d8b9e commit 7a12b70

File tree

2 files changed

+62
-62
lines changed

2 files changed

+62
-62
lines changed

Diff for: src/main/java/org/junit/experimental/theories/PotentialAssignment.java

+15-15
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,24 @@ public String toString() {
2121

2222
@Override
2323
public String getDescription() {
24-
String valueString;
25-
26-
if (value == null) {
27-
valueString = "null";
28-
} else {
29-
try {
30-
valueString = format("\"%s\"", value);
31-
} catch (Throwable e) {
32-
valueString = format("[toString() threw %s: %s]",
33-
e.getClass().getSimpleName(), e.getMessage());
34-
}
35-
}
36-
37-
return format("%s <from %s>", valueString, name);
24+
String valueString;
25+
26+
if (value == null) {
27+
valueString = "null";
28+
} else {
29+
try {
30+
valueString = format("\"%s\"", value);
31+
} catch (Throwable e) {
32+
valueString = format("[toString() threw %s: %s]",
33+
e.getClass().getSimpleName(), e.getMessage());
34+
}
35+
}
36+
37+
return format("%s <from %s>", valueString, name);
3838
}
3939
};
4040
}
41-
41+
4242
public abstract Object getValue() throws CouldNotGenerateValueException;
4343

4444
public abstract String getDescription() throws CouldNotGenerateValueException;

Diff for: src/test/java/org/junit/tests/experimental/theories/PotentialAssignmentTest.java

+47-47
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,52 @@
66
import org.junit.experimental.theories.PotentialAssignment.CouldNotGenerateValueException;
77

88
public class PotentialAssignmentTest {
9-
10-
@Test
11-
public void shouldUseQuotedValueInDescription() throws CouldNotGenerateValueException {
12-
String name = "stringDatapoint";
13-
Object value = new Object() {
14-
@Override
15-
public String toString() {
16-
return "string value";
17-
}
18-
};
19-
20-
PotentialAssignment assignment = PotentialAssignment.forValue(name, value);
21-
22-
assertEquals("\"string value\" <from stringDatapoint>", assignment.getDescription());
23-
}
24-
25-
@Test
26-
public void shouldNotUseQuotesForNullValueDescriptions() throws CouldNotGenerateValueException {
27-
String name = "nullDatapoint";
28-
Object value = null;
29-
30-
PotentialAssignment assignment = PotentialAssignment.forValue(name, value);
31-
32-
assertEquals("null <from nullDatapoint>", assignment.getDescription());
33-
}
34-
35-
@Test
36-
public void shouldIncludeFailureInDescriptionIfToStringFails() throws CouldNotGenerateValueException {
37-
String name = "explodingValue";
38-
Object value = new Object() {
39-
@Override
40-
public String toString() {
41-
throw new RuntimeException("Oh no!");
42-
}
43-
};
44-
45-
PotentialAssignment assignment = PotentialAssignment.forValue(name, value);
46-
47-
assertEquals("[toString() threw RuntimeException: Oh no!] <from explodingValue>", assignment.getDescription());
48-
}
49-
50-
@Test
51-
public void shouldReturnGivenValue() throws CouldNotGenerateValueException {
52-
Object value = new Object();
53-
PotentialAssignment assignment = PotentialAssignment.forValue("name", value);
54-
assertEquals(value, assignment.getValue());
55-
}
9+
10+
@Test
11+
public void shouldUseQuotedValueInDescription() throws CouldNotGenerateValueException {
12+
String name = "stringDatapoint";
13+
Object value = new Object() {
14+
@Override
15+
public String toString() {
16+
return "string value";
17+
}
18+
};
19+
20+
PotentialAssignment assignment = PotentialAssignment.forValue(name, value);
21+
22+
assertEquals("\"string value\" <from stringDatapoint>", assignment.getDescription());
23+
}
24+
25+
@Test
26+
public void shouldNotUseQuotesForNullValueDescriptions() throws CouldNotGenerateValueException {
27+
String name = "nullDatapoint";
28+
Object value = null;
29+
30+
PotentialAssignment assignment = PotentialAssignment.forValue(name, value);
31+
32+
assertEquals("null <from nullDatapoint>", assignment.getDescription());
33+
}
34+
35+
@Test
36+
public void shouldIncludeFailureInDescriptionIfToStringFails() throws CouldNotGenerateValueException {
37+
String name = "explodingValue";
38+
Object value = new Object() {
39+
@Override
40+
public String toString() {
41+
throw new RuntimeException("Oh no!");
42+
}
43+
};
44+
45+
PotentialAssignment assignment = PotentialAssignment.forValue(name, value);
46+
47+
assertEquals("[toString() threw RuntimeException: Oh no!] <from explodingValue>", assignment.getDescription());
48+
}
49+
50+
@Test
51+
public void shouldReturnGivenValue() throws CouldNotGenerateValueException {
52+
Object value = new Object();
53+
PotentialAssignment assignment = PotentialAssignment.forValue("name", value);
54+
assertEquals(value, assignment.getValue());
55+
}
5656

5757
}

0 commit comments

Comments
 (0)