Skip to content

Commit a3aea95

Browse files
committed
port changes from java
1 parent bf7adce commit a3aea95

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

packages/firestore/test/unit/util/misc.test.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,40 +92,33 @@ class StringGenerator {
9292
} else {
9393
this.rnd = seedOrRnd;
9494
this.surrogatePairProbability = StringGenerator.validateProbability(
95-
'surrogate pair',
9695
surrogatePairProbability!
9796
);
98-
this.maxLength = StringGenerator.validateLength(
99-
'maximum string',
100-
maxLength!
101-
);
97+
this.maxLength = StringGenerator.validateLength(maxLength!);
10298
}
10399
}
104100

105-
private static validateProbability(
106-
name: string,
107-
probability: number
108-
): number {
101+
private static validateProbability(probability: number): number {
109102
if (!Number.isFinite(probability)) {
110103
throw new Error(
111-
`invalid ${name} probability: ${probability} (must be between 0.0 and 1.0, inclusive)`
104+
`invalid surrogate pair probability: ${probability} (must be between 0.0 and 1.0, inclusive)`
112105
);
113106
} else if (probability < 0.0) {
114107
throw new Error(
115-
`invalid ${name} probability: ${probability} (must be greater than or equal to zero)`
108+
`invalid surrogate pair probability: ${probability} (must be greater than or equal to zero)`
116109
);
117110
} else if (probability > 1.0) {
118111
throw new Error(
119-
`invalid ${name} probability: ${probability} (must be less than or equal to 1)`
112+
`invalid surrogate pair probability: ${probability} (must be less than or equal to 1)`
120113
);
121114
}
122115
return probability;
123116
}
124117

125-
private static validateLength(name: string, length: number): number {
118+
private static validateLength(length: number): number {
126119
if (length < 0) {
127120
throw new Error(
128-
`invalid ${name} length: ${length} (must be greater than or equal to zero)`
121+
`invalid maximum string length: ${length} (must be greater than or equal to zero)`
129122
);
130123
}
131124
return length;

0 commit comments

Comments
 (0)