Skip to content

Commit 334970e

Browse files
committed
port changes from java
1 parent 6dd0b84 commit 334970e

File tree

1 file changed

+13
-21
lines changed
  • firebase-firestore/src/test/java/com/google/firebase/firestore/util

1 file changed

+13
-21
lines changed

firebase-firestore/src/test/java/com/google/firebase/firestore/util/UtilTest.java

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,9 @@ public void compareUtf8StringsShouldReturnCorrectValue() {
9898
StringGenerator stringGenerator = new StringGenerator(29750468);
9999
StringPairGenerator stringPairGenerator = new StringPairGenerator(stringGenerator);
100100
for (int i = 0; i < 1_000_000 && errors.size() < 10; i++) {
101-
final String s1, s2;
102-
{
103-
StringPairGenerator.StringPair stringPair = stringPairGenerator.next();
104-
s1 = stringPair.s1;
105-
s2 = stringPair.s2;
106-
}
101+
StringPairGenerator.StringPair stringPair = stringPairGenerator.next();
102+
final String s1 = stringPair.s1;
103+
final String s2 = stringPair.s2;
107104

108105
int actual = Util.compareUtf8Strings(s1, s2);
109106

@@ -190,41 +187,36 @@ public StringGenerator(int seed) {
190187

191188
public StringGenerator(Random rnd, float surrogatePairProbability, int maxLength) {
192189
this.rnd = rnd;
193-
this.surrogatePairProbability =
194-
validateProbability("surrogate pair", surrogatePairProbability);
195-
this.maxLength = validateLength("maximum string", maxLength);
190+
this.surrogatePairProbability = validateProbability(surrogatePairProbability);
191+
this.maxLength = validateLength(maxLength);
196192
}
197193

198-
private static float validateProbability(String name, float probability) {
194+
private static float validateProbability(float probability) {
199195
if (!Float.isFinite(probability)) {
200196
throw new IllegalArgumentException(
201-
"invalid "
202-
+ name
203-
+ " probability: "
197+
"invalid surrogate pair probability: "
204198
+ probability
205199
+ " (must be between 0.0 and 1.0, inclusive)");
206200
} else if (probability < 0.0f) {
207201
throw new IllegalArgumentException(
208-
"invalid "
209-
+ name
210-
+ " probability: "
202+
"invalid surrogate pair probability: "
211203
+ probability
212204
+ " (must be greater than or equal to zero)");
213205
} else if (probability > 1.0f) {
214206
throw new IllegalArgumentException(
215-
"invalid "
216-
+ name
217-
+ " probability: "
207+
"invalid surrogate pair probability: "
218208
+ probability
219209
+ " (must be less than or equal to 1)");
220210
}
221211
return probability;
222212
}
223213

224-
private static int validateLength(String name, int length) {
214+
private static int validateLength(int length) {
225215
if (length < 0) {
226216
throw new IllegalArgumentException(
227-
"invalid " + name + " length: " + length + " (must be greater than or equal to zero)");
217+
"invalid maximum string length: "
218+
+ length
219+
+ " (must be greater than or equal to zero)");
228220
}
229221
return length;
230222
}

0 commit comments

Comments
 (0)