• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15import { objectToMemorySize } from '../../../src/hdc/common/ObjectToMemorySize';
16describe('ObjectToMemoryTest', () => {
17  let obj = new objectToMemorySize();
18  it('ObjectToMemoryTest_objectToSize_01', () => {
19    expect(obj.objectToSize(12)).toEqual(8);
20  });
21
22  it('ObjectToMemoryTest_objectToSize_02', () => {
23    expect(obj.objectToSize(true)).toEqual(4);
24  });
25
26  it('ObjectToMemoryTest_objectToSize_03', () => {
27    expect(obj.objectToSize('abc')).toEqual(6);
28  });
29
30  it('ObjectToMemoryTest_objectToSize_04', () => {
31    expect(obj.objectToSize([1, 2])).toEqual(16);
32  });
33
34  it('ObjectToMemoryTest_objectToSize_05', () => {
35    expect(obj.objectToSize({ name: 'demo', age: 12 })).toEqual(30);
36  });
37
38  it('ObjectToMemoryTest_sizeOfObj_01', () => {
39    expect(obj.sizeOfObj(null)).toEqual(0);
40  });
41
42  it('ObjectToMemoryTest_sizeOfObj_02', () => {
43    expect(obj.sizeOfObj(12)).toEqual(0);
44  });
45
46  it('ObjectToMemoryTest_sizeOfObj_03', () => {
47    expect(obj.sizeOfObj(false)).toEqual(0);
48  });
49
50  it('ObjectToMemoryTest_sizeOfObj_04', () => {
51    expect(obj.sizeOfObj(false)).toEqual(0);
52  });
53
54  it('ObjectToMemoryTest_sizeOfObj_05', () => {
55    expect(obj.sizeOfObj([1, 2])).toEqual(20);
56  });
57
58  it('ObjectToMemoryTest_sizeOfObj_06', () => {
59    expect(obj.sizeOfObj({ name: 'demo', age: 12 })).toEqual(30);
60  });
61
62  it('ObjectToMemoryTest_objectToSize_07', () => {
63    expect(obj.objectToSize(undefined)).toEqual(0);
64  });
65
66  it('ObjectToMemoryTest_sizeOfObj_08', () => {
67    let object = {
68      [1]: 2,
69      [3]: 4,
70      [5]: 6,
71      [7]: 8,
72    };
73    expect(obj.sizeOfObj(object)).toEqual(40);
74  });
75});
76