Skip to content

Commit 745fd08

Browse files
committed
internal change
PiperOrigin-RevId: 517214701
1 parent f29c44e commit 745fd08

File tree

3 files changed

+32
-31
lines changed

3 files changed

+32
-31
lines changed

js/bundle_test.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
import {BrotliDecode} from "./decode.js";
77
import {makeTestData} from "./test_data.js";
8-
goog.require('goog.testing.asserts');
9-
const testSuite = goog.require('goog.testing.testSuite');
108

119
const CRC_64_POLY = new Uint32Array([0xD7870F42, 0xC96C5795]);
1210

@@ -55,18 +53,17 @@ function checkEntry(entry, data) {
5553
const expectedCrc = entry.substring(0, 16);
5654
const decompressed = BrotliDecode(data);
5755
const crc = calculateCrc64(decompressed);
58-
assertEquals(expectedCrc, crc);
56+
expect(expectedCrc).toEqual(crc);
5957
}
6058

61-
let allTests = {};
62-
const testData = makeTestData();
63-
for (let entry in testData) {
64-
if (!testData.hasOwnProperty(entry)) {
65-
continue;
59+
describe("BundleTest", () => {
60+
const testData = makeTestData();
61+
for (let entry in testData) {
62+
if (!testData.hasOwnProperty(entry)) {
63+
continue;
64+
}
65+
const name = entry.substring(17);
66+
const data = testData[entry];
67+
it('test_' + name, checkEntry.bind(null, entry, data));
6668
}
67-
const name = entry.substring(17);
68-
const data = testData[entry];
69-
allTests['test_' + name] = checkEntry.bind(null, entry, data);
70-
}
71-
72-
testSuite(allTests);
69+
});

js/decode_synth_test.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
55
*/
66
import {BrotliDecode} from "./decode.js";
7-
const testSuite = goog.require('goog.testing.testSuite');
8-
goog.require('goog.testing.asserts');
97

108
/**
119
* NB: Use intermediate chunks to avoid "Maximum call stack size exceeded".
@@ -42,13 +40,13 @@ function checkSynth(compressed, expectSuccess, expectedOutput) {
4240
} catch (ex) {
4341
success = false;
4442
}
45-
assertEquals(expectSuccess, success);
43+
expect(expectSuccess).toEqual(success);
4644
if (expectSuccess) {
47-
assertEquals(expectedOutput, bytesToString(actual));
45+
expect(expectedOutput).toEqual(bytesToString(actual));
4846
}
4947
}
5048

51-
testSuite({
49+
const allTests = {
5250
/* GENERATED CODE START */
5351

5452
testAllTransforms10() {
@@ -2278,4 +2276,12 @@ testZeroCostLiterals() {
22782276
},
22792277

22802278
/* GENERATED CODE END */
2279+
};
2280+
2281+
describe("DecodeSynthTest", () => {
2282+
const testNames = Object.keys(allTests);
2283+
for (let i = 0; i < testNames.length; ++i) {
2284+
const testName = testNames[i];
2285+
it(testName, allTests[testName]);
2286+
}
22812287
});

js/decode_test.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
55
*/
66
import {BrotliDecode} from "./decode.js";
7-
const testSuite = goog.require('goog.testing.testSuite');
8-
goog.require('goog.testing.asserts');
97

108
/**
119
* @param {!Int8Array} bytes
@@ -25,20 +23,20 @@ function stringToBytes(str) {
2523
return out;
2624
}
2725

28-
testSuite({
29-
testMetadata() {
30-
assertEquals(
31-
'', bytesToString(BrotliDecode(Int8Array.from([1, 11, 0, 42, 3]))));
32-
},
26+
describe('DecodeTest', () => {
27+
it('testMetadata', () => {
28+
expect('').toEqual(
29+
bytesToString(BrotliDecode(Int8Array.from([1, 11, 0, 42, 3]))));
30+
});
3331

34-
testCompoundDictionary() {
32+
it('testCompoundDictionary', () => {
3533
const txt = 'kot lomom kolol slona\n';
3634
const dictionary = stringToBytes(txt);
3735
const compressed =
3836
[0xa1, 0xa8, 0x00, 0xc0, 0x2f, 0x01, 0x10, 0xc4, 0x44, 0x09, 0x00];
39-
assertEquals(txt.length, compressed.length * 2);
37+
expect(txt.length).toEqual(compressed.length * 2);
4038
const options = {'customDictionary': dictionary};
41-
assertEquals(
42-
txt, bytesToString(BrotliDecode(Int8Array.from(compressed), options)));
43-
}
39+
expect(txt).toEqual(
40+
bytesToString(BrotliDecode(Int8Array.from(compressed), options)));
41+
});
4442
});

0 commit comments

Comments
 (0)