1ffe3c632Sopenharmony_ci/**
2ffe3c632Sopenharmony_ci * @fileoverview Test data for double encoding and decoding.
3ffe3c632Sopenharmony_ci */
4ffe3c632Sopenharmony_cigoog.module('protobuf.binary.doubleTestPairs');
5ffe3c632Sopenharmony_ci
6ffe3c632Sopenharmony_ciconst BufferDecoder = goog.require('protobuf.binary.BufferDecoder');
7ffe3c632Sopenharmony_ciconst {createBufferDecoder} = goog.require('protobuf.binary.bufferDecoderHelper');
8ffe3c632Sopenharmony_ci
9ffe3c632Sopenharmony_ci/**
10ffe3c632Sopenharmony_ci * An array of Pairs of double values and their bit representation.
11ffe3c632Sopenharmony_ci * This is used to test encoding and decoding from the protobuf wire format.
12ffe3c632Sopenharmony_ci * @return {!Array<{name: string, doubleValue:number, bufferDecoder:
13ffe3c632Sopenharmony_ci *     !BufferDecoder}>}
14ffe3c632Sopenharmony_ci */
15ffe3c632Sopenharmony_cifunction getDoublePairs() {
16ffe3c632Sopenharmony_ci  const doublePairs = [
17ffe3c632Sopenharmony_ci    {
18ffe3c632Sopenharmony_ci      name: 'zero',
19ffe3c632Sopenharmony_ci      doubleValue: 0,
20ffe3c632Sopenharmony_ci      bufferDecoder:
21ffe3c632Sopenharmony_ci          createBufferDecoder(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
22ffe3c632Sopenharmony_ci    },
23ffe3c632Sopenharmony_ci    {
24ffe3c632Sopenharmony_ci      name: 'minus zero',
25ffe3c632Sopenharmony_ci      doubleValue: -0,
26ffe3c632Sopenharmony_ci      bufferDecoder:
27ffe3c632Sopenharmony_ci          createBufferDecoder(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80)
28ffe3c632Sopenharmony_ci    },
29ffe3c632Sopenharmony_ci    {
30ffe3c632Sopenharmony_ci      name: 'one',
31ffe3c632Sopenharmony_ci      doubleValue: 1,
32ffe3c632Sopenharmony_ci      bufferDecoder:
33ffe3c632Sopenharmony_ci          createBufferDecoder(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F)
34ffe3c632Sopenharmony_ci    },
35ffe3c632Sopenharmony_ci    {
36ffe3c632Sopenharmony_ci      name: 'minus one',
37ffe3c632Sopenharmony_ci      doubleValue: -1,
38ffe3c632Sopenharmony_ci      bufferDecoder:
39ffe3c632Sopenharmony_ci          createBufferDecoder(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xBF)
40ffe3c632Sopenharmony_ci    },
41ffe3c632Sopenharmony_ci
42ffe3c632Sopenharmony_ci    {
43ffe3c632Sopenharmony_ci      name: 'PI',
44ffe3c632Sopenharmony_ci      doubleValue: Math.PI,
45ffe3c632Sopenharmony_ci      bufferDecoder:
46ffe3c632Sopenharmony_ci          createBufferDecoder(0x18, 0x2D, 0x44, 0x54, 0xFB, 0x21, 0x09, 0x40)
47ffe3c632Sopenharmony_ci
48ffe3c632Sopenharmony_ci    },
49ffe3c632Sopenharmony_ci    {
50ffe3c632Sopenharmony_ci      name: 'max value',
51ffe3c632Sopenharmony_ci      doubleValue: Number.MAX_VALUE,
52ffe3c632Sopenharmony_ci      bufferDecoder:
53ffe3c632Sopenharmony_ci          createBufferDecoder(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEF, 0x7F)
54ffe3c632Sopenharmony_ci    },
55ffe3c632Sopenharmony_ci    {
56ffe3c632Sopenharmony_ci      name: 'min value',
57ffe3c632Sopenharmony_ci      doubleValue: Number.MIN_VALUE,
58ffe3c632Sopenharmony_ci      bufferDecoder:
59ffe3c632Sopenharmony_ci          createBufferDecoder(0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
60ffe3c632Sopenharmony_ci    },
61ffe3c632Sopenharmony_ci    {
62ffe3c632Sopenharmony_ci      name: 'Infinity',
63ffe3c632Sopenharmony_ci      doubleValue: Infinity,
64ffe3c632Sopenharmony_ci      bufferDecoder:
65ffe3c632Sopenharmony_ci          createBufferDecoder(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x7F)
66ffe3c632Sopenharmony_ci    },
67ffe3c632Sopenharmony_ci    {
68ffe3c632Sopenharmony_ci      name: 'minus Infinity',
69ffe3c632Sopenharmony_ci      doubleValue: -Infinity,
70ffe3c632Sopenharmony_ci      bufferDecoder:
71ffe3c632Sopenharmony_ci          createBufferDecoder(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF)
72ffe3c632Sopenharmony_ci    },
73ffe3c632Sopenharmony_ci    {
74ffe3c632Sopenharmony_ci      name: 'Number.MAX_SAFE_INTEGER',
75ffe3c632Sopenharmony_ci      doubleValue: Number.MAX_SAFE_INTEGER,
76ffe3c632Sopenharmony_ci      bufferDecoder:
77ffe3c632Sopenharmony_ci          createBufferDecoder(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x43)
78ffe3c632Sopenharmony_ci    },
79ffe3c632Sopenharmony_ci    {
80ffe3c632Sopenharmony_ci      name: 'Number.MIN_SAFE_INTEGER',
81ffe3c632Sopenharmony_ci      doubleValue: Number.MIN_SAFE_INTEGER,
82ffe3c632Sopenharmony_ci      bufferDecoder:
83ffe3c632Sopenharmony_ci          createBufferDecoder(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0xC3)
84ffe3c632Sopenharmony_ci    },
85ffe3c632Sopenharmony_ci  ];
86ffe3c632Sopenharmony_ci  return [...doublePairs];
87ffe3c632Sopenharmony_ci}
88ffe3c632Sopenharmony_ci
89ffe3c632Sopenharmony_ciexports = {getDoublePairs};
90