aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgenii Kliuchnikov <eustas@google.com>2023-03-16 20:38:28 +0000
committerEvgenii Kliuchnikov <eustas.ru@gmail.com>2023-07-04 07:53:59 +0000
commit745fd08ef29ba7c86def64a21905fa7a9a7b89a6 (patch)
tree424668a2e043515be8122834599f12609576892d
parentf29c44ed38db167be86e734c302b50cdc6b29227 (diff)
downloadbrotli-745fd08ef29ba7c86def64a21905fa7a9a7b89a6.zip
brotli-745fd08ef29ba7c86def64a21905fa7a9a7b89a6.tar.gz
brotli-745fd08ef29ba7c86def64a21905fa7a9a7b89a6.tar.bz2
internal change
PiperOrigin-RevId: 517214701
-rw-r--r--js/bundle_test.js25
-rw-r--r--js/decode_synth_test.js16
-rw-r--r--js/decode_test.js22
3 files changed, 32 insertions, 31 deletions
diff --git a/js/bundle_test.js b/js/bundle_test.js
index 6567a3d..f36fc8e 100644
--- a/js/bundle_test.js
+++ b/js/bundle_test.js
@@ -5,8 +5,6 @@
*/
import {BrotliDecode} from "./decode.js";
import {makeTestData} from "./test_data.js";
-goog.require('goog.testing.asserts');
-const testSuite = goog.require('goog.testing.testSuite');
const CRC_64_POLY = new Uint32Array([0xD7870F42, 0xC96C5795]);
@@ -55,18 +53,17 @@ function checkEntry(entry, data) {
const expectedCrc = entry.substring(0, 16);
const decompressed = BrotliDecode(data);
const crc = calculateCrc64(decompressed);
- assertEquals(expectedCrc, crc);
+ expect(expectedCrc).toEqual(crc);
}
-let allTests = {};
-const testData = makeTestData();
-for (let entry in testData) {
- if (!testData.hasOwnProperty(entry)) {
- continue;
+describe("BundleTest", () => {
+ const testData = makeTestData();
+ for (let entry in testData) {
+ if (!testData.hasOwnProperty(entry)) {
+ continue;
+ }
+ const name = entry.substring(17);
+ const data = testData[entry];
+ it('test_' + name, checkEntry.bind(null, entry, data));
}
- const name = entry.substring(17);
- const data = testData[entry];
- allTests['test_' + name] = checkEntry.bind(null, entry, data);
-}
-
-testSuite(allTests);
+});
diff --git a/js/decode_synth_test.js b/js/decode_synth_test.js
index e4fecbf..7732826 100644
--- a/js/decode_synth_test.js
+++ b/js/decode_synth_test.js
@@ -4,8 +4,6 @@
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/
import {BrotliDecode} from "./decode.js";
-const testSuite = goog.require('goog.testing.testSuite');
-goog.require('goog.testing.asserts');
/**
* NB: Use intermediate chunks to avoid "Maximum call stack size exceeded".
@@ -42,13 +40,13 @@ function checkSynth(compressed, expectSuccess, expectedOutput) {
} catch (ex) {
success = false;
}
- assertEquals(expectSuccess, success);
+ expect(expectSuccess).toEqual(success);
if (expectSuccess) {
- assertEquals(expectedOutput, bytesToString(actual));
+ expect(expectedOutput).toEqual(bytesToString(actual));
}
}
-testSuite({
+const allTests = {
/* GENERATED CODE START */
testAllTransforms10() {
@@ -2278,4 +2276,12 @@ testZeroCostLiterals() {
},
/* GENERATED CODE END */
+};
+
+describe("DecodeSynthTest", () => {
+ const testNames = Object.keys(allTests);
+ for (let i = 0; i < testNames.length; ++i) {
+ const testName = testNames[i];
+ it(testName, allTests[testName]);
+ }
});
diff --git a/js/decode_test.js b/js/decode_test.js
index bbeb541..231cffe 100644
--- a/js/decode_test.js
+++ b/js/decode_test.js
@@ -4,8 +4,6 @@
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/
import {BrotliDecode} from "./decode.js";
-const testSuite = goog.require('goog.testing.testSuite');
-goog.require('goog.testing.asserts');
/**
* @param {!Int8Array} bytes
@@ -25,20 +23,20 @@ function stringToBytes(str) {
return out;
}
-testSuite({
- testMetadata() {
- assertEquals(
- '', bytesToString(BrotliDecode(Int8Array.from([1, 11, 0, 42, 3]))));
- },
+describe('DecodeTest', () => {
+ it('testMetadata', () => {
+ expect('').toEqual(
+ bytesToString(BrotliDecode(Int8Array.from([1, 11, 0, 42, 3]))));
+ });
- testCompoundDictionary() {
+ it('testCompoundDictionary', () => {
const txt = 'kot lomom kolol slona\n';
const dictionary = stringToBytes(txt);
const compressed =
[0xa1, 0xa8, 0x00, 0xc0, 0x2f, 0x01, 0x10, 0xc4, 0x44, 0x09, 0x00];
- assertEquals(txt.length, compressed.length * 2);
+ expect(txt.length).toEqual(compressed.length * 2);
const options = {'customDictionary': dictionary};
- assertEquals(
- txt, bytesToString(BrotliDecode(Int8Array.from(compressed), options)));
- }
+ expect(txt).toEqual(
+ bytesToString(BrotliDecode(Int8Array.from(compressed), options)));
+ });
});