1/* 2 * Copyright (c) 2025 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 16import { DeepTypeUtils } from '../assert/deepEquals/DeepTypeUtils'; 17import { AnyType } from '../types/common'; 18class LogExpectError { 19 static getErrorMsg(matcherName: string, actualValue: AnyType, expect: AnyType, originMsg: string): string { 20 if (matcherName === 'assertNull') { 21 return 'expect not null, actualValue is ' + String(actualValue); 22 } 23 if (matcherName === 'assertTrue') { 24 return 'expect not true, actualValue is ' + String(actualValue); 25 } 26 if (matcherName === 'assertFalse') { 27 return 'expect not false, actualValue is ' + String(actualValue); 28 } 29 if (matcherName === 'assertEqual') { 30 return 'expect not Equal, actualValue is ' + String(actualValue) + ' equals ' + String(expect); 31 } 32 if (matcherName === 'assertContain') { 33 return 'expect not have, ' + String(actualValue) + ' have ' + String(expect); 34 } 35 if (matcherName === 'assertInstanceOf') { 36 return ( 37 'expect not InstanceOf, ' + String(actualValue) + ' is ' + DeepTypeUtils.getType(actualValue) + String(expect) 38 ); 39 } 40 if (matcherName === 'assertLarger') { 41 return 'expect not Larger, ' + String(actualValue) + ' is larger than ' + String(expect); 42 } 43 if (matcherName === 'assertLargerOrEqual') { 44 return 'expect not LargerOrEqual, ' + String(actualValue) + ' larger than ' + String(expect); 45 } 46 if (matcherName === 'assertLess') { 47 return 'expect not Less, ' + String(actualValue) + ' less than ' + String(expect); 48 } 49 if (matcherName === 'assertLessOrEqual') { 50 return 'expect not LessOrEqual, ' + String(actualValue) + ' is less than ' + String(expect); 51 } 52 if (matcherName === 'assertNaN') { 53 return 'expect not NaN, actualValue is ' + String(actualValue); 54 } 55 if (matcherName === 'assertNegUnlimited') { 56 return 'expect not NegUnlimited, actualValue is ' + String(actualValue); 57 } 58 if (matcherName === 'assertPosUnlimited') { 59 return 'expect not PosUnlimited, actualValue is ' + String(actualValue); 60 } 61 if (matcherName === 'assertUndefined') { 62 return 'expect not Undefined, actualValue is ' + String(actualValue); 63 } 64 return originMsg; 65 } 66} 67 68export { LogExpectError }; 69