Test case conversion method of geometric engine, test method and related product
By identifying and converting the syntax forms of test cases, converting the test cases of TCL syntax forms into Python syntax forms, solving the problem that Open CASCADE platform test cases are difficult to apply to other modeling kernels, and achieving efficient and flexible programming and evaluation.
Patent Information
- Application Number
- CN202510220012.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-26
- Publication Date
- 2025-07-11
AI Technical Summary
In the prior art, test cases of the Open CASCADE platform are difficult to directly apply to other modeling cores, and test cases written in the TCL language have limitations in terms of modernization and ease of use, making it difficult to meet efficient and flexible programming needs.
By obtaining test cases of the first syntax form, identifying commands, parameters and key syntax elements, querying the mapping table to determine the corresponding commands and parameters of the second syntax form, and generating test cases of the second syntax form, which is specifically implemented to convert the TCL syntax form to Python syntax form.
It automatically converts geometry engine test cases with infrequent grammar forms into common grammar forms, meets the current efficient and flexible programming needs and supports a comprehensive evaluation of geometry engines.
Smart Images

Figure CN120295905A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of geometric engines, and particularly to a method for converting test cases of a geometric engine, a test method, and related products; wherein, the related products include: a test case conversion subsystem of a geometric engine, a test system for test cases, an electronic device, and a computer-readable storage medium. Background Art
[0002] In the field of computer-aided design (CAD, Computer Aided Design), geometric modeling kernels play a crucial role, which are mainly responsible for processing geometric data and performing various modeling operations. To comprehensively and effectively evaluate the capabilities of modeling kernels, a large number of test cases are required.
[0003] However, it is not easy to design a set of test cases that can accurately evaluate specific modeling capabilities, which requires designers to have profound industry knowledge and rich practical experience. In the well-known Open CASCADE (OCC, Open Cascade) platform, although a comprehensive set of test cases has been constructed, there is a tight binding relationship between this set of test cases and OCC, making it difficult to directly apply them to the performance evaluation of other modeling kernels. Moreover, these test cases are written in the TCL (Tool Command Language) language, and this programming language has certain limitations in terms of modernization and usability, making it difficult to meet the current high-efficiency and flexible programming requirements. Summary of the Invention
[0004] In view of the above problems, a method for converting test cases of a geometric engine, a test method, and related products that overcome the above problems or at least partially solve the above problems are provided, including:
[0005] A method for converting test cases of a geometric engine, the method includes:
[0006] Obtain a first test case in a first syntax form, and identify the first test case to obtain a first command, a first parameter, and a first other key syntax element;
[0007] Query a mapping table between the first syntax form and a second syntax form, and determine a second command in the second syntax form corresponding to the first command, a second parameter in the second syntax form corresponding to the first parameter, and a second other key syntax element in the second syntax form corresponding to the first other key syntax element;
[0008] Generate a second test case in the second syntax form according to the second command, the second parameter, and the second other key syntax element.
[0009] Optionally, identifying the first test case to obtain a first command, a first parameter, and a first other key syntax element, includes:
[0010] Identifying and analyzing the first test case through regular expressions and lexical analysis to obtain the first command, the first parameter, and the first other key syntax element.
[0011] Optionally, the method further includes:
[0012] Constructing a mapping table between a first syntax form and a second syntax form.
[0013] A test method for test cases, characterized in that the method includes:
[0014] Obtaining a first test case in a first syntax form and identifying the first test case to obtain a first command, a first parameter, and a first other key syntax element;
[0015] Querying the mapping table between the first syntax form and the second syntax form to determine a second command in the second syntax form corresponding to the first command, a second parameter in the second syntax form corresponding to the first parameter, and a second other key syntax element in the second syntax form corresponding to the first other key syntax element;
[0016] Generating a second test case in the second syntax form according to the second command, the second parameter, and the second other key syntax element;
[0017] Obtaining a first entity result corresponding to the first test case; and executing the second test case to obtain a second entity result;
[0018] Generating a test result for the second test case according to the first entity result and the second entity result.
[0019] Optionally, the obtaining the first entity result corresponding to the first test case includes:
[0020] When the output result corresponding to the first test case is a non-entity form result, converting the output result corresponding to the first test case into a first entity result in entity form.
[0021] Optionally, the generating the test result for the second test case according to the first entity result and the second entity result includes:
[0022] Determining the absolute value of the difference between the attribute value in the first entity result and the attribute value in the second entity result;
[0023] Generate a test result for the second test case according to the absolute value of the difference and the preset tolerance value.
[0024] An embodiment of the present invention further provides a test case conversion subsystem for a geometry engine. The test case conversion subsystem for the geometry engine includes:
[0025] A syntax parsing module, configured to obtain a first test case in a first syntax form, and identify the first test case to obtain a first command, a first parameter, and a first other key syntax element;
[0026] A conversion rule library module, configured to query a mapping table between the first syntax form and the second syntax form, and determine a second command in the second syntax form corresponding to the first command, a second parameter in the second syntax form corresponding to the first parameter, and a second other key syntax element in the second syntax form corresponding to the first other key syntax element;
[0027] A code generation module, configured to generate a second test case in the second syntax form according to the second command, the second parameter, and the second other key syntax element.
[0028] An embodiment of the present invention further provides a test system for test cases. The system includes: a test case conversion subsystem for a geometry engine and a test subsystem; wherein:
[0029] The test case conversion subsystem for the geometry engine includes:
[0030] A syntax parsing module, configured to obtain a first test case in a first syntax form, and identify the first test case to obtain a first command, a first parameter, and a first other key syntax element;
[0031] A conversion rule library module, configured to query a mapping table between the first syntax form and the second syntax form, and determine a second command in the second syntax form corresponding to the first command, a second parameter in the second syntax form corresponding to the first parameter, and a second other key syntax element in the second syntax form corresponding to the first other key syntax element;
[0032] A code generation module, configured to generate a second test case in the second syntax form according to the second command, the second parameter, and the second other key syntax element;
[0033] The test subsystem is configured to obtain a first entity result corresponding to the first test case; and execute the second test case to obtain a second entity result; and generate a test result for the second test case according to the first entity result and the second entity result.
[0034] An embodiment of the present invention further provides an electronic device, including a processor, a memory, and a computer program stored on the memory and capable of running on the processor. When the computer program is executed by the processor, the above method is implemented.
[0035] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the above method is implemented.
[0036] The embodiments of the present invention have the following advantages:
[0037] In an embodiment of the present invention, a first test case in a first syntax form is obtained, and the first test case is recognized to obtain a first command, a first parameter, and a first other key syntax element; a mapping table between the first syntax form and a second syntax form is queried to determine a second command in the second syntax form corresponding to the first command, a second parameter in the second syntax form corresponding to the first parameter, and a second other key syntax element in the second syntax form corresponding to the first other key syntax element; a second test case in the second syntax form is generated according to the second command, the second parameter, and the second other key syntax element. Through the embodiment of the present invention, the test cases of the geometry engine in an infrequently used syntax form can be automatically converted into the test cases of the geometry engine in a commonly used syntax form, so as to meet the current high-efficiency and flexible programming requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions of the present invention, the drawings required for the description of the present invention will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0039] Figure 1 is a flowchart of the steps of a method for converting test cases of a geometry engine according to an embodiment of the present invention;
[0040] Figure 2 is a flowchart of the steps of another method for converting test cases of a geometry engine according to an embodiment of the present invention;
[0041] Figure 3 is a flowchart of the steps of a method for converting test cases according to an embodiment of the present invention;
[0042] Figure 4 is a flowchart of the steps of a method for testing test cases according to an embodiment of the present invention;
[0043] Figure 5 is a flowchart of the steps of another method for testing test cases according to an embodiment of the present invention;
[0044] Figure 6 It is a step flowchart of a test case for an embodiment of the present invention;
[0045] Figure 7 It is a schematic structural diagram of a test case conversion subsystem of a geometric engine for an embodiment of the present invention;
[0046] Figure 8 It is a schematic structural diagram of a test system for a test case for an embodiment of the present invention. Detailed implementation manners
[0047] To make the above objects, features, and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific implementation manners. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of them. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts belong to the scope of protection of the present invention.
[0048] To meet the current high-efficiency and flexible programming requirements, an embodiment of the present invention provides a method for converting test cases of a geometric engine, which can automatically batch-convert test cases in the form of TCL syntax in OCC into test cases in the form of Python syntax. Specifically, reference can be made to Figure 1 , Figure 1 shows a step flowchart of a method for converting test cases of a geometric engine for an embodiment of the present invention.
[0049] As Figure 1 shown, the method for converting test cases of the geometric engine may include the following steps:
[0050] Step 101: Obtain a first test case in a first syntax form, and identify the first test case to obtain a first command, a first parameter, and a first other key syntax element.
[0051] In an embodiment of the present invention, a first test case in a first syntax form may be obtained first; wherein, the first syntax form may be in the form of TCL syntax, or may be other syntax forms that want to be converted into a second syntax form, and the embodiment of the present invention does not make specific limitations on this. The second syntax form may be in the form of Python syntax, or may be other syntax forms that want to be obtained, and the embodiment of the present invention also does not make specific limitations on this.
[0052] After obtaining the first test case, the first test case in the first syntax form may be opened first, and it may be identified and processed to split out a first command, a first parameter, and a first other key syntax element.
[0053] Taking, for example, the conversion of test cases in the TCL syntax form in OCC into test cases in the Python syntax form, the first command may be an OCC command, the first parameter may be a parameter corresponding to the OCC command, and the first other key syntax elements may be other TCL syntaxes, such as variable declarations, control flow statements, string operations, list / dictionary processing, etc., which are not limited in the embodiments of the present invention.
[0054] Step 102: Query the mapping table between the first syntax form and the second syntax form, and determine the second command in the second syntax form corresponding to the first command, the second parameter in the second syntax form corresponding to the first parameter, and the second other key syntax elements in the second syntax form corresponding to the first other key syntax elements.
[0055] After obtaining the first command, the first parameter, and the first other key syntax elements, the pre-constructed mapping table in which the first syntax form and the second syntax form have a mapping relationship can be queried to query the second parameter in the second syntax form corresponding to the first parameter in the first syntax form and the second other key syntax elements in the second syntax form corresponding to the first other key syntax elements in the first syntax form from the mapping table.
[0056] Step 103: Generate the second test case in the second syntax form according to the second command, the second parameter, and the second other key syntax elements.
[0057] Then, the second test case in the second syntax form can be automatically generated according to the obtained second command, second parameter, and second other key syntax elements; exemplarily, the first test case in the TCL syntax form can be converted into the second test case in the Python syntax form based on the mapping table.
[0058] In the embodiments of the present invention, the first test case in the first syntax form is obtained, and the first test case is identified to obtain the first command, the first parameter, and the first other key syntax elements; the mapping table between the first syntax form and the second syntax form is queried to determine the second command in the second syntax form corresponding to the first command, the second parameter in the second syntax form corresponding to the first parameter, and the second other key syntax elements in the second syntax form corresponding to the first other key syntax elements; the second test case in the second syntax form is generated according to the second command, the second parameter, and the second other key syntax elements. Through the embodiments of the present invention, the test cases of the geometric engine in an infrequently used syntax form can be automatically converted into the test cases of the geometric engine in a commonly used syntax form, so as to meet the current high-efficiency and flexible programming requirements.
[0059] Referring to Figure 2 , a flowchart of the steps of another method for converting test cases of a geometric engine according to an embodiment of the present invention is shown, which may include the following steps:
[0060] Step 201: Obtain the first test case in the first grammar form.
[0061] In an embodiment of the present invention, the first test case in the first grammar form can be obtained first; exemplarily, multiple first test cases can be obtained in batches for batch conversion.
[0062] Step 202: Identify and analyze the first test case through regular expressions and lexical analysis to obtain the first command, the first parameter, and the first other key grammar elements.
[0063] After obtaining the first test case in the first grammar form, the code of the first test case can be parsed line by line through regular expressions and lexical analysis techniques to identify and analyze the first command, the first parameter, and the first other key grammar elements therein.
[0064] Step 203: Query the mapping table between the first grammar form and the second grammar form to determine the second command in the second grammar form corresponding to the first command, the second parameter in the second grammar form corresponding to the first parameter, and the second other key grammar elements in the second grammar form corresponding to the first other key grammar elements.
[0065] After obtaining the first command, the first parameter, and the first other key grammar elements, the pre-constructed mapping table in which the first grammar form and the second grammar form have a mapping relationship can be queried to query the second parameter in the second grammar form corresponding to the first parameter in the first grammar form and the second other key grammar elements in the second grammar form corresponding to the first other key grammar elements in the first grammar form from the mapping table.
[0066] Step 204: Generate the second test case in the second grammar form according to the second command, the second parameter, and the second other key grammar elements.
[0067] Then, the second test case in the second grammar form can be automatically generated according to the obtained second command, the second parameter, and the second other key grammar elements; exemplarily, based on the mapping table, the first test case in the TCL grammar form can be converted into the second test case in the Python grammar form.
[0068] In an embodiment of the present invention, the above method may further include the following steps:
[0069] Construct a mapping table between the first grammar form and the second grammar form.
[0070] In some feasible embodiments, a mapping table between the first grammar form and the second grammar form can also be pre-constructed. Exemplarily:
[0071] For example, for the TCL variable declaration: set type "FACE", first find the set string, then record the variable name type and the value "FACE", and establish a mapping relationship. The corresponding Python code can be obtained as type = "FACE".
[0072] For example, for the TCL control flow statement: if{[expr $dx * $dx + $dy * $dy] < [expr $tolerance * $tolerance]}{XXX} else {XXX}.
[0073] The corresponding Python control flow statement: if dx * dx + dy * dy < tolerance * tolerance: XXX
[0074] else: XXX.
[0075] For example, for the TCL string operation: if{[string compare $type "FACE"] == 0}{XXX};
[0076] The corresponding Python string operation: if type == "FACE": XXX.
[0077] For example, for the TCL list declaration: set chamfid [list 8, 9, 10];
[0078] The Python list declaration: chamfid = {8, 9, 10}.
[0079] Exemplarily, such as Figure 3 As shown, the first test case in TCL syntax form can be opened first.
[0080] Then, use the line break character to split the file content of the first test case into lines, and further split and parse each line with spaces to extract the first keyword.
[0081] If the identified keyword belongs to the instruction set defined by OCC, extract the subsequent parameters according to the definition of this instruction.
[0082] If the keyword is a reserved word in TCL syntax, such as if, while, puts, set, etc., extract the parameters according to the corresponding syntax rules.
[0083] Finally, generate Python code according to the mapping table, and further generate the second test case in Python syntax form.
[0084] In an embodiment of the present invention, a first test case in a first syntax form is obtained; through regular expressions and lexical analysis, the first test case is identified and analyzed to obtain a first command, a first parameter, and a first other key syntax element; a mapping table between the first syntax form and a second syntax form is queried to determine a second command in the second syntax form corresponding to the first command, a second parameter in the second syntax form corresponding to the first parameter, and a second other key syntax element in the second syntax form corresponding to the first other key syntax element; a second test case in the second syntax form is generated according to the second command, the second parameter, and the second other key syntax element. Through the embodiment of the present invention, the test case of the geometric engine in an infrequently used syntax form can be automatically converted into the test case of the geometric engine in a commonly used syntax form, so as to meet the current efficient and flexible programming requirements.
[0085] The following is a further description from the perspective of test case testing. Specifically:
[0086] Refer to Figure 4 , which shows a flowchart of the steps of a test method for a test case according to an embodiment of the present invention, and may include the following steps:
[0087] Step 401, obtain a first test case in a first syntax form, and identify the first test case to obtain a first command, a first parameter, and a first other key syntax element.
[0088] In an embodiment of the present invention, a first test case in a first syntax form may be obtained first; after obtaining the first test case, the first test case in the first syntax form may be opened first, and it may be identified and processed to split and obtain a first command, a first parameter, and a first other key syntax element.
[0089] Step 402, query a mapping table between the first syntax form and a second syntax form, and determine a second command in the second syntax form corresponding to the first command, a second parameter in the second syntax form corresponding to the first parameter, and a second other key syntax element in the second syntax form corresponding to the first other key syntax element.
[0090] After obtaining the first command, the first parameter, and the first other key syntax element, a pre-constructed mapping table in which the first syntax form and the second syntax form have a mapping relationship may be queried to query from the mapping table the first parameter in the second syntax form corresponding to the first parameter of the first syntax form, and the first other key syntax element in the second syntax form corresponding to the first other key syntax element of the first syntax form.
[0091] Step 403, generate a second test case in the second syntax form according to the second command, the second parameter, and the second other key syntax element.
[0092] Then, according to the obtained second command, second parameter, and second other key syntax elements, a second test case in the second syntax form can be automatically generated; exemplarily, based on the mapping table, the first test case in the TCL syntax form can be converted into a second test case in the Python syntax form.
[0093] Step 404: Obtain the first entity result corresponding to the first test case; and execute the second test case to obtain the second entity result.
[0094] After obtaining the first test case, the first entity result corresponding to the first test case can be obtained; the first entity result can be the parameters of the model output by the geometry engine based on the first test case, for example: the surface area, volume, centroid, offset, line length, etc. of the model, which are not limited in the embodiments of the present invention.
[0095] In addition, after converting to obtain the second test case, the corresponding second test case can also be run in the OCC modeling kernel, and the second entity result output by the OCC modeling kernel can be obtained. The second entity result is similar to the first entity result and will not be elaborated here.
[0096] Step 405: Generate a test result for the second test case according to the first entity result and the second entity result.
[0097] After obtaining the first entity result and the second entity result, the second test case can be evaluated by comparing the first entity result and the second entity result; specifically, the similarity between the first entity result and the second entity result can be compared to determine whether the second test case can complete the test of the geometry engine as effectively as the first test case.
[0098] In the embodiments of the present invention, the first test case in the first syntax form is obtained, and the first test case is recognized to obtain the first command, the first parameter, and the first other key syntax elements; the mapping table between the first syntax form and the second syntax form is queried to determine the second command in the second syntax form corresponding to the first command, the second parameter in the second syntax form corresponding to the first parameter, and the second other key syntax elements in the second syntax form corresponding to the first other key syntax elements; a second test case in the second syntax form is generated according to the second command, the second parameter, and the second other key syntax elements; the first entity result corresponding to the first test case is obtained; and the second test case is executed to obtain the second entity result; a test result for the second test case is generated according to the first entity result and the second entity result. Through the embodiments of the present invention, the test cases of the geometry engine in an infrequently used syntax form can be automatically converted into the test cases of the geometry engine in a commonly used syntax form and corresponding tests can be performed, thereby meeting the current efficient and flexible programming requirements.
[0099] Reference Figure 5 , a step flowchart of a test method for another test case according to an embodiment of the present invention is shown, which may include the following steps:
[0100] Step 501, obtain a first test case in a first syntax form, and identify the first test case to obtain a first command, a first parameter, and a first other key syntax element.
[0101] In an embodiment of the present invention, a first test case in a first syntax form may be obtained first; after obtaining the first test case, the first test case in the first syntax form may be opened first, and it may be identified and processed to split the first command, the first parameter, and the first other key syntax element.
[0102] Step 502, query a mapping table between the first syntax form and the second syntax form, and determine a second command in the second syntax form corresponding to the first command, a second parameter in the second syntax form corresponding to the first parameter, and a second other key syntax element in the second syntax form corresponding to the first other key syntax element.
[0103] After obtaining the first command, the first parameter, and the first other key syntax element, a pre-constructed mapping table in which the first syntax form and the second syntax form have a mapping relationship may be queried to query, from the mapping table, a first parameter in the second syntax form corresponding to the first parameter in the first syntax form, and a first other key syntax element in the second syntax form corresponding to the first other key syntax element in the first syntax form.
[0104] Step 503, generate a second test case in the second syntax form according to the second command, the second parameter, and the second other key syntax element.
[0105] Then, a second test case in the second syntax form may be automatically generated according to the obtained second command, second parameter, and second other key syntax element; exemplarily, based on the mapping table, a first test case in the TCL syntax form may be converted into a second test case in the Python syntax form.
[0106] Step 504, when the output result corresponding to the first test case is a non-entity form result, convert the output result corresponding to the first test case into a first entity result in an entity form.
[0107] After obtaining the first test case, it can be first determined whether the output result obtained from the first test case in the TCL syntax form provided by OCC is in entity form, that is, whether the output result is a topological entity of a geometric object. If not, that is, the output result corresponding to the first test case is a non-entity form result, the output result corresponding to the first test case can be first converted into a first entity result in entity form.
[0108] Exemplarily, the non-entity form result can be converted into the first entity result in entity form by adding mkface or mkedge commands.
[0109] In practical applications, the first entity result can also be obtained by directly running the first test case using OCC's draw or batch-running the first test case using testgird in draw, and exporting it to a brep file. The embodiments of the present invention do not limit this.
[0110] Step 505: Execute the second test case to obtain a second entity result.
[0111] After converting and obtaining the second test case, the corresponding second test case can be run in the OCC modeling kernel, and the second entity result output by the OCC modeling kernel can be obtained.
[0112] Step 506: Determine the absolute value of the difference between the attribute values in the first entity result and the attribute values in the second entity result.
[0113] After obtaining the first entity result and the second entity result, the attribute values in the first entity result and the attribute values in the second entity result can be determined; among them, the attribute values can include surface area, volume, centroid, offset, line length, etc.
[0114] Then, the attribute values of the first entity result and the second entity result can be compared, and the absolute value of the difference corresponding to each attribute value can be obtained.
[0115] Step 507: Generate a test result for the second test case according to the absolute value of the difference and the preset tolerance value.
[0116] After obtaining the absolute value of the difference, the magnitude relationship between the absolute value of the difference and the preset tolerance value can be compared. If the absolute values of the differences corresponding to all attribute values are less than the preset tolerance value, a test result that the second test case passes on the geometric engine can be generated.
[0117] Among them, a preset tolerance value such as 1.0e-6 can be formulated. For example, compare the absolute value of the difference in surface area with the preset tolerance value:
[0118] abs(Result1.Area - Result2.Area) < 1.e-6; If the differences of all attribute values satisfy being less than the tolerance value, then this second test case passes on the OCC kernel.
[0119] Exemplarily, as Figure 6 shown:
[0120] 1. In the first test case in the TCL syntax form provided by OCC, if the obtained output result is not in the entity form, the result can be converted to the first entity result by adding the mkface or mkedge command, and the materialized result is exported to a file using the bsave statement.
[0121] 2. Use OCC's draw to directly run or batch run the first test case in draw using testgird, and generate the first entity result and export it to a brep file.
[0122] 3. Convert the first test case into the corresponding second test case in Python syntax form by converting the TCL syntax test case of OCC into a Python syntax test case.
[0123] 4. Import the brep file in the OCC modeling kernel, and record the relevant model parameters (i.e., the attribute values in the first entity result) as Result1.
[0124] 5. Run the corresponding Python test case in the OCC modeling kernel, and record the relevant model parameters as Result2 (i.e., the attribute values in the second entity result).
[0125] Compare whether each attribute value of Result1 and Result2 conforms to the tolerance value. If all conform, it means the second test case passes the test
[0126] In an embodiment of the present invention, a first test case in a first syntax form is obtained, and the first test case is recognized to obtain a first command, a first parameter, and a first other key syntax element; a mapping table between the first syntax form and a second syntax form is queried to determine a second command in the second syntax form corresponding to the first command, a second parameter in the second syntax form corresponding to the first parameter, and a second other key syntax element in the second syntax form corresponding to the first other key syntax element; a second test case in the second syntax form is generated according to the second command, the second parameter, and the second other key syntax element; when the output result corresponding to the first test case is a non-entity form result, the output result corresponding to the first test case is converted into a first entity result in an entity form; the second test case is executed to obtain a second entity result; the absolute value of the difference between the attribute value in the first entity result and the attribute value in the second entity result is determined; a test result for the second test case is generated according to the absolute value of the difference and a preset tolerance value. Through the embodiment of the present invention, the test case of the geometry engine in an infrequently used syntax form can be automatically converted into the test case of the geometry engine in a commonly used syntax form and corresponding tests are performed, so as to meet the current efficient and flexible programming requirements.
[0127] It should be noted that, for the method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the embodiments of the present invention are not limited by the described action sequence, because according to the embodiments of the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.
[0128] Referring to Figure 7 , a structural schematic diagram of a test case conversion subsystem of a geometry engine according to an embodiment of the present invention is shown, which may include the following modules:
[0129] A syntax parsing module 701, configured to obtain a first test case in a first syntax form and recognize the first test case to obtain a first command, a first parameter, and a first other key syntax element;
[0130] A conversion rule library module 702, configured to query a mapping table between the first syntax form and a second syntax form to determine a second command in the second syntax form corresponding to the first command, a second parameter in the second syntax form corresponding to the first parameter, and a second other key syntax element in the second syntax form corresponding to the first other key syntax element;
[0131] A code generation module 703, configured to generate a second test case in the second syntax form according to the second command, the second parameter, and the second other key syntax element.
[0132] In an alternative embodiment of the present invention, the syntax parsing module 701 is configured to identify and analyze the first test case through regular expressions and lexical analysis to obtain a first command, a first parameter, and a first other key syntax element.
[0133] In an alternative embodiment of the present invention, the conversion rule library module 702 is further configured to construct a mapping table between the first syntax form and the second syntax form.
[0134] In an embodiment of the present invention, a first test case in a first syntax form is obtained and identified to obtain a first command, a first parameter, and a first other key syntax element; a mapping table between the first syntax form and the second syntax form is queried to determine a second command in the second syntax form corresponding to the first command, a second parameter in the second syntax form corresponding to the first parameter, and a second other key syntax element in the second syntax form corresponding to the first other key syntax element; a second test case in the second syntax form is generated according to the second command, the second parameter, and the second other key syntax element. Through the present invention, the test cases of the geometry engine in an infrequently used syntax form can be automatically converted into the test cases of the geometry engine in a commonly used syntax form, thereby meeting the current efficient and flexible programming requirements.
[0135] Refer to Figure 8 , which shows a schematic structural diagram of a test system 800 for a test case of an embodiment of the present invention, may include: a test case conversion subsystem 70 of a geometry engine and a test subsystem 80; wherein:
[0136] The test case conversion subsystem 70 of the geometry engine includes:
[0137] The syntax parsing module 701 is configured to obtain a first test case in a first syntax form and identify the first test case to obtain a first command, a first parameter, and a first other key syntax element;
[0138] The conversion rule library module 702 is configured to query a mapping table between the first syntax form and the second syntax form to determine a second command in the second syntax form corresponding to the first command, a second parameter in the second syntax form corresponding to the first parameter, and a second other key syntax element in the second syntax form corresponding to the first other key syntax element;
[0139] The code generation module 703 is configured to generate a second test case in the second syntax form according to the second command, the second parameter, and the second other key syntax element;
[0140] A test subsystem 80 is configured to obtain a first entity result corresponding to a first test case; and execute a second test case to obtain a second entity result; generate a test result for the second test case according to the first entity result and the second entity result.
[0141] In an optional embodiment of the present invention, a syntax parsing module 701 is configured to convert the output result corresponding to the first test case into a first entity result in entity form when the output result corresponding to the first test case is a non-entity form result.
[0142] In an optional embodiment of the present invention, the test subsystem 80 is configured to determine the absolute value of the difference between the attribute value in the first entity result and the attribute value in the second entity result; generate a test result for the second test case according to the absolute value of the difference and a preset tolerance value.
[0143] In an embodiment of the present invention, a first test case in a first syntax form is obtained, and the first test case is recognized to obtain a first command, a first parameter, and a first other key syntax element; a mapping table of the first syntax form and a second syntax form is queried to determine a second command in the second syntax form corresponding to the first command, a second parameter in the second syntax form corresponding to the first parameter, and a second other key syntax element in the second syntax form corresponding to the first other key syntax element; a second test case in the second syntax form is generated according to the second command, the second parameter, and the second other key syntax element; when the output result corresponding to the first test case is a non-entity form result, the output result corresponding to the first test case is converted into a first entity result in entity form; the second test case is executed to obtain a second entity result; the absolute value of the difference between the attribute value in the first entity result and the attribute value in the second entity result is determined; a test result for the second test case is generated according to the absolute value of the difference and a preset tolerance value. Through the embodiment of the present invention, the test cases of the geometric engine in an infrequently used syntax form can be automatically converted into the test cases of the geometric engine in a commonly used syntax form and corresponding tests are performed, so as to meet the current high-efficiency and flexible programming requirements.
[0144] An embodiment of the present invention further provides an electronic device, including a processor, a memory, and a computer program stored on the memory and capable of running on the processor. When the computer program is executed by the processor, the above method is implemented.
[0145] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the above method is implemented.
[0146] For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple. For related parts, refer to the partial description of the method embodiment.
[0147] Each embodiment in this specification is described in a progressive manner. The key point of each embodiment is to illustrate the differences from other embodiments. For the same or similar parts among the embodiments, reference can be made to each other.
[0148] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a device, or a computer program product. Therefore, the embodiments of the present invention can take the form of an all-hardware embodiment, an all-software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0149] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram can be implemented by computer program instructions, and the combination of the flows and / or blocks in the flowchart and / or block diagram can also be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal devices generate a device for implementing the specified functions in one Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0150] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured product including an instruction device, and the instruction device implements the specified functions in one Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0151] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device, so that a series of operation steps are executed on the computer or other programmable terminal device to generate a computer-implemented process. Thus, the instructions executed on the computer or other programmable terminal device provide steps for implementing the specified functions in one Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0152] Although the preferred embodiments of the embodiments of the present invention have been described, additional changes and modifications can be made by those skilled in the art once they learn the basic creative concept. Therefore, the appended claims are intended to be construed to include the preferred embodiments as well as all changes and modifications that fall within the scope of the embodiments of the present invention.
[0153] Finally, it should also be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or terminal device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or elements inherent to such process, method, article or terminal device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or terminal device comprising the element.
[0154] The above has introduced in detail a method for converting test cases of a geometric engine, a test method, and related products. Specific examples are used in this text to elaborate on the principles and implementation manners of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to the present invention.
Claims
1. A method for converting test cases of a geometric engine, characterized in that The method includes: Obtain a first test case in a first syntax form, and identify the first test case to obtain a first command, a first parameter, and a first other key syntax element; Query a mapping table between the first syntax form and the second syntax form, and determine a second command in the second syntax form corresponding to the first command, a second parameter in the second syntax form corresponding to the first parameter, and a second other key syntax element in the second syntax form corresponding to the first other key syntax element; Generate a second test case in the second syntax form according to the second command, the second parameter, and the second other key syntax element.
2. The method according to claim 1, characterized in that, The identifying the first test case to obtain a first command, a first parameter, and a first other key syntax element includes: Identify and analyze the first test case through regular expressions and lexical analysis to obtain the first command, the first parameter, and the first other key syntax element.
3. The method according to claim 1, wherein The method further includes: Construct a mapping table between the first syntax form and the second syntax form.
4. A test method for test cases, characterized in that, The method includes: Obtain a first test case in a first syntax form, and identify the first test case to obtain a first command, a first parameter, and a first other key syntax element; Query a mapping table between the first syntax form and the second syntax form, and determine a second command in the second syntax form corresponding to the first command, a second parameter in the second syntax form corresponding to the first parameter, and a second other key syntax element in the second syntax form corresponding to the first other key syntax element; Generate a second test case in the second syntax form according to the second command, the second parameter, and the second other key syntax element; Obtain a first entity result corresponding to the first test case; and execute the second test case to obtain a second entity result; Generate a test result for the second test case according to the first entity result and the second entity result.
5. The method according to claim 4, characterized in that, The obtaining the first entity result corresponding to the first test case includes: When the output result corresponding to the first test case is a non-entity form result, convert the output result corresponding to the first test case into a first entity result in entity form.
6. The method according to claim 4, wherein The generating a test result for the second test case according to the first entity result and the second entity result includes: Determine the absolute value of the difference between the attribute value in the first entity result and the attribute value in the second entity result; Generate a test result for the second test case according to the absolute value of the difference and a preset tolerance value.
7. A test case conversion subsystem for a geometric engine, characterized in that, The test case conversion subsystem of the geometric engine includes: A syntax parsing module, configured to obtain a first test case in a first syntax form, and identify the first test case to obtain a first command, a first parameter, and a first other key syntax element; A conversion rule library module, which is used to query the mapping table between the first syntax form and the second syntax form, and determine the second command in the second syntax form corresponding to the first command, the second parameter in the second syntax form corresponding to the first parameter, and the second other key syntax element in the second syntax form corresponding to the first other key syntax element; A code generation module, which is used to generate a second test case in the second syntax form according to the second command, the second parameter, and the second other key syntax element; 8. A test system for test cases, characterized in that, The system includes: a test case conversion subsystem and a test subsystem of a geometry engine; where: The test case conversion subsystem of the geometry engine includes: A syntax parsing module, which is used to obtain a first test case in the first syntax form, and identify the first test case to obtain a first command, a first parameter, and a first other key syntax element; A conversion rule library module, which is used to query the mapping table between the first syntax form and the second syntax form, and determine the second command in the second syntax form corresponding to the first command, the second parameter in the second syntax form corresponding to the first parameter, and the second other key syntax element in the second syntax form corresponding to the first other key syntax element; A code generation module, which is used to generate a second test case in the second syntax form according to the second command, the second parameter, and the second other key syntax element; The test subsystem is used to obtain a first entity result corresponding to the first test case; and execute the second test case to obtain a second entity result; generate a test result for the second test case according to the first entity result and the second entity result.
9. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored on the memory and capable of running on the processor. When the computer program is executed by the processor, the method described in any one of claims 1 to 6 is implemented.
10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium. When the computer program is executed by the processor, the method described in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Semantic identification and automatic generation method for spacecraft test script
CN102541730A
Automatic testing program conversion method
CN103942140A
A test case conversion method and device
CN109739758A
Test method and device, electronic equipment and vehicle
CN119441015A
Validation of code translation using intermediate representation
US20250004909A1