Skip to content

Commit ca04f65

Browse files
cpovirkronshapiro
authored andcommitted
Remove deprecated (Object expected, double tolerance) overloads of isEqualTo() and isNotEqualTo().
RELNOTES=Removed deprecated `(Object expected, double tolerance)` overloads of `isEqualTo()` and `isNotEqualTo()`. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=187336036
1 parent f33f567 commit ca04f65

File tree

4 files changed

+0
-635
lines changed

4 files changed

+0
-635
lines changed

core/src/main/java/com/google/common/truth/PrimitiveDoubleArraySubject.java

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -94,50 +94,6 @@ public void isEqualTo(Object expected) {
9494
}
9595
}
9696

97-
/**
98-
* A check that the actual array and {@code expected} are arrays of the same length and type,
99-
* containing elements such that each element in {@code expected} is within {@code tolerance} of
100-
* each element in the subject, and in the same position.
101-
*
102-
* <p>Behaviour for non-finite values ({@link Double#POSITIVE_INFINITY POSITIVE_INFINITY}, {@link
103-
* Double#NEGATIVE_INFINITY NEGATIVE_INFINITY}, and {@link Double#NaN NaN}) is as follows: If the
104-
* subject and the object of the assertion are the same array, the test will pass. If not
105-
* (including if one is a clone of the other) then non-finite values are considered not equal so
106-
* the any non-finite value in either argument will cause the test to fail.
107-
*
108-
* @deprecated use {@code usingTolerance(someTolerance).containsExactly(someValues).inOrder()},
109-
* noting the different behaviour for non-finite values
110-
*/
111-
@Deprecated
112-
public void isEqualTo(Object expected, double tolerance) {
113-
double[] actual = actual();
114-
if (actual == expected) {
115-
return; // short-cut.
116-
}
117-
try {
118-
double[] expectedArray = (double[]) expected;
119-
if (expectedArray.length != actual.length) {
120-
failWithRawMessage(
121-
"Arrays are of different lengths. expected: %s, actual %s",
122-
doubleArrayAsString(expectedArray), doubleArrayAsString(actual));
123-
return;
124-
}
125-
List<Integer> unequalIndices = new ArrayList<>();
126-
for (int i = 0; i < expectedArray.length; i++) {
127-
if (!equalWithinTolerance(actual[i], expectedArray[i], tolerance)) {
128-
unequalIndices.add(i);
129-
}
130-
}
131-
132-
if (!unequalIndices.isEmpty()) {
133-
fail("is equal to", doubleArrayAsString(expectedArray));
134-
return;
135-
}
136-
} catch (ClassCastException e) {
137-
failWithBadType(expected);
138-
}
139-
}
140-
14197
/**
14298
* A check that the actual array and {@code expected} are not arrays of the same length and type,
14399
* containing elements such that each element in {@code expected} is equal to each element in the
@@ -166,49 +122,6 @@ public void isNotEqualTo(Object expected) {
166122
}
167123
}
168124

169-
/**
170-
* A check that the actual array and {@code expected} are not arrays of the same length and type,
171-
* containing elements such that each element in {@code expected} is within {@code tolerance} of
172-
* each element in the subject, and in the same position.
173-
*
174-
* <p>Behaviour for non-finite values ({@link Double#POSITIVE_INFINITY POSITIVE_INFINITY}, {@link
175-
* Double#NEGATIVE_INFINITY NEGATIVE_INFINITY}, and {@link Double#NaN NaN}) is as follows: If the
176-
* subject and the object of the assertion are the same array, the test will fail. If not
177-
* (including if one is a clone of the other) then non-finite values are considered not equal so
178-
* the any non-finite value in either argument will cause the test to pass.
179-
*
180-
* @deprecated Write a for loop over the values looking for mismatches (see this implementation
181-
* for an example)
182-
*/
183-
@Deprecated
184-
public void isNotEqualTo(Object expectedArray, double tolerance) {
185-
double[] actual = actual();
186-
try {
187-
double[] expected = (double[]) expectedArray;
188-
if (actual == expected) {
189-
failWithRawMessage(
190-
"%s unexpectedly equal to %s.", actualAsString(), doubleArrayAsString(expected));
191-
return;
192-
}
193-
if (expected.length != actual.length) {
194-
return; // Unequal-lengthed arrays are not equal.
195-
}
196-
List<Integer> unequalIndices = new ArrayList<>();
197-
for (int i = 0; i < expected.length; i++) {
198-
if (!equalWithinTolerance(actual[i], expected[i], tolerance)) {
199-
unequalIndices.add(i);
200-
}
201-
}
202-
if (unequalIndices.isEmpty()) {
203-
failWithRawMessage(
204-
"%s unexpectedly equal to %s.", actualAsString(), doubleArrayAsString(expected));
205-
return;
206-
}
207-
} catch (ClassCastException ignored) {
208-
// Unequal since they are of different types.
209-
}
210-
}
211-
212125
/**
213126
* A partially specified check about an approximate relationship to a {@code double[]} subject
214127
* using a tolerance.

core/src/main/java/com/google/common/truth/PrimitiveFloatArraySubject.java

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -94,50 +94,6 @@ public void isEqualTo(Object expected) {
9494
}
9595
}
9696

97-
/**
98-
* A check that the actual array and {@code expected} are arrays of the same length and type,
99-
* containing elements such that each element in {@code expected} is within {@code tolerance} of
100-
* each element in the subject, and in the same position.
101-
*
102-
* <p>Behaviour for non-finite values ({@link Float#POSITIVE_INFINITY POSITIVE_INFINITY}, {@link
103-
* Float#NEGATIVE_INFINITY NEGATIVE_INFINITY}, and {@link Float#NaN NaN}) is as follows: If the
104-
* subject and the object of the assertion are the same array, the test will pass. If not
105-
* (including if one is a clone of the other) then non-finite values are considered not equal so
106-
* the any non-finite value in either argument will cause the test to fail.
107-
*
108-
* @deprecated use {@code usingTolerance(someTolerance).containsExactly(someValues).inOrder()},
109-
* noting the different behaviour for non-finite values
110-
*/
111-
@Deprecated
112-
public void isEqualTo(Object expected, float tolerance) {
113-
float[] actual = actual();
114-
if (actual == expected) {
115-
return; // short-cut.
116-
}
117-
try {
118-
float[] expectedArray = (float[]) expected;
119-
if (expectedArray.length != actual.length) {
120-
failWithRawMessage(
121-
"Arrays are of different lengths. expected: %s, actual %s",
122-
floatArrayAsString(expectedArray), floatArrayAsString(actual));
123-
return;
124-
}
125-
List<Integer> unequalIndices = new ArrayList<>();
126-
for (int i = 0; i < expectedArray.length; i++) {
127-
if (!equalWithinTolerance(actual[i], expectedArray[i], tolerance)) {
128-
unequalIndices.add(i);
129-
}
130-
}
131-
132-
if (!unequalIndices.isEmpty()) {
133-
fail("is equal to", floatArrayAsString(expectedArray));
134-
return;
135-
}
136-
} catch (ClassCastException e) {
137-
failWithBadType(expected);
138-
}
139-
}
140-
14197
/**
14298
* A check that the actual array and {@code expected} are not arrays of the same length and type,
14399
* containing elements such that each element in {@code expected} is equal to each element in the
@@ -166,49 +122,6 @@ public void isNotEqualTo(Object expected) {
166122
}
167123
}
168124

169-
/**
170-
* A check that the actual array and {@code expected} are not arrays of the same length and type,
171-
* containing elements such that each element in {@code expected} is within {@code tolerance} of
172-
* each element in the subject, and in the same position.
173-
*
174-
* <p>Behaviour for non-finite values ({@link Float#POSITIVE_INFINITY POSITIVE_INFINITY}, {@link
175-
* Float#NEGATIVE_INFINITY NEGATIVE_INFINITY}, and {@link Float#NaN NaN}) is as follows: If the
176-
* subject and the object of the assertion are the same array, the test will fail. If not
177-
* (including if one is a clone of the other) then non-finite values are considered not equal so
178-
* the any non-finite value in either argument will cause the test to pass.
179-
*
180-
* @deprecated Write a for loop over the values looking for mismatches (see this implementation
181-
* for an example)
182-
*/
183-
@Deprecated
184-
public void isNotEqualTo(Object expectedArray, float tolerance) {
185-
float[] actual = actual();
186-
try {
187-
float[] expected = (float[]) expectedArray;
188-
if (actual == expected) {
189-
failWithRawMessage(
190-
"%s unexpectedly equal to %s.", actualAsString(), floatArrayAsString(expected));
191-
return;
192-
}
193-
if (expected.length != actual.length) {
194-
return; // Unequal-lengthed arrays are not equal.
195-
}
196-
List<Integer> unequalIndices = new ArrayList<>();
197-
for (int i = 0; i < expected.length; i++) {
198-
if (!equalWithinTolerance(actual[i], expected[i], tolerance)) {
199-
unequalIndices.add(i);
200-
}
201-
}
202-
if (unequalIndices.isEmpty()) {
203-
failWithRawMessage(
204-
"%s unexpectedly equal to %s.", actualAsString(), floatArrayAsString(expected));
205-
return;
206-
}
207-
} catch (ClassCastException ignored) {
208-
// Unequal since they are of different types.
209-
}
210-
}
211-
212125
/**
213126
* A partially specified check about an approximate relationship to a {@code float[]} subject
214127
* using a tolerance.

0 commit comments

Comments
 (0)