code
stringlengths
23
201k
docstring
stringlengths
17
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
72
path
stringlengths
11
317
url
stringlengths
57
377
license
stringclasses
7 values
@Test public void isEqualToFailureExtra() { ImmutableMap<String, Integer> actual = ImmutableMap.of("jan", 1, "feb", 2, "march", 3); ImmutableMap<String, Integer> expectedMap = ImmutableMap.of("jan", 1, "feb", 2); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).isEqualTo(expectedMap)); assertFailureKeys( e, "unexpected keys", "for key", "unexpected value", "---", "expected", "but was"); assertFailureValue(e, "for key", "march"); assertFailureValue(e, "unexpected value", "3"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
isEqualToFailureExtra
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void isEqualToFailureMissing() { ImmutableMap<String, Integer> actual = ImmutableMap.of("jan", 1, "feb", 2); ImmutableMap<String, Integer> expectedMap = ImmutableMap.of("jan", 1, "feb", 2, "march", 3); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).isEqualTo(expectedMap)); assertFailureKeys(e, "missing keys", "for key", "expected value", "---", "expected", "but was"); assertFailureValue(e, "for key", "march"); assertFailureValue(e, "expected value", "3"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
isEqualToFailureMissing
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void isEqualToFailureExtraAndMissing() { ImmutableMap<String, Integer> actual = ImmutableMap.of("jan", 1, "feb", 2, "march", 3); ImmutableMap<String, Integer> expectedMap = ImmutableMap.of("jan", 1, "feb", 2, "mar", 3); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).isEqualTo(expectedMap)); assertFailureKeys( e, "missing keys", "for key", "expected value", "unexpected keys", "for key", "unexpected value", "---", "expected", "but was"); assertFailureValueIndexed(e, "for key", 0, "mar"); assertFailureValue(e, "expected value", "3"); assertFailureValueIndexed(e, "for key", 1, "march"); assertFailureValue(e, "unexpected value", "3"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
isEqualToFailureExtraAndMissing
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void isEqualToFailureDiffering_sameToString() { ImmutableMap<String, Number> actual = ImmutableMap.<String, Number>of("jan", 1, "feb", 2, "march", 3L); ImmutableMap<String, Integer> expectedMap = ImmutableMap.of("jan", 1, "feb", 2, "march", 3); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).isEqualTo(expectedMap)); assertFailureKeys( e, "keys with wrong values", "for key", "expected value", "but got value", "---", "expected", "but was"); assertFailureValueIndexed(e, "for key", 0, "march"); assertFailureValue(e, "expected value", "3 (java.lang.Integer)"); assertFailureValue(e, "but got value", "3 (java.lang.Long)"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
isEqualToFailureDiffering_sameToString
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void isEqualToNonMap() { ImmutableMap<String, Integer> actual = ImmutableMap.of("jan", 1, "feb", 2, "march", 3); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).isEqualTo("something else")); assertFailureKeys(e, "expected", "but was"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
isEqualToNonMap
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void isEqualToNotConsistentWithEquals() { TreeMap<String, Integer> actual = new TreeMap<>(CASE_INSENSITIVE_ORDER); TreeMap<String, Integer> expected = new TreeMap<>(CASE_INSENSITIVE_ORDER); actual.put("one", 1); expected.put("ONE", 1); /* * Our contract doesn't guarantee that the following test will pass. It *currently* does, * though, and if we change that behavior, we want this test to let us know. */ assertThat(actual).isEqualTo(expected); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
isEqualToNotConsistentWithEquals
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void isEqualToNotConsistentWithEquals_failure() { TreeMap<String, Integer> actual = new TreeMap<>(CASE_INSENSITIVE_ORDER); TreeMap<String, Integer> expected = new TreeMap<>(CASE_INSENSITIVE_ORDER); actual.put("one", 1); expected.put("ONE", 1); actual.put("two", 2); expectFailure(whenTesting -> whenTesting.that(actual).isEqualTo(expected)); // The exact message generated is unspecified. }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
isEqualToNotConsistentWithEquals_failure
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void isEqualToActualNullOtherMap() { expectFailure(whenTesting -> whenTesting.that((Map<?, ?>) null).isEqualTo(ImmutableMap.of())); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
isEqualToActualNullOtherMap
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void isEqualToActualMapOtherNull() { expectFailure(whenTesting -> whenTesting.that(ImmutableMap.of()).isEqualTo(null)); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
isEqualToActualMapOtherNull
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void isNotEqualTo() { ImmutableMap<String, Integer> actual = ImmutableMap.of("jan", 1, "feb", 2, "march", 3); ImmutableMap<String, Integer> unexpected = ImmutableMap.of("jan", 1, "feb", 2, "march", 3); expectFailure(whenTesting -> whenTesting.that(actual).isNotEqualTo(unexpected)); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
isNotEqualTo
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void isEmpty() { ImmutableMap<String, String> actual = ImmutableMap.of(); assertThat(actual).isEmpty(); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
isEmpty
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void isEmptyWithFailure() { ImmutableMap<Integer, Integer> actual = ImmutableMap.of(1, 5); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).isEmpty()); assertFailureKeys(e, "expected to be empty", "but was"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
isEmptyWithFailure
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void isNotEmpty() { ImmutableMap<Integer, Integer> actual = ImmutableMap.of(1, 5); assertThat(actual).isNotEmpty(); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
isNotEmpty
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void isNotEmptyWithFailure() { ImmutableMap<Integer, Integer> actual = ImmutableMap.of(); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).isNotEmpty()); assertFailureKeys(e, "expected not to be empty"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
isNotEmptyWithFailure
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void hasSize() { assertThat(ImmutableMap.of(1, 2, 3, 4)).hasSize(2); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
hasSize
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void hasSizeZero() { assertThat(ImmutableMap.of()).hasSize(0); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
hasSizeZero
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void hasSizeNegative() { assertThrows( IllegalArgumentException.class, () -> assertThat(ImmutableMap.of(1, 2)).hasSize(-1)); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
hasSizeNegative
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void containsKey() { ImmutableMap<String, String> actual = ImmutableMap.of("kurt", "kluever"); assertThat(actual).containsKey("kurt"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
containsKey
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void containsKeyFailure() { ImmutableMap<String, String> actual = ImmutableMap.of("kurt", "kluever"); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).containsKey("greg")); assertFailureKeys(e, "value of", "expected to contain", "but was", "map was"); assertFailureValue(e, "value of", "map.keySet()"); assertFailureValue(e, "expected to contain", "greg"); assertFailureValue(e, "but was", "[kurt]"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
containsKeyFailure
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void containsKeyNullFailure() { ImmutableMap<String, String> actual = ImmutableMap.of("kurt", "kluever"); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).containsKey(null)); assertFailureKeys(e, "value of", "expected to contain", "but was", "map was"); assertFailureValue(e, "value of", "map.keySet()"); assertFailureValue(e, "expected to contain", "null"); assertFailureValue(e, "but was", "[kurt]"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
containsKeyNullFailure
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void containsKey_failsWithSameToString() { AssertionError e = expectFailure( whenTesting -> whenTesting .that(ImmutableMap.of(1L, "value1", 2L, "value2", "1", "value3")) .containsKey(1)); assertFailureKeys( e, "value of", "expected to contain", "an instance of", "but did not", "though it did contain", "full contents", "map was"); assertFailureValue(e, "value of", "map.keySet()"); assertFailureValue(e, "expected to contain", "1"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
containsKey_failsWithSameToString
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void containsKey_failsWithNullStringAndNull() { Map<String, String> actual = new HashMap<>(); actual.put("null", "value1"); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).containsKey(null)); assertFailureKeys( e, "value of", "expected to contain", "an instance of", "but did not", "though it did contain", "full contents", "map was"); assertFailureValue(e, "value of", "map.keySet()"); assertFailureValue(e, "expected to contain", "null"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
containsKey_failsWithNullStringAndNull
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void containsNullKey() { Map<String, String> actual = new HashMap<>(); actual.put(null, "null"); assertThat(actual).containsKey(null); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
containsNullKey
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void doesNotContainKey() { ImmutableMap<String, String> actual = ImmutableMap.of("kurt", "kluever"); assertThat(actual).doesNotContainKey("greg"); assertThat(actual).doesNotContainKey(null); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
doesNotContainKey
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void doesNotContainKeyFailure() { ImmutableMap<String, String> actual = ImmutableMap.of("kurt", "kluever"); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).doesNotContainKey("kurt")); assertFailureKeys(e, "value of", "expected not to contain", "but was", "map was"); assertFailureValue(e, "value of", "map.keySet()"); assertFailureValue(e, "expected not to contain", "kurt"); assertFailureValue(e, "but was", "[kurt]"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
doesNotContainKeyFailure
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void doesNotContainNullKey() { Map<String, String> actual = new HashMap<>(); actual.put(null, "null"); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).doesNotContainKey(null)); assertFailureKeys(e, "value of", "expected not to contain", "but was", "map was"); assertFailureValue(e, "value of", "map.keySet()"); assertFailureValue(e, "expected not to contain", "null"); assertFailureValue(e, "but was", "[null]"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
doesNotContainNullKey
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void containsEntry() { ImmutableMap<String, String> actual = ImmutableMap.of("kurt", "kluever"); assertThat(actual).containsEntry("kurt", "kluever"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
containsEntry
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test /* * This test is all about reference equality, so we do want a new String instance. * * (Alternatively, we could perform the test with a type other than String. That would still have * been enough to demonstrate that the test failed before my change to MapSubject. However, it * would have demonstrated only a *very* terrible failure message, as opposed to the *extremely* * terrible failure message that a user reported.) */ @SuppressWarnings("StringCopy") public void containsEntryInIdentityHashMapWithNonIdenticalValue() { IdentityHashMap<String, String> actual = new IdentityHashMap<>(); actual.put("kurt", "kluever"); assertThat(actual).containsEntry("kurt", new String("kluever")); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
containsEntryInIdentityHashMapWithNonIdenticalValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void containsEntryFailure() { ImmutableMap<String, String> actual = ImmutableMap.of("kurt", "kluever"); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).containsEntry("greg", "kick")); assertFailureKeys(e, "expected to contain entry", "but was"); assertFailureValue(e, "expected to contain entry", "greg=kick"); assertFailureValue(e, "but was", "{kurt=kluever}"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
containsEntryFailure
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void containsEntry_failsWithSameToStringOfKey() { AssertionError e = expectFailure( whenTesting -> whenTesting .that(ImmutableMap.of(1L, "value1", 2L, "value2")) .containsEntry(1, "value1")); assertFailureKeys( e, "expected to contain entry", "an instance of", "but did not", "though it did contain keys", "full contents"); assertFailureValue(e, "an instance of", "Map.Entry<java.lang.Integer, java.lang.String>"); assertFailureValue(e, "though it did contain keys", "[1] (java.lang.Long)"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
containsEntry_failsWithSameToStringOfKey
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void containsEntry_failsWithSameToStringOfValue() { // Does not contain the correct key, but does contain a value which matches by toString. AssertionError e = expectFailure( whenTesting -> whenTesting.that(ImmutableMap.of(1, "null")).containsEntry(2, null)); assertFailureKeys( e, "expected to contain entry", "an instance of", "but did not", "though it did contain values", "full contents"); assertFailureValue(e, "an instance of", "Map.Entry<java.lang.Integer, null type>"); assertFailureValue(e, "though it did contain values", "[null] (java.lang.String)"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
containsEntry_failsWithSameToStringOfValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void containsNullKeyAndValue() { ImmutableMap<String, String> actual = ImmutableMap.of("kurt", "kluever"); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).containsEntry(null, null)); assertFailureKeys(e, "expected to contain entry", "but was"); assertFailureValue(e, "expected to contain entry", "null=null"); assertFailureValue(e, "but was", "{kurt=kluever}"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
containsNullKeyAndValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void containsNullEntry() { Map<String, String> actual = new HashMap<>(); actual.put(null, null); assertThat(actual).containsEntry(null, null); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
containsNullEntry
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void containsNullEntryValue() { Map<String, String> actual = new HashMap<>(); actual.put(null, null); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).containsEntry("kurt", null)); assertFailureKeys( e, "expected to contain entry", "but did not", "though it did contain keys with that value", "full contents"); assertFailureValue(e, "expected to contain entry", "kurt=null"); assertFailureValue(e, "though it did contain keys with that value", "[null]"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
containsNullEntryValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void containsNullEntryKey() { Map<String, String> actual = new HashMap<>(); actual.put(null, null); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).containsEntry(null, "kluever")); assertFailureValue(e, "value of", "map.get(null)"); assertFailureValue(e, "expected", "kluever"); assertFailureValue(e, "but was", "null"); assertFailureValue(e, "map was", "{null=null}"); assertThat(e).hasMessageThat().contains(KEY_IS_PRESENT_WITH_DIFFERENT_VALUE); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
containsNullEntryKey
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void containsExactly_bothExactAndToStringKeyMatches_showsExactKeyMatch() { ImmutableMap<Number, String> actual = ImmutableMap.of(1, "actual int", 1L, "actual long"); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).containsEntry(1L, "expected long")); // should show the exact key match, 1="actual int", not the toString key match, 1L="actual long" assertFailureKeys(e, "value of", "expected", "but was", "map was"); assertFailureValue(e, "value of", "map.get(1)"); assertFailureValue(e, "expected", "expected long"); assertFailureValue(e, "but was", "actual long"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
containsExactly_bothExactAndToStringKeyMatches_showsExactKeyMatch
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void doesNotContainEntry() { ImmutableMap<String, String> actual = ImmutableMap.of("kurt", "kluever"); assertThat(actual).doesNotContainEntry("greg", "kick"); assertThat(actual).doesNotContainEntry(null, null); assertThat(actual).doesNotContainEntry("kurt", null); assertThat(actual).doesNotContainEntry(null, "kluever"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
doesNotContainEntry
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void doesNotContainEntryFailure() { ImmutableMap<String, String> actual = ImmutableMap.of("kurt", "kluever"); AssertionError e = expectFailure( whenTesting -> whenTesting.that(actual).doesNotContainEntry("kurt", "kluever")); assertFailureKeys(e, "value of", "expected not to contain", "but was"); assertFailureValue(e, "value of", "map.entrySet()"); assertFailureValue(e, "expected not to contain", "kurt=kluever"); assertFailureValue(e, "but was", "[kurt=kluever]"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
doesNotContainEntryFailure
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void doesNotContainNullEntry() { Map<String, String> actual = new HashMap<>(); actual.put(null, null); assertThat(actual).doesNotContainEntry("kurt", null); assertThat(actual).doesNotContainEntry(null, "kluever"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
doesNotContainNullEntry
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void doesNotContainNullEntryFailure() { Map<String, String> actual = new HashMap<>(); actual.put(null, null); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).doesNotContainEntry(null, null)); assertFailureKeys(e, "value of", "expected not to contain", "but was"); assertFailureValue(e, "value of", "map.entrySet()"); assertFailureValue(e, "expected not to contain", "null=null"); assertFailureValue(e, "but was", "[null=null]"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
doesNotContainNullEntryFailure
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void failMapContainsKey() { ImmutableMap<String, String> actual = ImmutableMap.of("a", "A"); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).containsKey("b")); assertFailureKeys(e, "value of", "expected to contain", "but was", "map was"); assertFailureValue(e, "value of", "map.keySet()"); assertFailureValue(e, "expected to contain", "b"); assertFailureValue(e, "but was", "[a]"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
failMapContainsKey
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void failMapContainsKeyWithNull() { ImmutableMap<String, String> actual = ImmutableMap.of("a", "A"); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).containsKey(null)); assertFailureKeys(e, "value of", "expected to contain", "but was", "map was"); assertFailureValue(e, "value of", "map.keySet()"); assertFailureValue(e, "expected to contain", "null"); assertFailureValue(e, "but was", "[a]"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
failMapContainsKeyWithNull
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void failMapLacksKey() { ImmutableMap<String, String> actual = ImmutableMap.of("a", "A"); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).doesNotContainKey("a")); assertFailureKeys(e, "value of", "expected not to contain", "but was", "map was"); assertFailureValue(e, "value of", "map.keySet()"); assertFailureValue(e, "expected not to contain", "a"); assertFailureValue(e, "but was", "[a]"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
failMapLacksKey
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void containsKeyWithValue() { ImmutableMap<String, String> actual = ImmutableMap.of("a", "A"); assertThat(actual).containsEntry("a", "A"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
containsKeyWithValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void containsKeyWithNullValueNullExpected() { Map<String, String> actual = new HashMap<>(); actual.put("a", null); assertThat(actual).containsEntry("a", null); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
containsKeyWithNullValueNullExpected
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void failMapContainsKeyWithValue() { ImmutableMap<String, String> actual = ImmutableMap.of("a", "A"); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).containsEntry("a", "a")); assertFailureValue(e, "value of", "map.get(a)"); assertFailureValue(e, "expected", "a"); assertFailureValue(e, "but was", "A"); assertFailureValue(e, "map was", "{a=A}"); assertThat(e).hasMessageThat().doesNotContain(KEY_IS_PRESENT_WITH_DIFFERENT_VALUE); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
failMapContainsKeyWithValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void failMapContainsKeyWithNullValuePresentExpected() { Map<String, String> actual = new HashMap<>(); actual.put("a", null); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).containsEntry("a", "A")); assertFailureValue(e, "value of", "map.get(a)"); assertFailureValue(e, "expected", "A"); assertFailureValue(e, "but was", "null"); assertFailureValue(e, "map was", "{a=null}"); assertThat(e).hasMessageThat().contains(KEY_IS_PRESENT_WITH_DIFFERENT_VALUE); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
failMapContainsKeyWithNullValuePresentExpected
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void failMapContainsKeyWithPresentValueNullExpected() { ImmutableMap<String, String> actual = ImmutableMap.of("a", "A"); AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).containsEntry("a", null)); assertFailureValue(e, "value of", "map.get(a)"); assertFailureValue(e, "expected", "null"); assertFailureValue(e, "but was", "A"); assertFailureValue(e, "map was", "{a=A}"); assertThat(e).hasMessageThat().contains(KEY_IS_PRESENT_WITH_DIFFERENT_VALUE); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
failMapContainsKeyWithPresentValueNullExpected
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsEntry_success() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); assertThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsEntry("def", 456); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsEntry_success
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsEntry_failsExpectedKeyHasWrongValue() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "+123", "def", "+456"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsEntry("def", 123)); assertFailureKeys( e, "for key", "expected value", "testing whether", "but got value", "full map"); assertFailureValue(e, "for key", "def"); assertFailureValue(e, "expected value", "123"); assertFailureValue(e, "testing whether", "actual value parses to expected value"); assertFailureValue(e, "but got value", "+456"); assertFailureValue(e, "full map", "{abc=+123, def=+456}"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsEntry_failsExpectedKeyHasWrongValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsEntry_failsWrongKeyHasExpectedValue() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "+123", "def", "+456"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsEntry("xyz", 456)); assertFailureKeys( e, "for key", "expected value", "testing whether", "but was missing", "other keys with matching values", "full map"); assertFailureValue(e, "other keys with matching values", "[def]"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsEntry_failsWrongKeyHasExpectedValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsEntry_failsMissingExpectedKeyAndValue() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "+123", "def", "+456"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsEntry("xyz", 321)); assertFailureKeys( e, "for key", "expected value", "testing whether", "but was missing", "full map"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsEntry_failsMissingExpectedKeyAndValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsEntry_diffExpectedKeyHasWrongValue() { ImmutableMap<String, Integer> actual = ImmutableMap.of("abc", 35, "def", 71); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(WITHIN_10_OF) .containsEntry("def", 60)); assertFailureKeys( e, "for key", "expected value", "testing whether", "but got value", "diff", "full map"); assertFailureValue(e, "for key", "def"); assertFailureValue(e, "expected value", "60"); assertFailureValue(e, "but got value", "71"); assertFailureValue(e, "diff", "11"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsEntry_diffExpectedKeyHasWrongValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsEntry_handlesFormatDiffExceptions() { Map<String, Integer> actual = new LinkedHashMap<>(); actual.put("abc", 35); actual.put("def", null); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(WITHIN_10_OF) .containsEntry("def", 60)); assertFailureKeys( e, "for key", "expected value", "testing whether", "but got value", "full map", "additionally, one or more exceptions were thrown while comparing values", "first exception", "additionally, one or more exceptions were thrown while formatting diffs", "first exception"); assertThat(e) .factValue("first exception", 0) .startsWith( "compare(null, 60) threw" + " com.google.common.truth.TestCorrespondences$NullPointerExceptionFromWithin10Of"); assertThat(e) .factValue("first exception", 1) .startsWith("formatDiff(null, 60) threw java.lang.NullPointerException"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsEntry_handlesFormatDiffExceptions
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsEntry_handlesExceptions_expectedKeyHasWrongValue() { Map<Integer, String> actual = new LinkedHashMap<>(); actual.put(1, "one"); actual.put(2, null); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(CASE_INSENSITIVE_EQUALITY) .containsEntry(2, "TWO")); // The test fails because the expected key has a null value which causes compare() to throw. // We should report that the key has the wrong value, and also that we saw an exception. assertFailureKeys( e, "for key", "expected value", "testing whether", "but got value", "full map", "additionally, one or more exceptions were thrown while comparing values", "first exception"); assertThat(e) .factValue("first exception") .startsWith("compare(null, TWO) threw java.lang.NullPointerException"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsEntry_handlesExceptions_expectedKeyHasWrongValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsEntry_handlesExceptions_wrongKeyHasExpectedValue() { Map<Integer, String> actual = new LinkedHashMap<>(); actual.put(1, null); actual.put(2, "three"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(CASE_INSENSITIVE_EQUALITY) .containsEntry(3, "THREE")); // The test fails and does not contain the expected key, but does contain the expected value for // a different key. No reasonable implementation would find this value in the second entry // without hitting the exception from trying the first entry (which has a null value), so we // should report the exception as well. assertFailureKeys( e, "for key", "expected value", "testing whether", "but was missing", "other keys with matching values", "full map", "additionally, one or more exceptions were thrown while comparing values", "first exception"); assertThat(e) .factValue("first exception") .startsWith("compare(null, THREE) threw java.lang.NullPointerException"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsEntry_handlesExceptions_wrongKeyHasExpectedValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_doesNotContainEntry_successExcludedKeyHasWrongValues() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "+123", "def", "+456"); assertThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .doesNotContainEntry("def", 123); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_doesNotContainEntry_successExcludedKeyHasWrongValues
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_doesNotContainEntry_successWrongKeyHasExcludedValue() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "+123", "def", "+456"); assertThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .doesNotContainEntry("xyz", 456); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_doesNotContainEntry_successWrongKeyHasExcludedValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_doesNotContainEntry_successMissingExcludedKeyAndValue() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); assertThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .doesNotContainEntry("xyz", 321); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_doesNotContainEntry_successMissingExcludedKeyAndValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_doesNotContainEntry_failure() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "+123", "def", "+456"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .doesNotContainEntry("def", 456)); assertFailureKeys(e, "expected not to contain", "testing whether", "but contained", "full map"); assertFailureValue(e, "expected not to contain", "def=456"); assertFailureValue(e, "but contained", "def=+456"); assertFailureValue(e, "full map", "{abc=+123, def=+456}"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_doesNotContainEntry_failure
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_doesNotContainEntry_handlesException() { Map<Integer, String> actual = new LinkedHashMap<>(); actual.put(1, "one"); actual.put(2, null); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(CASE_INSENSITIVE_EQUALITY) .doesNotContainEntry(2, "TWO")); // This test would pass if compare(null, "TWO") returned false. But it actually throws, so the // test must fail. assertFailureKeys( e, "one or more exceptions were thrown while comparing values", "first exception", "expected not to contain", "testing whether", "found no match (but failing because of exception)", "full map"); assertThat(e) .factValue("first exception") .startsWith("compare(null, TWO) threw java.lang.NullPointerException"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_doesNotContainEntry_handlesException
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactly_success() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); assertThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactly("def", 456, "abc", 123); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactly_success
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactly_inOrder_success() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); assertThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactly("abc", 123, "def", 456) .inOrder(); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactly_inOrder_success
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactly_failsExtraEntry() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactly("def", 456)); assertFailureKeys( e, "unexpected keys", "for key", "unexpected value", "---", "expected", "testing whether", "but was"); assertFailureValue(e, "for key", "abc"); assertFailureValue(e, "unexpected value", "123"); assertFailureValue(e, "expected", "{def=456}"); assertFailureValue(e, "testing whether", "actual value parses to expected value"); assertFailureValue(e, "but was", "{abc=123, def=456}"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactly_failsExtraEntry
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactly_failsMissingEntry() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactly("def", 456, "xyz", 999, "abc", 123)); assertFailureKeys( e, "missing keys", "for key", "expected value", "---", "expected", "testing whether", "but was"); assertFailureValue(e, "for key", "xyz"); assertFailureValue(e, "expected value", "999"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactly_failsMissingEntry
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactly_failsWrongKey() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactly("def", 456, "cab", 123)); assertFailureKeys( e, "missing keys", "for key", "expected value", "unexpected keys", "for key", "unexpected value", "---", "expected", "testing whether", "but was"); assertFailureValueIndexed(e, "for key", 0, "cab"); assertFailureValue(e, "expected value", "123"); assertFailureValueIndexed(e, "for key", 1, "abc"); assertFailureValue(e, "unexpected value", "123"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactly_failsWrongKey
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactly_failsWrongValue() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactly("def", 456, "abc", 321)); assertFailureKeys( e, "keys with wrong values", "for key", "expected value", "but got value", "---", "expected", "testing whether", "but was"); assertFailureValue(e, "for key", "abc"); assertFailureValue(e, "expected value", "321"); assertFailureValue(e, "but got value", "123"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactly_failsWrongValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactly_handlesExceptions() { Map<Integer, String> actual = new LinkedHashMap<>(); actual.put(1, "one"); actual.put(2, null); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(CASE_INSENSITIVE_EQUALITY) .containsExactly(1, "ONE", 2, "TWO")); assertFailureKeys( e, "keys with wrong values", "for key", "expected value", "but got value", "---", "expected", "testing whether", "but was", "additionally, one or more exceptions were thrown while comparing values", "first exception"); assertThat(e) .factValue("first exception") .startsWith("compare(null, TWO) threw java.lang.NullPointerException"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactly_handlesExceptions
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactly_inOrder_failsOutOfOrder() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactly("def", 456, "abc", 123) .inOrder()); assertFailureKeys( e, "entries match, but order was wrong", "expected", "testing whether", "but was"); assertFailureValue(e, "expected", "{def=456, abc=123}"); assertFailureValue(e, "but was", "{abc=123, def=456}"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactly_inOrder_failsOutOfOrder
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactly_wrongValueTypeInActual() { ImmutableMap<String, Object> actual = ImmutableMap.<String, Object>of("abc", "123", "def", 456); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactly("def", 456, "abc", 123)); assertFailureKeys( e, "keys with wrong values", "for key", "expected value", "but got value", "---", "expected", "testing whether", "but was", "additionally, one or more exceptions were thrown while comparing values", "first exception"); assertThat(e) .factValue("first exception") .startsWith("compare(456, 456) threw java.lang.ClassCastException"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactly_wrongValueTypeInActual
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactly_wrongValueTypeInExpected() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactly("def", 456, "abc", 123L)); assertFailureKeys( e, "keys with wrong values", "for key", "expected value", "but got value", "---", "expected", "testing whether", "but was", "additionally, one or more exceptions were thrown while comparing values", "first exception"); assertThat(e) .factValue("first exception") .startsWith("compare(123, 123) threw java.lang.ClassCastException"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactly_wrongValueTypeInExpected
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactlyEntriesIn_success() { ImmutableMap<String, Integer> expected = ImmutableMap.of("def", 456, "abc", 123); ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); assertThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactlyEntriesIn(expected); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactlyEntriesIn_success
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactlyEntriesIn_inOrder_success() { ImmutableMap<String, Integer> expected = ImmutableMap.of("abc", 123, "def", 456); ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); assertThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactlyEntriesIn(expected) .inOrder(); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactlyEntriesIn_inOrder_success
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactlyEntriesIn_failsExtraEntry() { ImmutableMap<String, Integer> expected = ImmutableMap.of("def", 456); ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactlyEntriesIn(expected)); assertFailureKeys( e, "unexpected keys", "for key", "unexpected value", "---", "expected", "testing whether", "but was"); assertFailureValue(e, "for key", "abc"); assertFailureValue(e, "unexpected value", "123"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactlyEntriesIn_failsExtraEntry
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactlyEntriesIn_failsMissingEntry() { ImmutableMap<String, Integer> expected = ImmutableMap.of("def", 456, "xyz", 999, "abc", 123); ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactlyEntriesIn(expected)); assertFailureKeys( e, "missing keys", "for key", "expected value", "---", "expected", "testing whether", "but was"); assertFailureValue(e, "for key", "xyz"); assertFailureValue(e, "expected value", "999"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactlyEntriesIn_failsMissingEntry
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactlyEntriesIn_failsWrongKey() { ImmutableMap<String, Integer> expected = ImmutableMap.of("def", 456, "cab", 123); ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactlyEntriesIn(expected)); assertFailureKeys( e, "missing keys", "for key", "expected value", "unexpected keys", "for key", "unexpected value", "---", "expected", "testing whether", "but was"); assertFailureValueIndexed(e, "for key", 0, "cab"); assertFailureValue(e, "expected value", "123"); assertFailureValueIndexed(e, "for key", 1, "abc"); assertFailureValue(e, "unexpected value", "123"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactlyEntriesIn_failsWrongKey
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactlyEntriesIn_failsWrongValue() { ImmutableMap<String, Integer> expected = ImmutableMap.of("def", 456, "abc", 321); ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactlyEntriesIn(expected)); assertFailureKeys( e, "keys with wrong values", "for key", "expected value", "but got value", "---", "expected", "testing whether", "but was"); assertFailureValue(e, "for key", "abc"); assertFailureValue(e, "expected value", "321"); assertFailureValue(e, "but got value", "123"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactlyEntriesIn_failsWrongValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactlyEntriesIn_diffMissingAndExtraAndWrongValue() { ImmutableMap<String, Integer> expected = ImmutableMap.of("abc", 30, "def", 60, "ghi", 90); ImmutableMap<String, Integer> actual = ImmutableMap.of("abc", 35, "fed", 60, "ghi", 101); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(WITHIN_10_OF) .containsExactlyEntriesIn(expected)); assertFailureKeys( e, "keys with wrong values", "for key", "expected value", "but got value", "diff", "missing keys", "for key", "expected value", "unexpected keys", "for key", "unexpected value", "---", "expected", "testing whether", "but was"); assertFailureValueIndexed(e, "for key", 0, "ghi"); assertFailureValueIndexed(e, "expected value", 0, "90"); assertFailureValue(e, "but got value", "101"); assertFailureValue(e, "diff", "11"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactlyEntriesIn_diffMissingAndExtraAndWrongValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactlyEntriesIn_handlesFormatDiffExceptions() { ImmutableMap<String, Integer> expected = ImmutableMap.of("abc", 30, "def", 60, "ghi", 90); Map<String, Integer> actual = new LinkedHashMap<>(); actual.put("abc", 35); actual.put("def", null); actual.put("ghi", 95); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(WITHIN_10_OF) .containsExactlyEntriesIn(expected)); assertFailureKeys( e, "keys with wrong values", "for key", "expected value", "but got value", "---", "expected", "testing whether", "but was", "additionally, one or more exceptions were thrown while comparing values", "first exception", "additionally, one or more exceptions were thrown while formatting diffs", "first exception"); assertThat(e) .factValue("first exception", 0) .startsWith( "compare(null, 60) threw" + " com.google.common.truth.TestCorrespondences$NullPointerExceptionFromWithin10Of"); assertThat(e) .factValue("first exception", 1) .startsWith("formatDiff(null, 60) threw java.lang.NullPointerException"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactlyEntriesIn_handlesFormatDiffExceptions
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactlyEntriesIn_inOrder_failsOutOfOrder() { ImmutableMap<String, Integer> expected = ImmutableMap.of("def", 456, "abc", 123); ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactlyEntriesIn(expected) .inOrder()); assertFailureKeys( e, "entries match, but order was wrong", "expected", "testing whether", "but was"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactlyEntriesIn_inOrder_failsOutOfOrder
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactlyEntriesIn_empty() { ImmutableMap<String, Integer> expected = ImmutableMap.of(); ImmutableMap<String, String> actual = ImmutableMap.of(); assertThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactlyEntriesIn(expected); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactlyEntriesIn_empty
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactlyEntriesIn_failsEmpty() { ImmutableMap<String, Integer> expected = ImmutableMap.of(); ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactlyEntriesIn(expected)); assertFailureKeys(e, "expected to be empty", "but was"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactlyEntriesIn_failsEmpty
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsExactlyEntriesIn_wrongValueTypeInActual() { ImmutableMap<String, Integer> expected = ImmutableMap.of("def", 456, "abc", 123); ImmutableMap<String, Object> actual = ImmutableMap.<String, Object>of("abc", "123", "def", 456); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactlyEntriesIn(expected)); assertFailureKeys( e, "keys with wrong values", "for key", "expected value", "but got value", "---", "expected", "testing whether", "but was", "additionally, one or more exceptions were thrown while comparing values", "first exception"); assertThat(e) .factValue("first exception") .startsWith("compare(456, 456) threw java.lang.ClassCastException"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsExactlyEntriesIn_wrongValueTypeInActual
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsAtLeast_success() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456", "ghi", "789"); assertThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsAtLeast("def", 456, "abc", 123); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsAtLeast_success
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsAtLeast_inOrder_success() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "ghi", "789", "def", "456"); assertThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsAtLeast("abc", 123, "def", 456) .inOrder(); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsAtLeast_inOrder_success
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsAtLeast_failsMissingEntry() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456", "ghi", "789"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsAtLeast("def", 456, "xyz", 999, "abc", 123)); assertFailureKeys( e, "missing keys", "for key", "expected value", "---", "expected to contain at least", "testing whether", "but was"); assertFailureValue(e, "for key", "xyz"); assertFailureValue(e, "expected value", "999"); assertFailureValue(e, "expected to contain at least", "{def=456, xyz=999, abc=123}"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsAtLeast_failsMissingEntry
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsAtLeast_failsWrongKey() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsAtLeast("def", 456, "cab", 123)); assertFailureKeys( e, "missing keys", "for key", "expected value", "---", "expected to contain at least", "testing whether", "but was"); assertFailureValue(e, "for key", "cab"); assertFailureValue(e, "expected value", "123"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsAtLeast_failsWrongKey
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsAtLeast_failsWrongValue() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsAtLeast("abc", 321)); assertFailureKeys( e, "keys with wrong values", "for key", "expected value", "but got value", "---", "expected to contain at least", "testing whether", "but was"); assertFailureValue(e, "for key", "abc"); assertFailureValue(e, "expected value", "321"); assertFailureValue(e, "but got value", "123"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsAtLeast_failsWrongValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsAtLeast_handlesExceptions() { Map<Integer, String> actual = new LinkedHashMap<>(); actual.put(1, "one"); actual.put(2, null); actual.put(3, "three"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(CASE_INSENSITIVE_EQUALITY) .containsAtLeast(1, "ONE", 2, "TWO")); assertFailureKeys( e, "keys with wrong values", "for key", "expected value", "but got value", "---", "expected to contain at least", "testing whether", "but was", "additionally, one or more exceptions were thrown while comparing values", "first exception"); assertThat(e) .factValue("first exception") .startsWith("compare(null, TWO) threw java.lang.NullPointerException"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsAtLeast_handlesExceptions
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsAtLeast_inOrder_failsOutOfOrder() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456", "ghi", "789"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsAtLeast("def", 456, "abc", 123) .inOrder()); assertFailureKeys( e, "required entries were all found, but order was wrong", "expected to contain at least", "testing whether", "but was"); assertFailureValue(e, "expected to contain at least", "{def=456, abc=123}"); assertFailureValue(e, "but was", "{abc=123, def=456, ghi=789}"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsAtLeast_inOrder_failsOutOfOrder
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsAtLeast_wrongValueTypeInExpectedActual() { ImmutableMap<String, Object> actual = ImmutableMap.<String, Object>of("abc", "123", "def", 456); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsAtLeast("def", 456)); assertFailureKeys( e, "keys with wrong values", "for key", "expected value", "but got value", "---", "expected to contain at least", "testing whether", "but was", "additionally, one or more exceptions were thrown while comparing values", "first exception"); assertThat(e) .factValue("first exception") .startsWith("compare(456, 456) threw java.lang.ClassCastException"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsAtLeast_wrongValueTypeInExpectedActual
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsAtLeast_wrongValueTypeInUnexpectedActual_success() { ImmutableMap<String, Object> actual = ImmutableMap.<String, Object>of("abc", "123", "def", 456); assertThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsAtLeast("abc", 123); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsAtLeast_wrongValueTypeInUnexpectedActual_success
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsAtLeast_wrongValueTypeInExpected() { ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456", "ghi", "789"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsAtLeast("def", 456, "abc", 123L)); assertFailureKeys( e, "keys with wrong values", "for key", "expected value", "but got value", "---", "expected to contain at least", "testing whether", "but was", "additionally, one or more exceptions were thrown while comparing values", "first exception"); assertThat(e) .factValue("first exception") .startsWith("compare(123, 123) threw java.lang.ClassCastException"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsAtLeast_wrongValueTypeInExpected
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsAtLeastEntriesIn_success() { ImmutableMap<String, Integer> expected = ImmutableMap.of("def", 456, "abc", 123); ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456", "ghi", "789"); assertThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsAtLeastEntriesIn(expected); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsAtLeastEntriesIn_success
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsAtLeastEntriesIn_inOrder_success() { ImmutableMap<String, Integer> expected = ImmutableMap.of("abc", 123, "ghi", 789); ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456", "ghi", "789"); assertThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsAtLeastEntriesIn(expected) .inOrder(); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsAtLeastEntriesIn_inOrder_success
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsAtLeastEntriesIn_failsMissingEntry() { ImmutableMap<String, Integer> expected = ImmutableMap.of("def", 456, "xyz", 999, "abc", 123); ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456", "ghi", "789"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsAtLeastEntriesIn(expected)); assertFailureKeys( e, "missing keys", "for key", "expected value", "---", "expected to contain at least", "testing whether", "but was"); assertFailureValue(e, "for key", "xyz"); assertFailureValue(e, "expected value", "999"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsAtLeastEntriesIn_failsMissingEntry
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsAtLeastEntriesIn_failsWrongKey() { ImmutableMap<String, Integer> expected = ImmutableMap.of("def", 456, "cab", 123); ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsAtLeastEntriesIn(expected)); assertFailureKeys( e, "missing keys", "for key", "expected value", "---", "expected to contain at least", "testing whether", "but was"); assertFailureValue(e, "for key", "cab"); assertFailureValue(e, "expected value", "123"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsAtLeastEntriesIn_failsWrongKey
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsAtLeastEntriesIn_failsWrongValue() { ImmutableMap<String, Integer> expected = ImmutableMap.of("def", 456, "abc", 321); ImmutableMap<String, String> actual = ImmutableMap.of("abc", "123", "def", "456", "ghi", "789"); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsAtLeastEntriesIn(expected)); assertFailureKeys( e, "keys with wrong values", "for key", "expected value", "but got value", "---", "expected to contain at least", "testing whether", "but was"); assertFailureValue(e, "for key", "abc"); assertFailureValue(e, "expected value", "321"); assertFailureValue(e, "but got value", "123"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsAtLeastEntriesIn_failsWrongValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsAtLeastEntriesIn_diffMissingAndWrongValue() { ImmutableMap<String, Integer> expected = ImmutableMap.of("abc", 30, "def", 60, "ghi", 90); ImmutableMap<String, Integer> actual = ImmutableMap.of("abc", 35, "fed", 60, "ghi", 101); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(WITHIN_10_OF) .containsAtLeastEntriesIn(expected)); assertFailureKeys( e, "keys with wrong values", "for key", "expected value", "but got value", "diff", "missing keys", "for key", "expected value", "---", "expected to contain at least", "testing whether", "but was"); assertFailureValueIndexed(e, "for key", 0, "ghi"); assertFailureValueIndexed(e, "expected value", 0, "90"); assertFailureValue(e, "but got value", "101"); assertFailureValue(e, "diff", "11"); assertFailureValueIndexed(e, "for key", 1, "def"); assertFailureValueIndexed(e, "expected value", 1, "60"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsAtLeastEntriesIn_diffMissingAndWrongValue
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0
@Test public void comparingValuesUsing_containsAtLeastEntriesIn_handlesFormatDiffExceptions() { ImmutableMap<String, Integer> expected = ImmutableMap.of("abc", 30, "def", 60, "ghi", 90); Map<String, Integer> actual = new LinkedHashMap<>(); actual.put("abc", 35); actual.put("def", null); actual.put("ghi", 95); AssertionError e = expectFailure( whenTesting -> whenTesting .that(actual) .comparingValuesUsing(WITHIN_10_OF) .containsAtLeastEntriesIn(expected)); assertFailureKeys( e, "keys with wrong values", "for key", "expected value", "but got value", "---", "expected to contain at least", "testing whether", "but was", "additionally, one or more exceptions were thrown while comparing values", "first exception", "additionally, one or more exceptions were thrown while formatting diffs", "first exception"); assertThat(e) .factValue("first exception", 0) .startsWith( "compare(null, 60) threw" + " com.google.common.truth.TestCorrespondences$NullPointerExceptionFromWithin10Of"); assertThat(e) .factValue("first exception", 1) .startsWith("formatDiff(null, 60) threw java.lang.NullPointerException"); }
Tests for {@link Map} subjects. @author Christian Gruber @author Kurt Alfred Kluever
comparingValuesUsing_containsAtLeastEntriesIn_handlesFormatDiffExceptions
java
google/truth
core/src/test/java/com/google/common/truth/MapSubjectTest.java
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MapSubjectTest.java
Apache-2.0