|
12 | 12 | */ |
13 | 13 | package org.assertj.core.presentation; |
14 | 14 |
|
15 | | -import org.assertj.core.configuration.Configuration; |
16 | | -import org.assertj.core.configuration.ConfigurationProvider; |
17 | | -import org.assertj.core.data.MapEntry; |
18 | | -import org.assertj.core.groups.Tuple; |
19 | | -import org.assertj.core.internal.ComparatorBasedComparisonStrategy; |
20 | | -import org.assertj.core.util.Closeables; |
21 | | -import org.assertj.core.util.VisibleForTesting; |
22 | | -import org.assertj.core.util.diff.ChangeDelta; |
23 | | -import org.assertj.core.util.diff.DeleteDelta; |
24 | | -import org.assertj.core.util.diff.InsertDelta; |
| 15 | +import static java.lang.Integer.toHexString; |
| 16 | +import static java.util.stream.Collectors.toList; |
| 17 | +import static org.assertj.core.util.Arrays.isArray; |
| 18 | +import static org.assertj.core.util.Arrays.isArrayTypePrimitive; |
| 19 | +import static org.assertj.core.util.Arrays.isObjectArray; |
| 20 | +import static org.assertj.core.util.Arrays.notAnArrayOfPrimitives; |
| 21 | +import static org.assertj.core.util.DateUtil.formatAsDatetime; |
| 22 | +import static org.assertj.core.util.DateUtil.formatAsDatetimeWithMs; |
| 23 | +import static org.assertj.core.util.Preconditions.checkArgument; |
| 24 | +import static org.assertj.core.util.Strings.concat; |
| 25 | +import static org.assertj.core.util.Strings.quote; |
| 26 | +import static org.assertj.core.util.Throwables.getStackTrace; |
25 | 27 |
|
26 | 28 | import java.io.File; |
27 | 29 | import java.io.PrintWriter; |
|
61 | 63 | import java.util.concurrent.atomic.LongAdder; |
62 | 64 | import java.util.function.Function; |
63 | 65 |
|
64 | | -import static java.lang.Integer.toHexString; |
65 | | -import static java.util.stream.Collectors.toList; |
66 | | -import static org.assertj.core.util.Arrays.isArray; |
67 | | -import static org.assertj.core.util.Arrays.isArrayTypePrimitive; |
68 | | -import static org.assertj.core.util.Arrays.isObjectArray; |
69 | | -import static org.assertj.core.util.Arrays.notAnArrayOfPrimitives; |
70 | | -import static org.assertj.core.util.DateUtil.formatAsDatetime; |
71 | | -import static org.assertj.core.util.DateUtil.formatAsDatetimeWithMs; |
72 | | -import static org.assertj.core.util.Preconditions.checkArgument; |
73 | | -import static org.assertj.core.util.Strings.concat; |
74 | | -import static org.assertj.core.util.Strings.quote; |
75 | | -import static org.assertj.core.util.Throwables.getStackTrace; |
| 66 | +import org.assertj.core.configuration.Configuration; |
| 67 | +import org.assertj.core.configuration.ConfigurationProvider; |
| 68 | +import org.assertj.core.data.MapEntry; |
| 69 | +import org.assertj.core.groups.Tuple; |
| 70 | +import org.assertj.core.internal.ComparatorBasedComparisonStrategy; |
| 71 | +import org.assertj.core.util.Closeables; |
| 72 | +import org.assertj.core.util.VisibleForTesting; |
| 73 | +import org.assertj.core.util.diff.ChangeDelta; |
| 74 | +import org.assertj.core.util.diff.DeleteDelta; |
| 75 | +import org.assertj.core.util.diff.InsertDelta; |
76 | 76 |
|
77 | 77 | /** |
78 | 78 | * Standard java object representation. |
@@ -234,6 +234,7 @@ public String toStringOf(Object object) { |
234 | 234 | if (object instanceof AtomicReferenceFieldUpdater) return AtomicReferenceFieldUpdater.class.getSimpleName(); |
235 | 235 | if (object instanceof File) return toStringOf((File) object); |
236 | 236 | if (object instanceof Path) return fallbackToStringOf(object); |
| 237 | + if (isUnquotedString(object)) return toUnquotedStringOf(object); |
237 | 238 | if (object instanceof String) return toStringOf((String) object); |
238 | 239 | if (object instanceof CharSequence) return toStringOf((CharSequence) object); |
239 | 240 | if (object instanceof Character) return toStringOf((Character) object); |
@@ -262,6 +263,11 @@ public String toStringOf(Object object) { |
262 | 263 | return fallbackToStringOf(object); |
263 | 264 | } |
264 | 265 |
|
| 266 | + private static boolean isUnquotedString(Object object) { |
| 267 | + String className = object.getClass().getName(); |
| 268 | + return className.contains("org.assertj.core") && className.contains("UnquotedString"); |
| 269 | + } |
| 270 | + |
265 | 271 | private static boolean isInstanceOfNotOverridingToString(Object object, Class<?> type) { |
266 | 272 | return type.isInstance(object) && !hasOverriddenToStringInSubclassOf(object.getClass(), type); |
267 | 273 | } |
@@ -404,6 +410,10 @@ protected String toStringOf(String s) { |
404 | 410 | return concatWithDoubleQuotes(s); |
405 | 411 | } |
406 | 412 |
|
| 413 | + protected String toUnquotedStringOf(Object s) { |
| 414 | + return s.toString(); |
| 415 | + } |
| 416 | + |
407 | 417 | protected String toStringOf(CharSequence s) { |
408 | 418 | return concatWithDoubleQuotes(s); |
409 | 419 | } |
|
0 commit comments