Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static void assertEqualInOrder(Iterable<?> expected, Iterable<?> actual)
}
}

public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
public static void assertContentsInOrder(Iterable<?> actual, @Nullable Object... expected) {
assertEqualInOrder(asList(expected), actual);
}

Expand Down Expand Up @@ -155,11 +155,11 @@ public static void assertEqualIgnoringOrder(Iterable<?> expected, Iterable<?> ac
assertTrue("unexpected elements: " + act, act.isEmpty());
}

public static void assertContentsAnyOrder(Iterable<?> actual, Object... expected) {
public static void assertContentsAnyOrder(Iterable<?> actual, @Nullable Object... expected) {
assertEqualIgnoringOrder(asList(expected), actual);
}

public static void assertContains(Iterable<?> actual, Object expected) {
public static void assertContains(Iterable<?> actual, @Nullable Object expected) {
boolean contained = false;
if (actual instanceof Collection) {
contained = ((Collection<?>) actual).contains(expected);
Expand All @@ -177,7 +177,7 @@ public static void assertContains(Iterable<?> actual, Object expected) {
}
}

public static void assertContainsAllOf(Iterable<?> actual, Object... expected) {
public static void assertContainsAllOf(Iterable<?> actual, @Nullable Object... expected) {
List<Object> expectedList = new ArrayList<>(asList(expected));

for (Object o : actual) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.google.common.escape.testing;

import static com.google.common.escape.Escapers.computeReplacement;
import static org.junit.Assert.assertThrows;

import com.google.common.annotations.GwtCompatible;
import com.google.common.escape.CharEscaper;
Expand All @@ -40,16 +41,12 @@ private EscaperAsserts() {}
*
* @param escaper the non-null escaper to test
*/
@SuppressWarnings("NullArgumentForNonNullParameter") // test of a bogus call
public static void assertBasic(Escaper escaper) throws IOException {
// Escapers operate on characters: no characters, no escaping.
Assert.assertEquals("", escaper.escape(""));
// Assert that escapers throw null pointer exceptions.
try {
escaper.escape((String) null);
Assert.fail("exception not thrown when escaping a null string");
} catch (NullPointerException e) {
// pass
}
assertThrows(NullPointerException.class, () -> escaper.escape(null));
}

/**
Expand All @@ -60,7 +57,6 @@ public static void assertBasic(Escaper escaper) throws IOException {
* @param c the character to escape
*/
public static void assertEscaping(CharEscaper escaper, String expected, char c) {

String escaped = computeReplacement(escaper, c);
Assert.assertNotNull(escaped);
Assert.assertEquals(expected, escaped);
Expand All @@ -74,7 +70,6 @@ public static void assertEscaping(CharEscaper escaper, String expected, char c)
* @param cp the Unicode code point to escape
*/
public static void assertEscaping(UnicodeEscaper escaper, String expected, int cp) {

String escaped = computeReplacement(escaper, cp);
Assert.assertNotNull(escaped);
Assert.assertEquals(expected, escaped);
Expand Down Expand Up @@ -110,7 +105,6 @@ public static void assertUnescaped(UnicodeEscaper escaper, int cp) {
*/
public static void assertUnicodeEscaping(
UnicodeEscaper escaper, String expected, char hi, char lo) {

int cp = Character.toCodePoint(hi, lo);
String escaped = computeReplacement(escaper, cp);
Assert.assertNotNull(escaped);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static void assertEqualInOrder(Iterable<?> expected, Iterable<?> actual)
}
}

public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
public static void assertContentsInOrder(Iterable<?> actual, @Nullable Object... expected) {
assertEqualInOrder(asList(expected), actual);
}

Expand Down Expand Up @@ -155,11 +155,11 @@ public static void assertEqualIgnoringOrder(Iterable<?> expected, Iterable<?> ac
assertTrue("unexpected elements: " + act, act.isEmpty());
}

public static void assertContentsAnyOrder(Iterable<?> actual, Object... expected) {
public static void assertContentsAnyOrder(Iterable<?> actual, @Nullable Object... expected) {
assertEqualIgnoringOrder(asList(expected), actual);
}

public static void assertContains(Iterable<?> actual, Object expected) {
public static void assertContains(Iterable<?> actual, @Nullable Object expected) {
boolean contained = false;
if (actual instanceof Collection) {
contained = ((Collection<?>) actual).contains(expected);
Expand All @@ -177,7 +177,7 @@ public static void assertContains(Iterable<?> actual, Object expected) {
}
}

public static void assertContainsAllOf(Iterable<?> actual, Object... expected) {
public static void assertContainsAllOf(Iterable<?> actual, @Nullable Object... expected) {
List<Object> expectedList = new ArrayList<>(asList(expected));

for (Object o : actual) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.google.common.escape.testing;

import static com.google.common.escape.Escapers.computeReplacement;
import static org.junit.Assert.assertThrows;

import com.google.common.annotations.GwtCompatible;
import com.google.common.escape.CharEscaper;
Expand All @@ -40,16 +41,12 @@ private EscaperAsserts() {}
*
* @param escaper the non-null escaper to test
*/
@SuppressWarnings("NullArgumentForNonNullParameter") // test of a bogus call
public static void assertBasic(Escaper escaper) throws IOException {
// Escapers operate on characters: no characters, no escaping.
Assert.assertEquals("", escaper.escape(""));
// Assert that escapers throw null pointer exceptions.
try {
escaper.escape((String) null);
Assert.fail("exception not thrown when escaping a null string");
} catch (NullPointerException e) {
// pass
}
assertThrows(NullPointerException.class, () -> escaper.escape(null));
}

/**
Expand All @@ -60,7 +57,6 @@ public static void assertBasic(Escaper escaper) throws IOException {
* @param c the character to escape
*/
public static void assertEscaping(CharEscaper escaper, String expected, char c) {

String escaped = computeReplacement(escaper, c);
Assert.assertNotNull(escaped);
Assert.assertEquals(expected, escaped);
Expand All @@ -74,7 +70,6 @@ public static void assertEscaping(CharEscaper escaper, String expected, char c)
* @param cp the Unicode code point to escape
*/
public static void assertEscaping(UnicodeEscaper escaper, String expected, int cp) {

String escaped = computeReplacement(escaper, cp);
Assert.assertNotNull(escaped);
Assert.assertEquals(expected, escaped);
Expand Down Expand Up @@ -110,7 +105,6 @@ public static void assertUnescaped(UnicodeEscaper escaper, int cp) {
*/
public static void assertUnicodeEscaping(
UnicodeEscaper escaper, String expected, char hi, char lo) {

int cp = Character.toCodePoint(hi, lo);
String escaped = computeReplacement(escaper, cp);
Assert.assertNotNull(escaped);
Expand Down
Loading