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