aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/syntax/PrinterTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/syntax/PrinterTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/PrinterTest.java38
1 files changed, 4 insertions, 34 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/PrinterTest.java b/src/test/java/com/google/devtools/build/lib/syntax/PrinterTest.java
index 0a7f8410a8..fdf43271bb 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/PrinterTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/PrinterTest.java
@@ -98,12 +98,12 @@ public class PrinterTest {
@Test
public void testFormatPositional() throws Exception {
- assertThat(Printer.formatToString("%s %d", Tuple.of("foo", 3))).isEqualTo("foo 3");
+ assertThat(Printer.formatWithList("%s %d", Tuple.of("foo", 3))).isEqualTo("foo 3");
assertThat(Printer.format("%s %d", "foo", 3)).isEqualTo("foo 3");
// Note: formatToString doesn't perform scalar x -> (x) conversion;
// The %-operator is responsible for that.
- assertThat(Printer.formatToString("", Tuple.of())).isEmpty();
+ assertThat(Printer.formatWithList("", Tuple.of())).isEmpty();
assertThat(Printer.format("%s", "foo")).isEqualTo("foo");
assertThat(Printer.format("%s", 3.14159)).isEqualTo("3.14159");
checkFormatPositionalFails("not all arguments converted during string formatting",
@@ -131,34 +131,6 @@ public class PrinterTest {
}
@Test
- public void testSingleQuotes() throws Exception {
- assertThat(Printer.str("test", '\'')).isEqualTo("test");
- assertThat(Printer.repr("test", '\'')).isEqualTo("'test'");
-
- assertThat(Printer.repr("'", '\'')).isEqualTo("'\\''");
- assertThat(Printer.str("\"", '\'')).isEqualTo("\"");
- assertThat(Printer.repr("\"", '\'')).isEqualTo("'\"'");
-
- List<?> list = MutableList.of(null, "foo", "bar");
- List<?> tuple = Tuple.of("foo", "bar");
-
- assertThat(Printer.str(Tuple.of(1, list, 3), '\'')).isEqualTo("(1, ['foo', 'bar'], 3)");
- assertThat(Printer.repr(Tuple.of(1, list, 3), '\'')).isEqualTo("(1, ['foo', 'bar'], 3)");
- assertThat(Printer.str(MutableList.of(null, 1, tuple, 3), '\''))
- .isEqualTo("[1, ('foo', 'bar'), 3]");
- assertThat(Printer.repr(MutableList.of(null, 1, tuple, 3), '\''))
- .isEqualTo("[1, ('foo', 'bar'), 3]");
-
- Map<Object, Object> dict =
- ImmutableMap.<Object, Object>of(1, tuple, 2, list, "foo", MutableList.of(null));
-
- assertThat(Printer.str(dict, '\''))
- .isEqualTo("{1: ('foo', 'bar'), 2: ['foo', 'bar'], 'foo': []}");
- assertThat(Printer.repr(dict, '\''))
- .isEqualTo("{1: ('foo', 'bar'), 2: ['foo', 'bar'], 'foo': []}");
- }
-
- @Test
public void testListLimitStringLength() throws Exception {
int lengthDivisibleByTwo = Printer.SUGGESTED_CRITICAL_LIST_ELEMENTS_STRING_LENGTH;
if (lengthDivisibleByTwo % 2 == 1) {
@@ -249,9 +221,7 @@ public class PrinterTest {
}
private String printList(List<?> list, int criticalElementsCount, int criticalStringLength) {
- StringBuilder builder = new StringBuilder();
- Printer.printList(
- builder, list, "[", ", ", "]", "", '"', criticalElementsCount, criticalStringLength);
- return builder.toString();
+ return Printer.printAbbreviatedList(
+ list, "[", ", ", "]", "", criticalElementsCount, criticalStringLength);
}
}