Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve containsExactly error message
If the lists are of the same length and contain the same elements, but are in not in the same order, print the indices - limited to 50 - where a mismatch occurred. Fix 2629
- Loading branch information
1 parent
a4a615e
commit 41179e5
Showing
6 changed files
with
371 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* Copyright 2012-2022 the original author or authors. | ||
*/ | ||
package org.assertj.core.internal; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Immutable class modeling the actual and expected elements at a given index. | ||
*/ | ||
public class IndexedDiff { | ||
public final Object actual; | ||
public final Object expected; | ||
public final int index; | ||
|
||
/** | ||
* Create a {@link IndexedDiff}. | ||
* @param actual the actual value of the diff. | ||
* @param expected the expected value of the diff. | ||
* @param index the index the diff occurred at. | ||
*/ | ||
public IndexedDiff(Object actual, Object expected, int index) { | ||
this.actual = actual; | ||
this.expected = expected; | ||
this.index = index; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
IndexedDiff that = (IndexedDiff) o; | ||
return index == that.index && Objects.equals(actual, that.actual) && Objects.equals(expected, that.expected); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("IndexedDiff(actual=%s, expected=%s, index=%s)", this.actual, this.expected, this.index); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(actual, expected, index); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.