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 */ 15// @ts-ignore 16import {toHex8,toHex16,toHex32,toHex64,uint8ArrayToString} from "../../../dist/hdc/common/BaseConversion.js"; 17 18describe('BaseConversionTest', () => { 19 20 it('BaseConversionTest_toHex8_01', () => { 21 expect(toHex8('0O8')).toEqual("0O8") 22 }) 23 24 it('BaseConversionTest_toHex8_02', () => { 25 expect(toHex8(32)).toEqual("20") 26 }) 27 28 it('BaseConversionTest_toHex16_01', () => { 29 expect(toHex16(8)).toEqual("08") 30 }) 31 32 it('BaseConversionTest_toHex16_02', () => { 33 expect(toHex16(11)).toEqual("0b") 34 }) 35 36 it('BaseConversionTest_toHex32_01', () => { 37 expect(toHex32(33)).toEqual("0021") 38 }) 39 40 it('BaseConversionTest_toHex32_02', () => { 41 expect(toHex32(36)).toEqual("0024") 42 }) 43 44 it('BaseConversionTest_toHex64_01', () => { 45 expect(toHex64("36")).toEqual("00000036") 46 }) 47 48 it('BaseConversionTest_toHex64_02', () => { 49 expect(toHex64(36)).toEqual("00000024") 50 }) 51 52 it('BaseConversionTest_uint8ArrayToString_01', () => { 53 expect(uint8ArrayToString([21,31],false)).toEqual("2131") 54 }) 55 56 it('BaseConversionTest_uint8ArrayToString_02', () => { 57 expect(uint8ArrayToString([21,31],true)).toEqual("151f") 58 }) 59 60});