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 comparingValuesUsing_doesNotContainEntry_successExcludeKeyHasWrongValues() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("abc", "+123", "def", "+456", "def", "+789");
assertThat(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.doesNotContainEntry("def", 123);
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_doesNotContainEntry_successExcludeKeyHasWrongValues
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_doesNotContainEntry_successWrongKeyHasExcludedValue() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("abc", "+123", "def", "+456", "def", "+789");
assertThat(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.doesNotContainEntry("xyz", 789);
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_doesNotContainEntry_successWrongKeyHasExcludedValue
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_doesNotContainEntry_successMissingExcludedKeyAndValue() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("abc", "+123", "def", "+456", "def", "+789");
assertThat(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.doesNotContainEntry("xyz", 321);
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_doesNotContainEntry_successMissingExcludedKeyAndValue
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_doesNotContainEntry_failure() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("abc", "+123", "def", "+456", "def", "+789");
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.doesNotContainEntry("def", 789));
assertFailureKeys(
e,
"expected not to contain entry",
"testing whether",
"but contained that key with matching values",
"full contents");
assertFailureValue(e, "expected not to contain entry", "def=789");
assertFailureValue(e, "testing whether", "actual value parses to expected value");
assertFailureValue(e, "but contained that key with matching values", "[+789]");
assertFailureValue(e, "full contents", "{abc=[+123], def=[+456, +789]}");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_doesNotContainEntry_failure
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_doesNotContainEntry_handlesException_didContainEntry() {
ListMultimap<Integer, String> actual = LinkedListMultimap.create();
actual.put(1, "one");
actual.put(2, "two");
actual.put(2, null);
actual.put(2, "zwei");
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(CASE_INSENSITIVE_EQUALITY)
.doesNotContainEntry(2, "ZWEI"));
// The test fails because it does contain the expected entry. We are bound to also hit the NPE
// from compare(null, ZWEI) along the way, and should also report that.
assertFailureKeys(
e,
"expected not to contain entry",
"testing whether",
"but contained that key with matching values",
"full contents",
"additionally, one or more exceptions were thrown while comparing values",
"first exception");
assertThat(e)
.factValue("first exception")
.startsWith("compare(null, ZWEI) threw java.lang.NullPointerException");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_doesNotContainEntry_handlesException_didContainEntry
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_doesNotContainEntry_handlesException_didNotContainEntry() {
ListMultimap<Integer, String> actual = LinkedListMultimap.create();
actual.put(1, "one");
actual.put(2, "two");
actual.put(2, "deux");
actual.put(2, null);
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(CASE_INSENSITIVE_EQUALITY)
.doesNotContainEntry(2, "ZWEI"));
// The test would pass if compare(null, ZWEI) returned false. But it actually throws NPE, and
// we are bound to hit that, so we are contractually required to fail.
assertFailureKeys(
e,
"one or more exceptions were thrown while comparing values",
"first exception",
"expected not to contain entry",
"testing whether",
"found no match (but failing because of exception)",
"full contents");
assertThat(e)
.factValue("first exception")
.startsWith("compare(null, ZWEI) threw java.lang.NullPointerException");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_doesNotContainEntry_handlesException_didNotContainEntry
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_doesNotContainEntry_wrongTypeInActual() {
ImmutableListMultimap<String, Object> actual =
ImmutableListMultimap.of("abc", "+123", "def", "+456", "def", 789);
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.doesNotContainEntry("def", 789));
assertFailureKeys(
e,
"one or more exceptions were thrown while comparing values",
"first exception",
"expected not to contain entry",
"testing whether",
"found no match (but failing because of exception)",
"full contents");
assertThat(e)
.factValue("first exception")
.startsWith("compare(789, 789) threw java.lang.ClassCastException");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_doesNotContainEntry_wrongTypeInActual
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactlyEntriesIn_success() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("abc", "+123", "def", "+64", "def", "0x40", "def", "+128");
ImmutableListMultimap<String, Integer> expected =
ImmutableListMultimap.of("def", 64, "def", 128, "def", 64, "abc", 123);
assertThat(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactlyEntriesIn(expected);
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactlyEntriesIn_success
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactlyEntriesIn_missingKey() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("def", "+64", "def", "0x40", "def", "+128");
ImmutableListMultimap<String, Integer> expected =
ImmutableListMultimap.of("def", 64, "def", 128, "def", 64, "abc", 123);
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactlyEntriesIn(expected));
assertFailureKeys(e, "missing (1)", "---", "expected", "testing whether", "but was");
assertFailureValue(e, "missing (1)", "abc=123");
// TODO(b/69154276): Address the fact that we show "expected" as a list of entries and "but was"
// as a multimap, which looks a bit odd.
assertFailureValue(e, "expected", "[def=64, def=128, def=64, abc=123]");
assertFailureValue(
e,
"testing whether",
"actual element has a key that is equal to and a value that parses to the key and value of"
+ " expected element");
assertFailureValue(e, "but was", "{def=[+64, 0x40, +128]}");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactlyEntriesIn_missingKey
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactlyEntriesIn_extraKey() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("abc", "+123", "def", "+64", "def", "0x40", "def", "+128");
ImmutableListMultimap<String, Integer> expected =
ImmutableListMultimap.of("def", 64, "def", 128, "def", 64);
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactlyEntriesIn(expected));
assertFailureKeys(e, "unexpected (1)", "---", "expected", "testing whether", "but was");
assertFailureValue(e, "unexpected (1)", "abc=+123");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactlyEntriesIn_extraKey
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactlyEntriesIn_wrongValueForKey() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("abc", "+123", "def", "+64", "def", "0x40", "def", "+128");
ImmutableListMultimap<String, Integer> expected =
ImmutableListMultimap.of("def", 64, "def", 128, "def", 128, "abc", 123);
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactlyEntriesIn(expected));
assertFailureKeys(
e,
"in an assertion requiring a 1:1 mapping between the expected and the actual elements,"
+ " each actual element matches as least one expected element, and vice versa, but"
+ " there was no 1:1 mapping",
"using the most complete 1:1 mapping (or one such mapping, if there is a tie)",
"missing (1)",
"unexpected (1)",
"---",
"expected",
"testing whether",
"but was");
assertFailureValue(e, "missing (1)", "def=128");
assertThat(e).factValue("unexpected (1)").isAnyOf("[def=+64]", "[def=0x40]");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactlyEntriesIn_wrongValueForKey
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactlyEntriesIn_handlesException() {
ListMultimap<Integer, String> actual = LinkedListMultimap.create();
actual.put(1, "one");
actual.put(2, null);
actual.put(2, "deux");
actual.put(2, "zwei");
ImmutableListMultimap<Integer, String> expected =
ImmutableListMultimap.of(1, "ONE", 2, "TWO", 2, "DEUX", 2, "ZWEI");
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(CASE_INSENSITIVE_EQUALITY)
.containsExactlyEntriesIn(expected));
assertFailureKeys(
e,
"missing (1)",
"unexpected (1)",
"---",
"expected",
"testing whether",
"but was",
"additionally, one or more exceptions were thrown while comparing elements",
"first exception");
assertFailureValue(e, "missing (1)", "2=TWO");
assertFailureValue(e, "unexpected (1)", "[2=null]");
assertThat(e)
.factValue("first exception")
.startsWith("compare(2=null, 2=TWO) threw java.lang.NullPointerException");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactlyEntriesIn_handlesException
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactlyEntriesIn_handlesException_alwaysFails() {
ListMultimap<Integer, String> actual = LinkedListMultimap.create();
actual.put(1, "one");
actual.put(2, null);
actual.put(2, "two");
actual.put(2, "deux");
ListMultimap<Integer, String> expected = LinkedListMultimap.create();
expected.put(1, "ONE");
expected.put(2, "TWO");
expected.put(2, "DEUX");
expected.put(2, null);
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(CASE_INSENSITIVE_EQUALITY_HALF_NULL_SAFE)
.containsExactlyEntriesIn(expected));
// CASE_INSENSITIVE_EQUALITY_HALF_NULL_SAFE.compare(null, null) returns true, so there is a
// mapping between actual and expected entries where they all correspond. However, no
// reasonable implementation would find that mapping without hitting the (null, "TWO") case
// along the way, and that throws NPE, so we are contractually required to fail.
assertFailureKeys(
e,
"one or more exceptions were thrown while comparing elements",
"first exception",
"expected",
"testing whether",
"found all expected elements (but failing because of exception)",
"full contents");
assertThat(e)
.factValue("first exception")
.startsWith("compare(2=null, 2=TWO) threw java.lang.NullPointerException");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactlyEntriesIn_handlesException_alwaysFails
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactlyEntriesIn_wrongTypeInActual() {
ImmutableListMultimap<String, Object> actual =
ImmutableListMultimap.<String, Object>of(
"abc", "+123", "def", "+64", "def", "0x40", "def", 999);
ImmutableListMultimap<String, Integer> expected =
ImmutableListMultimap.of("def", 64, "def", 123, "def", 64, "abc", 123);
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactlyEntriesIn(expected));
assertFailureKeys(
e,
"missing (1)",
"unexpected (1)",
"---",
"expected",
"testing whether",
"but was",
"additionally, one or more exceptions were thrown while comparing elements",
"first exception");
assertFailureValue(e, "missing (1)", "def=123");
assertFailureValue(e, "unexpected (1)", "[def=999]");
assertThat(e)
.factValue("first exception")
.startsWith("compare(def=999, def=64) threw java.lang.ClassCastException");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactlyEntriesIn_wrongTypeInActual
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactlyEntriesIn_inOrder_success() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("abc", "+123", "def", "+64", "def", "0x40", "def", "+128");
ImmutableListMultimap<String, Integer> expected =
ImmutableListMultimap.of("abc", 123, "def", 64, "def", 64, "def", 128);
assertThat(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactlyEntriesIn(expected);
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactlyEntriesIn_inOrder_success
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactlyEntriesIn_inOrder_wrongKeyOrder() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("abc", "+123", "def", "+64", "def", "0x40", "def", "+128");
ImmutableListMultimap<String, Integer> expected =
ImmutableListMultimap.of("def", 64, "def", 64, "def", 128, "abc", 123);
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactlyEntriesIn(expected)
.inOrder());
assertFailureKeys(
e, "contents match, but order was wrong", "expected", "testing whether", "but was");
assertFailureValue(e, "expected", "[def=64, def=64, def=128, abc=123]");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactlyEntriesIn_inOrder_wrongKeyOrder
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactlyEntriesIn_inOrder_wrongValueOrder() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("abc", "+123", "def", "+64", "def", "0x40", "def", "+128");
ImmutableListMultimap<String, Integer> expected =
ImmutableListMultimap.of("abc", 123, "def", 64, "def", 128, "def", 64);
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactlyEntriesIn(expected)
.inOrder());
assertFailureKeys(
e, "contents match, but order was wrong", "expected", "testing whether", "but was");
assertFailureValue(e, "expected", "[abc=123, def=64, def=128, def=64]");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactlyEntriesIn_inOrder_wrongValueOrder
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactlyNoArgs() {
ImmutableListMultimap<String, String> actual = ImmutableListMultimap.of();
assertThat(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactly();
assertThat(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactly()
.inOrder();
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(ImmutableListMultimap.of("abc", "+123"))
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactly());
assertFailureKeys(e, "expected to be empty", "but was");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactlyNoArgs
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactly_success() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("abc", "+123", "def", "+64", "def", "0x40", "def", "+128");
assertThat(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactly("def", 64, "def", 128, "def", 64, "abc", 123);
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactly_success
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactly_missingKey() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("def", "+64", "def", "0x40", "def", "+128");
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactly("def", 64, "def", 128, "def", 64, "abc", 123));
assertFailureKeys(e, "missing (1)", "---", "expected", "testing whether", "but was");
assertFailureValue(e, "missing (1)", "abc=123");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactly_missingKey
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactly_extraKey() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("abc", "+123", "def", "+64", "def", "0x40", "def", "+128");
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactly("def", 64, "def", 128, "def", 64));
assertFailureKeys(e, "unexpected (1)", "---", "expected", "testing whether", "but was");
assertFailureValue(e, "unexpected (1)", "abc=+123");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactly_extraKey
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactly_wrongValueForKey() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("abc", "+123", "def", "+64", "def", "0x40", "def", "+128");
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactly("def", 64, "def", 128, "def", 128, "abc", 123));
assertFailureKeys(
e,
"in an assertion requiring a 1:1 mapping between the expected and the actual elements,"
+ " each actual element matches as least one expected element, and vice versa, but"
+ " there was no 1:1 mapping",
"using the most complete 1:1 mapping (or one such mapping, if there is a tie)",
"missing (1)",
"unexpected (1)",
"---",
"expected",
"testing whether",
"but was");
assertFailureValue(e, "missing (1)", "def=128");
assertThat(e).factValue("unexpected (1)").isAnyOf("[def=+64]", "[def=0x40]");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactly_wrongValueForKey
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactly_wrongTypeInActual() {
ImmutableListMultimap<String, Object> actual =
ImmutableListMultimap.<String, Object>of(
"abc", "+123", "def", "+64", "def", "0x40", "def", 999);
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactly("def", 64, "def", 123, "def", 64, "abc", 123));
assertFailureKeys(
e,
"missing (1)",
"unexpected (1)",
"---",
"expected",
"testing whether",
"but was",
"additionally, one or more exceptions were thrown while comparing elements",
"first exception");
assertFailureValue(e, "missing (1)", "def=123");
assertFailureValue(e, "unexpected (1)", "[def=999]");
assertThat(e)
.factValue("first exception")
.startsWith("compare(def=999, def=64) threw java.lang.ClassCastException");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactly_wrongTypeInActual
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactly_nullKey() {
ListMultimap<String, String> actual = ArrayListMultimap.create();
actual.put(null, "+123");
assertThat(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactly(null, 123);
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactly_nullKey
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactly_inOrder_success() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("abc", "+123", "def", "+64", "def", "0x40", "def", "+128");
assertThat(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactly("abc", 123, "def", 64, "def", 64, "def", 128);
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactly_inOrder_success
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactly_inOrder_wrongKeyOrder() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("abc", "+123", "def", "+64", "def", "0x40", "def", "+128");
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactly("def", 64, "def", 64, "def", 128, "abc", 123)
.inOrder());
assertFailureKeys(
e, "contents match, but order was wrong", "expected", "testing whether", "but was");
assertFailureValue(e, "expected", "[def=64, def=64, def=128, abc=123]");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactly_inOrder_wrongKeyOrder
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsExactly_inOrder_wrongValueOrder() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("abc", "+123", "def", "+64", "def", "0x40", "def", "+128");
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsExactly("abc", 123, "def", 64, "def", 128, "def", 64)
.inOrder());
assertFailureKeys(
e, "contents match, but order was wrong", "expected", "testing whether", "but was");
assertFailureValue(e, "expected", "[abc=123, def=64, def=128, def=64]");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsExactly_inOrder_wrongValueOrder
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsAtLeastEntriesIn_success() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("abc", "+123", "def", "+64", "def", "0x40", "def", "+128");
ImmutableListMultimap<String, Integer> expected =
ImmutableListMultimap.of("def", 64, "def", 128, "abc", 123);
assertThat(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsAtLeastEntriesIn(expected);
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsAtLeastEntriesIn_success
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsAtLeastEntriesIn_missingKey() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("def", "+64", "def", "0x40", "def", "+128", "abc", "+99");
ImmutableListMultimap<String, Integer> expected =
ImmutableListMultimap.of("def", 64, "def", 128, "def", 64, "abc", 123);
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsAtLeastEntriesIn(expected));
assertFailureKeys(
e, "missing (1)", "---", "expected to contain at least", "testing whether", "but was");
assertFailureValue(e, "missing (1)", "abc=123");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsAtLeastEntriesIn_missingKey
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsAtLeastEntriesIn_wrongValueForKey() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("abc", "+123", "def", "+64", "def", "0x40", "def", "+128");
ImmutableListMultimap<String, Integer> expected =
ImmutableListMultimap.of("def", 64, "def", 128, "def", 128, "abc", 123);
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsAtLeastEntriesIn(expected));
assertFailureKeys(
e,
"in an assertion requiring a 1:1 mapping between the expected and a subset of the actual"
+ " elements, each actual element matches as least one expected element, and vice"
+ " versa, but there was no 1:1 mapping",
"using the most complete 1:1 mapping (or one such mapping, if there is a tie)",
"missing (1)",
"---",
"expected to contain at least",
"testing whether",
"but was");
assertFailureValue(e, "missing (1)", "def=128");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsAtLeastEntriesIn_wrongValueForKey
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsAtLeastEntriesIn_handlesException() {
ListMultimap<Integer, String> actual = LinkedListMultimap.create();
actual.put(1, "one");
actual.put(2, null);
actual.put(2, "deux");
actual.put(2, "zwei");
ImmutableListMultimap<Integer, String> expected =
ImmutableListMultimap.of(1, "ONE", 2, "TWO", 2, "DEUX");
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(CASE_INSENSITIVE_EQUALITY)
.containsAtLeastEntriesIn(expected));
assertFailureKeys(
e,
"missing (1)",
"---",
"expected to contain at least",
"testing whether",
"but was",
"additionally, one or more exceptions were thrown while comparing elements",
"first exception");
assertFailureValue(e, "missing (1)", "2=TWO");
assertThat(e)
.factValue("first exception")
.startsWith("compare(2=null, 2=TWO) threw java.lang.NullPointerException");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsAtLeastEntriesIn_handlesException
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsAtLeastEntriesIn_handlesException_alwaysFails() {
ListMultimap<Integer, String> actual = LinkedListMultimap.create();
actual.put(1, "one");
actual.put(2, null);
actual.put(2, "two");
actual.put(2, "deux");
ListMultimap<Integer, String> expected = LinkedListMultimap.create();
expected.put(1, "ONE");
expected.put(2, "TWO");
expected.put(2, "DEUX");
expected.put(2, null);
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(CASE_INSENSITIVE_EQUALITY_HALF_NULL_SAFE)
.containsAtLeastEntriesIn(expected));
// CASE_INSENSITIVE_EQUALITY_HALF_NULL_SAFE.compare(null, null) returns true, so there is a
// mapping between actual and expected entries where they all correspond. However, no
// reasonable implementation would find that mapping without hitting the (null, "TWO") case
// along the way, and that throws NPE, so we are contractually required to fail.
assertFailureKeys(
e,
"one or more exceptions were thrown while comparing elements",
"first exception",
"expected to contain at least",
"testing whether",
"found all expected elements (but failing because of exception)",
"full contents");
assertThat(e)
.factValue("first exception")
.startsWith("compare(2=null, 2=TWO) threw java.lang.NullPointerException");
assertFailureValue(e, "expected to contain at least", "[1=ONE, 2=TWO, 2=DEUX, 2=null]");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsAtLeastEntriesIn_handlesException_alwaysFails
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsAtLeastEntriesIn_wrongTypeInActual() {
ImmutableListMultimap<String, Object> actual =
ImmutableListMultimap.<String, Object>of(
"abc", "+123", "def", "+64", "def", "0x40", "def", 999);
ImmutableListMultimap<String, Integer> expected =
ImmutableListMultimap.of("def", 64, "def", 123, "def", 64, "abc", 123);
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsAtLeastEntriesIn(expected));
assertFailureKeys(
e,
"missing (1)",
"---",
"expected to contain at least",
"testing whether",
"but was",
"additionally, one or more exceptions were thrown while comparing elements",
"first exception");
assertFailureValue(e, "missing (1)", "def=123");
assertThat(e)
.factValue("first exception")
.startsWith("compare(def=999, def=64) threw java.lang.ClassCastException");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsAtLeastEntriesIn_wrongTypeInActual
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsAtLeastEntriesIn_inOrder_success() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of(
"def", "+64", "abc", "+123", "def", "0x40", "m", "+1", "def", "+128");
ImmutableListMultimap<String, Integer> expected =
ImmutableListMultimap.of("def", 64, "def", 64, "def", 128, "abc", 123);
assertThat(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsAtLeastEntriesIn(expected);
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsAtLeastEntriesIn_inOrder_success
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsAtLeastEntriesIn_inOrder_wrongKeyOrder() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of(
"abc", "+123", "def", "+64", "m", "+1", "def", "0x40", "def", "+128");
ImmutableListMultimap<String, Integer> expected =
ImmutableListMultimap.of("def", 64, "def", 64, "def", 128, "abc", 123);
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsAtLeastEntriesIn(expected)
.inOrder());
assertFailureKeys(
e,
"required elements were all found, but order was wrong",
"expected order for required elements",
"testing whether",
"but was");
assertFailureValue(
e, "expected order for required elements", "[def=64, def=64, def=128, abc=123]");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsAtLeastEntriesIn_inOrder_wrongKeyOrder
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsAtLeastEntriesIn_inOrder_wrongValueOrder() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of(
"abc", "+123", "def", "+64", "m", "+1", "def", "0x40", "def", "+128");
ImmutableListMultimap<String, Integer> expected =
ImmutableListMultimap.of("abc", 123, "def", 64, "def", 128, "def", 64);
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsAtLeastEntriesIn(expected)
.inOrder());
assertFailureKeys(
e,
"required elements were all found, but order was wrong",
"expected order for required elements",
"testing whether",
"but was");
assertFailureValue(
e, "expected order for required elements", "[abc=123, def=64, def=128, def=64]");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsAtLeastEntriesIn_inOrder_wrongValueOrder
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsAtLeast_success() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of(
"abc", "+123", "def", "+64", "m", "+1", "def", "0x40", "def", "+128");
assertThat(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsAtLeast("def", 64, "def", 128, "def", 64, "abc", 123);
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsAtLeast_success
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsAtLeast_missingKey() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of("def", "+64", "def", "0x40", "m", "+1", "def", "+128");
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsAtLeast("def", 64, "def", 128, "def", 64, "abc", 123));
assertFailureKeys(
e, "missing (1)", "---", "expected to contain at least", "testing whether", "but was");
assertFailureValue(e, "missing (1)", "abc=123");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsAtLeast_missingKey
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsAtLeast_wrongValueForKey() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of(
"abc", "+123", "def", "+64", "m", "+1", "def", "0x40", "def", "+128");
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsAtLeast("def", 64, "def", 128, "def", 128, "abc", 123));
assertFailureKeys(
e,
"in an assertion requiring a 1:1 mapping between the expected and a subset of the actual"
+ " elements, each actual element matches as least one expected element, and vice"
+ " versa, but there was no 1:1 mapping",
"using the most complete 1:1 mapping (or one such mapping, if there is a tie)",
"missing (1)",
"---",
"expected to contain at least",
"testing whether",
"but was");
assertFailureValue(e, "missing (1)", "def=128");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsAtLeast_wrongValueForKey
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsAtLeast_wrongTypeInActual() {
ImmutableListMultimap<String, Object> actual =
ImmutableListMultimap.<String, Object>of(
"abc", "+123", "def", "+64", "def", "0x40", "def", 999, "m", "+1");
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsAtLeast("def", 64, "def", 123, "def", 64, "abc", 123));
assertFailureKeys(
e,
"missing (1)",
"---",
"expected to contain at least",
"testing whether",
"but was",
"additionally, one or more exceptions were thrown while comparing elements",
"first exception");
assertFailureValue(e, "missing (1)", "def=123");
assertThat(e)
.factValue("first exception")
.startsWith("compare(def=999, def=64) threw java.lang.ClassCastException");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsAtLeast_wrongTypeInActual
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsAtLeast_inOrder_success() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of(
"abc", "+123", "def", "+64", "m", "+1", "def", "0x40", "def", "+128");
assertThat(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsAtLeast("abc", 123, "def", 64, "def", 64, "def", 128);
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsAtLeast_inOrder_success
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsAtLeast_inOrder_wrongKeyOrder() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of(
"abc", "+123", "def", "+64", "def", "0x40", "m", "+1", "def", "+128");
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsAtLeast("def", 64, "def", 64, "def", 128, "abc", 123)
.inOrder());
assertFailureKeys(
e,
"required elements were all found, but order was wrong",
"expected order for required elements",
"testing whether",
"but was");
assertFailureValue(
e, "expected order for required elements", "[def=64, def=64, def=128, abc=123]");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsAtLeast_inOrder_wrongKeyOrder
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void comparingValuesUsing_containsAtLeast_inOrder_wrongValueOrder() {
ImmutableListMultimap<String, String> actual =
ImmutableListMultimap.of(
"abc", "+123", "m", "+1", "def", "+64", "def", "0x40", "def", "+128");
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
.comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE)
.containsAtLeast("abc", 123, "def", 64, "def", 128, "def", 64)
.inOrder());
assertFailureKeys(
e,
"required elements were all found, but order was wrong",
"expected order for required elements",
"testing whether",
"but was");
assertFailureValue(
e, "expected order for required elements", "[abc=123, def=64, def=128, def=64]");
}
|
Tests for Multimap Subjects.
@author Daniel Ploch
@author Kurt Alfred Kluever
|
comparingValuesUsing_containsAtLeast_inOrder_wrongValueOrder
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java
|
Apache-2.0
|
@Test
public void hasCount() {
ImmutableMultiset<String> multiset = ImmutableMultiset.of("kurt", "kurt", "kluever");
assertThat(multiset).hasCount("kurt", 2);
assertThat(multiset).hasCount("kluever", 1);
assertThat(multiset).hasCount("alfred", 0);
assertWithMessage("name").that(multiset).hasCount("kurt", 2);
}
|
Tests for Multiset Subjects.
@author Kurt Alfred Kluever
|
hasCount
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultisetSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultisetSubjectTest.java
|
Apache-2.0
|
@Test
public void hasCountFail() {
ImmutableMultiset<String> multiset = ImmutableMultiset.of("kurt", "kurt", "kluever");
AssertionError e = expectFailure(whenTesting -> whenTesting.that(multiset).hasCount("kurt", 3));
assertFailureValue(e, "value of", "multiset.count(kurt)");
}
|
Tests for Multiset Subjects.
@author Kurt Alfred Kluever
|
hasCountFail
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/MultisetSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/MultisetSubjectTest.java
|
Apache-2.0
|
public static void main(String[] args) {
try {
assertThat("a").isEqualTo("b");
throw new Error("assertion should have failed");
} catch (AssertionError expected) {
ImmutableList<Fact> facts = ((AssertionErrorWithFacts) expected).facts();
assertThat(facts.get(0).key).isEqualTo("expected");
assertThat(facts.get(0).value).isEqualTo("b");
assertThat(facts.get(1).key).isEqualTo("but was");
assertThat(facts.get(1).value).isEqualTo("a");
}
}
|
Truth-using binary to be run without JUnit on the classpath to verify that it still works.
|
main
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/NoJUnitTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/NoJUnitTest.java
|
Apache-2.0
|
@Test
public void testPrimitivesVsBoxedPrimitivesVsObject_int() {
int int42 = 42;
Integer integer42 = 42;
Object object42 = (Object) 42;
assertThat(int42).isEqualTo(int42);
assertThat(integer42).isEqualTo(int42);
assertThat(object42).isEqualTo(int42);
assertThat(int42).isEqualTo(integer42);
assertThat(integer42).isEqualTo(integer42);
assertThat(object42).isEqualTo(integer42);
assertThat(int42).isEqualTo(object42);
assertThat(integer42).isEqualTo(object42);
assertThat(object42).isEqualTo(object42);
}
|
Tests for comparisons between various integral types.
@author David Saff
@author Christian Gruber
@author Kurt Alfred Kluever
|
testPrimitivesVsBoxedPrimitivesVsObject_int
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/NumericComparisonTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/NumericComparisonTest.java
|
Apache-2.0
|
@Test
public void testPrimitivesVsBoxedPrimitivesVsObject_long() {
long longPrim42 = 42;
Long long42 = (long) 42;
Object object42 = (Object) 42L;
assertThat(longPrim42).isEqualTo(longPrim42);
assertThat(long42).isEqualTo(longPrim42);
assertThat(object42).isEqualTo(longPrim42);
assertThat(longPrim42).isEqualTo(long42);
assertThat(long42).isEqualTo(long42);
assertThat(object42).isEqualTo(long42);
assertThat(longPrim42).isEqualTo(object42);
assertThat(long42).isEqualTo(object42);
assertThat(object42).isEqualTo(object42);
}
|
Tests for comparisons between various integral types.
@author David Saff
@author Christian Gruber
@author Kurt Alfred Kluever
|
testPrimitivesVsBoxedPrimitivesVsObject_long
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/NumericComparisonTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/NumericComparisonTest.java
|
Apache-2.0
|
@Test
public void testAllCombinations_pass() {
assertThat(42).isEqualTo(42L);
assertThat(42).isEqualTo(Long.valueOf(42L));
assertThat(Integer.valueOf(42)).isEqualTo(42L);
assertThat(Integer.valueOf(42)).isEqualTo(Long.valueOf(42L));
assertThat(42L).isEqualTo(42);
assertThat(42L).isEqualTo(Integer.valueOf(42));
assertThat(Long.valueOf(42L)).isEqualTo(42);
assertThat(Long.valueOf(42L)).isEqualTo(Integer.valueOf(42));
assertThat(42).isEqualTo(42);
assertThat(42).isEqualTo(Integer.valueOf(42));
assertThat(Integer.valueOf(42)).isEqualTo(42);
assertThat(Integer.valueOf(42)).isEqualTo(Integer.valueOf(42));
assertThat(42L).isEqualTo(42L);
assertThat(42L).isEqualTo(Long.valueOf(42L));
assertThat(Long.valueOf(42L)).isEqualTo(42L);
assertThat(Long.valueOf(42L)).isEqualTo(Long.valueOf(42L));
}
|
Tests for comparisons between various integral types.
@author David Saff
@author Christian Gruber
@author Kurt Alfred Kluever
|
testAllCombinations_pass
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/NumericComparisonTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/NumericComparisonTest.java
|
Apache-2.0
|
@Test
public void testNumericTypeWithSameValue_shouldBeEqual_int_long() {
expectFailure(whenTesting -> whenTesting.that(42).isNotEqualTo(42L));
}
|
Tests for comparisons between various integral types.
@author David Saff
@author Christian Gruber
@author Kurt Alfred Kluever
|
testNumericTypeWithSameValue_shouldBeEqual_int_long
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/NumericComparisonTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/NumericComparisonTest.java
|
Apache-2.0
|
@Test
public void testNumericTypeWithSameValue_shouldBeEqual_int_int() {
expectFailure(whenTesting -> whenTesting.that(42).isNotEqualTo(42));
}
|
Tests for comparisons between various integral types.
@author David Saff
@author Christian Gruber
@author Kurt Alfred Kluever
|
testNumericTypeWithSameValue_shouldBeEqual_int_int
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/NumericComparisonTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/NumericComparisonTest.java
|
Apache-2.0
|
@Test
public void testNumericPrimitiveTypes_isNotEqual_shouldFail_intToChar() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that(42).isNotEqualTo((char) 42));
// 42 in ASCII is '*'
assertFailureValue(e, "expected not to be", "*");
assertFailureValue(e, "but was; string representation of actual value", "42");
}
|
Tests for comparisons between various integral types.
@author David Saff
@author Christian Gruber
@author Kurt Alfred Kluever
|
testNumericPrimitiveTypes_isNotEqual_shouldFail_intToChar
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/NumericComparisonTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/NumericComparisonTest.java
|
Apache-2.0
|
@Test
public void testNumericPrimitiveTypes_isNotEqual_shouldFail_charToInt() {
// Uses Object overload rather than Integer.
AssertionError e = expectFailure(whenTesting -> whenTesting.that((char) 42).isNotEqualTo(42));
// 42 in ASCII is '*'
assertFailureValue(e, "expected not to be", "42");
assertFailureValue(e, "but was; string representation of actual value", "*");
}
|
Tests for comparisons between various integral types.
@author David Saff
@author Christian Gruber
@author Kurt Alfred Kluever
|
testNumericPrimitiveTypes_isNotEqual_shouldFail_charToInt
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/NumericComparisonTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/NumericComparisonTest.java
|
Apache-2.0
|
@Test
public void testNumericPrimitiveTypes() {
byte byte42 = (byte) 42;
short short42 = (short) 42;
char char42 = (char) 42;
int int42 = 42;
long long42 = (long) 42;
ImmutableSet<Object> fortyTwos =
ImmutableSet.<Object>of(byte42, short42, char42, int42, long42);
for (Object actual : fortyTwos) {
for (Object expected : fortyTwos) {
assertThat(actual).isEqualTo(expected);
}
}
ImmutableSet<Object> fortyTwosNoChar = ImmutableSet.<Object>of(byte42, short42, int42, long42);
for (Object actual : fortyTwosNoChar) {
for (Object expected : fortyTwosNoChar) {
expectFailure(whenTesting -> whenTesting.that(actual).isNotEqualTo(expected));
}
}
byte byte41 = (byte) 41;
short short41 = (short) 41;
char char41 = (char) 41;
int int41 = 41;
long long41 = (long) 41;
ImmutableSet<Object> fortyOnes =
ImmutableSet.<Object>of(byte41, short41, char41, int41, long41);
for (Object first : fortyTwos) {
for (Object second : fortyOnes) {
assertThat(first).isNotEqualTo(second);
assertThat(second).isNotEqualTo(first);
}
}
}
|
Tests for comparisons between various integral types.
@author David Saff
@author Christian Gruber
@author Kurt Alfred Kluever
|
testNumericPrimitiveTypes
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/NumericComparisonTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/NumericComparisonTest.java
|
Apache-2.0
|
@Test
public void isEqualTo() {
assertThat(array("A", 5L)).isEqualTo(array("A", 5L));
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isEqualTo
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@SuppressWarnings("TruthSelfEquals")
@Test
public void isEqualTo_same() {
Object[] same = array("A", 5L);
assertThat(same).isEqualTo(same);
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isEqualTo_same
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void asList() {
assertThat(array("A", 5L)).asList().contains("A");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
asList
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void asListOnNull() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that((Object[]) null).asList());
assertFailureKeys(e, "cannot perform assertions on the contents of a null array");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
asListOnNull
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void hasLength() {
assertThat(EMPTY).hasLength(0);
assertThat(array("A", 5L)).hasLength(2);
assertThat(new Object[][] {}).hasLength(0);
assertThat(new Object[][] {{}}).hasLength(1);
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
hasLength
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void hasLengthFail() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that(array("A", 5L)).hasLength(1));
assertFailureValue(e, "value of", "array.length");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
hasLengthFail
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void hasLengthMultiFail() {
AssertionError e =
expectFailure(whenTesting -> whenTesting.that(new Object[][] {{"A"}, {5L}}).hasLength(1));
assertFailureValue(e, "value of", "array.length");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
hasLengthMultiFail
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void hasLengthNullArray() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that((Object[]) null).hasLength(1));
assertFailureKeys(e, "expected an array with length", "but was");
assertFailureValue(e, "expected an array with length", "1");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
hasLengthNullArray
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void hasLengthNegative() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that(array(2, 5)).hasLength(-1));
assertFailureKeys(
e,
"could not perform length check because expected length is negative",
"expected length",
"array was");
assertFailureValue(e, "expected length", "-1");
assertFailureValue(e, "array was", "[2, 5]");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
hasLengthNegative
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void isEmpty() {
assertThat(EMPTY).isEmpty();
assertThat(new Object[][] {}).isEmpty();
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isEmpty
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void isEmptyFail() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that(array("A", 5L)).isEmpty());
assertFailureKeys(e, "expected to be empty", "but was");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isEmptyFail
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void isEmptyNullArray() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that((Object[]) null).isEmpty());
assertFailureKeys(e, "expected an empty array", "but was");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isEmptyNullArray
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void isNotEmpty() {
assertThat(array("A", 5L)).isNotEmpty();
assertThat(new Object[][] {{"A"}, {5L}}).isNotEmpty();
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isNotEmpty
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void isNotEmptyFail() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that(EMPTY).isNotEmpty());
assertFailureKeys(e, "expected not to be empty");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isNotEmptyFail
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void isNotEmptyNullArray() {
AssertionError e = expectFailure(whenTesting -> whenTesting.that((Object[]) null).isNotEmpty());
assertFailureKeys(e, "expected a nonempty array", "but was");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isNotEmptyNullArray
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void isEqualTo_fail_unequalOrdering() {
AssertionError e =
expectFailure(whenTesting -> whenTesting.that(array("A", 5L)).isEqualTo(array(5L, "A")));
assertFailureValue(e, "differs at index", "[0]");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isEqualTo_fail_unequalOrdering
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void isEqualTo_fail_unequalOrderingMultiDimensional_00() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(new Object[][] {{"A"}, {5L}})
.isEqualTo(new Object[][] {{5L}, {"A"}}));
assertFailureValue(e, "differs at index", "[0][0]");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isEqualTo_fail_unequalOrderingMultiDimensional_00
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void isEqualTo_fail_unequalOrderingMultiDimensional_01() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(new Object[][] {{"A", "B"}, {5L}})
.isEqualTo(new Object[][] {{"A"}, {5L}}));
assertFailureValue(e, "wrong length for index", "[0]");
assertFailureValueIndexed(e, "expected", 1, "1");
assertFailureValueIndexed(e, "but was", 1, "2");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isEqualTo_fail_unequalOrderingMultiDimensional_01
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void isEqualTo_fail_unequalOrderingMultiDimensional_11() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(new Object[][] {{"A"}, {5L}})
.isEqualTo(new Object[][] {{"A"}, {5L, 6L}}));
assertFailureValue(e, "wrong length for index", "[1]");
assertFailureValueIndexed(e, "expected", 1, "2");
assertFailureValueIndexed(e, "but was", 1, "1");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isEqualTo_fail_unequalOrderingMultiDimensional_11
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void isEqualTo_fail_notAnArray() {
expectFailure(whenTesting -> whenTesting.that(array("A", 5L)).isEqualTo(new Object()));
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isEqualTo_fail_notAnArray
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void isNotEqualTo_sameLengths() {
assertThat(array("A", 5L)).isNotEqualTo(array("C", 5L));
assertThat(new Object[][] {{"A"}, {5L}}).isNotEqualTo(new Object[][] {{"C"}, {5L}});
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isNotEqualTo_sameLengths
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void isNotEqualTo_differentLengths() {
assertThat(array("A", 5L)).isNotEqualTo(array("A", 5L, "c"));
assertThat(new Object[][] {{"A"}, {5L}}).isNotEqualTo(new Object[][] {{"A", "c"}, {5L}});
assertThat(new Object[][] {{"A"}, {5L}}).isNotEqualTo(new Object[][] {{"A"}, {5L}, {"C"}});
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isNotEqualTo_differentLengths
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void isNotEqualTo_differentTypes() {
assertThat(array("A", 5L)).isNotEqualTo(new Object());
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isNotEqualTo_differentTypes
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void isNotEqualTo_failEquals() {
expectFailure(whenTesting -> whenTesting.that(array("A", 5L)).isNotEqualTo(array("A", 5L)));
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isNotEqualTo_failEquals
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void isNotEqualTo_failEqualsMultiDimensional() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(new Object[][] {{"A"}, {5L}})
.isNotEqualTo(new Object[][] {{"A"}, {5L}}));
assertFailureValue(e, "expected not to be", "[[A], [5]]");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isNotEqualTo_failEqualsMultiDimensional
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@SuppressWarnings("TruthSelfEquals")
@Test
public void isNotEqualTo_failSame() {
Object[] same = array("A", 5L);
expectFailure(whenTesting -> whenTesting.that(same).isNotEqualTo(same));
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isNotEqualTo_failSame
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@SuppressWarnings("TruthSelfEquals")
@Test
public void isNotEqualTo_failSameMultiDimensional() {
Object[][] same = new Object[][] {{"A"}, {5L}};
expectFailure(whenTesting -> whenTesting.that(same).isNotEqualTo(same));
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
isNotEqualTo_failSameMultiDimensional
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void stringArrayIsEqualTo() {
assertThat(array("A", "B")).isEqualTo(array("A", "B"));
assertThat(new String[][] {{"A"}, {"B"}}).isEqualTo(new String[][] {{"A"}, {"B"}});
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
stringArrayIsEqualTo
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void stringArrayAsList() {
assertThat(array("A", "B")).asList().contains("A");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
stringArrayAsList
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void multiDimensionalStringArrayAsList() {
String[] ab = {"A", "B"};
assertThat(new String[][] {ab, {"C"}}).asList().contains(ab);
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
multiDimensionalStringArrayAsList
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void stringArrayIsEqualTo_fail_unequalLength() {
AssertionError e =
expectFailure(whenTesting -> whenTesting.that(array("A", "B")).isEqualTo(array("B")));
assertFailureKeys(e, "expected", "but was", "wrong length", "expected", "but was");
assertFailureValueIndexed(e, "expected", 1, "1");
assertFailureValueIndexed(e, "but was", 1, "2");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
stringArrayIsEqualTo_fail_unequalLength
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void stringArrayIsEqualTo_fail_unequalLengthMultiDimensional() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting.that(new String[][] {{"A"}, {"B"}}).isEqualTo(new String[][] {{"A"}}));
assertFailureKeys(e, "expected", "but was", "wrong length", "expected", "but was");
assertFailureValueIndexed(e, "expected", 1, "1");
assertFailureValueIndexed(e, "but was", 1, "2");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
stringArrayIsEqualTo_fail_unequalLengthMultiDimensional
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void stringArrayIsEqualTo_fail_unequalOrdering() {
AssertionError e =
expectFailure(whenTesting -> whenTesting.that(array("A", "B")).isEqualTo(array("B", "A")));
assertFailureValue(e, "differs at index", "[0]");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
stringArrayIsEqualTo_fail_unequalOrdering
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void stringArrayIsEqualTo_fail_unequalOrderingMultiDimensional() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(new String[][] {{"A"}, {"B"}})
.isEqualTo(new String[][] {{"B"}, {"A"}}));
assertFailureValue(e, "differs at index", "[0][0]");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
stringArrayIsEqualTo_fail_unequalOrderingMultiDimensional
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void setArrayIsEqualTo_fail_unequalOrdering() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(array(ImmutableSet.of("A"), ImmutableSet.of("B")))
.isEqualTo(array(ImmutableSet.of("B"), ImmutableSet.of("A"))));
assertFailureValue(e, "differs at index", "[0]");
// Maybe one day:
// .hasMessage("Not true that <(Set<String>[]) [[A], [B]]> is equal to <[[B], [A]]>");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
setArrayIsEqualTo_fail_unequalOrdering
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void primitiveMultiDimensionalArrayIsEqualTo() {
assertThat(new int[][] {{1, 2}, {3}, {4, 5, 6}})
.isEqualTo(new int[][] {{1, 2}, {3}, {4, 5, 6}});
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
primitiveMultiDimensionalArrayIsEqualTo
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void primitiveMultiDimensionalArrayIsEqualTo_fail_unequalOrdering() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(new int[][] {{1, 2}, {3}, {4, 5, 6}})
.isEqualTo(new int[][] {{1, 2}, {3}, {4, 5, 6, 7}}));
assertFailureValue(e, "wrong length for index", "[2]");
assertFailureValueIndexed(e, "expected", 1, "4");
assertFailureValueIndexed(e, "but was", 1, "3");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
primitiveMultiDimensionalArrayIsEqualTo_fail_unequalOrdering
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void primitiveMultiDimensionalArrayIsNotEqualTo() {
assertThat(new int[][] {{1, 2}, {3}, {4, 5, 6}})
.isNotEqualTo(new int[][] {{1, 2}, {3}, {4, 5, 6, 7}});
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
primitiveMultiDimensionalArrayIsNotEqualTo
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void primitiveMultiDimensionalArrayIsNotEqualTo_fail_equal() {
expectFailure(
whenTesting ->
whenTesting
.that(new int[][] {{1, 2}, {3}, {4, 5, 6}})
.isNotEqualTo(new int[][] {{1, 2}, {3}, {4, 5, 6}}));
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
primitiveMultiDimensionalArrayIsNotEqualTo_fail_equal
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void boxedAndUnboxed() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(new Object[] {new int[] {0}})
.isEqualTo(new Object[] {new Integer[] {0}}));
assertFailureValue(e, "wrong type for index", "[0]");
assertFailureValueIndexed(e, "expected", 1, "Object[]");
assertFailureValueIndexed(e, "but was", 1, "int[]");
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
boxedAndUnboxed
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
private static Object[] array(Object... ts) {
return ts;
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
array
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
private static String[] array(String... ts) {
return ts;
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
array
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
private static Set<?>[] array(Set<?>... ts) {
return ts;
}
|
Tests for {@link com.google.common.truth.ObjectArraySubject}.
@author Christian Gruber (cgruber@israfil.net)
|
array
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ObjectArraySubjectTest.java
|
Apache-2.0
|
@Test
public void failOnNullSubject() {
AssertionError expected =
expectFailure(whenTesting -> whenTesting.that((OptionalDouble) null).isEmpty());
assertThat(expected).factKeys().containsExactly("expected empty optional", "but was").inOrder();
}
|
Tests for {@link OptionalDouble} Subjects.
@author Ben Douglass
|
failOnNullSubject
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java
|
Apache-2.0
|
@Test
public void isPresent() {
assertThat(OptionalDouble.of(1337.0)).isPresent();
}
|
Tests for {@link OptionalDouble} Subjects.
@author Ben Douglass
|
isPresent
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java
|
Apache-2.0
|
@Test
public void isPresentFailing() {
AssertionError expected =
expectFailure(whenTesting -> whenTesting.that(OptionalDouble.empty()).isPresent());
assertThat(expected).factKeys().containsExactly("expected to be present");
}
|
Tests for {@link OptionalDouble} Subjects.
@author Ben Douglass
|
isPresentFailing
|
java
|
google/truth
|
core/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java
|
https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java
|
Apache-2.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.