1/** 2 * Copyright (c) 2021-2024 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 16{%- for number, param in item.param_list.items() %} 17const TEST_DATA_{{.number|upper}} : {{.item.param_init_data_types[number]}} = {{.item.param_list[number]}}; 18{%- endfor %} 19const TEST_DATA_EXPECTED : {{.item.expected_data_type}} = {{.item.expected_test_data}}; 20 21function main(): int { 22{%- if item.max_attempt is defined %} 23 let max_test : int = {{.item.max_attempt}} 24{%- else %} 25 let max_test : int = TEST_DATA_EXPECTED.length; 26{%- endif %} 27 let passed_counter : int = 0; 28 for (let i = 0; i < max_test; i++) { 29 {%- for number, param in item.param_list.items() %} 30 let {{.number}} : {{.item.param_types[number]}} = (TEST_DATA_{{.number|upper}}[i]); 31 printData("{{.number}}", {{.number}}); 32 {%- endfor %} 33 {%- if item.verify_region is not defined %} 34 let expected = TEST_DATA_EXPECTED[i] 35 {% endif %} 36 {%- if item.method_return_type != "void" %} 37 let actual : {{.item.method_return_type}} = {{.item.method_name}}({{.item.param_list.keys()|list|join(', ')}}); 38 {%- else %} 39 {{.item.method_name}}({{.item.param_list.keys()|list|join(', ')}}); 40 let actual : {{.item.param_types[item.result_storage]}} = {{.item.result_storage}} 41 {%- endif %} 42 printActualData(actual) 43 printExpectedData(TEST_DATA_EXPECTED[i]) 44 if ({{.item.verify_test_result_function}}(actual, expected)) { 45 console.print("PASSED"); 46 passed_counter++; 47 } else { 48 console.print("FAILED") 49 } 50 console.println(); 51 } 52 assertEQ(passed_counter, max_test) 53 return 0; 54} 55