deno.land / x / msgpack_javascript@v3.0.0-beta2 / test / bigint64.test.ts

bigint64.test.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import assert from "assert";import { encode, decode } from "../src";
describe("useBigInt64: true", () => { before(function () { if (typeof BigInt === "undefined") { this.skip(); } });
it("encodes and decodes 0n", () => { const value = BigInt(0); const encoded = encode(value, { useBigInt64: true }); assert.deepStrictEqual(decode(encoded, { useBigInt64: true }), value); });
it("encodes and decodes MAX_SAFE_INTEGER+1", () => { const value = BigInt(Number.MAX_SAFE_INTEGER) + BigInt(1); const encoded = encode(value, { useBigInt64: true }); assert.deepStrictEqual(decode(encoded, { useBigInt64: true }), value); });
it("encodes and decodes MIN_SAFE_INTEGER-1", () => { const value = BigInt(Number.MIN_SAFE_INTEGER) - BigInt(1); const encoded = encode(value, { useBigInt64: true }); assert.deepStrictEqual(decode(encoded, { useBigInt64: true }), value); });
it("encodes and decodes values with numbers and bigints", () => { const value = { ints: [0, Number.MAX_SAFE_INTEGER, Number.MIN_SAFE_INTEGER], nums: [Number.NaN, Math.PI, Math.E, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY], bigints: [BigInt(0), BigInt(Number.MAX_SAFE_INTEGER) + BigInt(1), BigInt(Number.MIN_SAFE_INTEGER) - BigInt(1)], }; const encoded = encode(value, { useBigInt64: true }); assert.deepStrictEqual(decode(encoded, { useBigInt64: true }), value); });});
msgpack_javascript

Version Info

Tagged at
a year ago