Feature Testing
3. Feature Testing
The following features of the program are tested: • Read Data from files: The program reads a line at a time as a string from
the input file and parses the string and then applies the string functions to convert into an integer or a double. So it is very important that the form at is exactly as expected by the parser. The program throws appropriate the input file and parses the string and then applies the string functions to convert into an integer or a double. So it is very important that the form at is exactly as expected by the parser. The program throws appropriate
• Read program arguments: The program has two arguments, 1) The number of threads which can be 1, 2, 4 or 8 for a small system and 1,2,4,8 or 16 for a large system. The limit is 8 and 16, since the number of partitions in one direction is 8 for a small system and 16 for a large system. 2) An integer which specifies what system to simulate, 0 for small system and 1 for a large system. The program has to catch exceptions and throw an error, if the program has an incorrect number of arguments, or invalid arguments. The table at the end of this section lists the test cases where this feature of the program is tested.
• Formatting values for output: The program outputs the total energy, potential energy, kinetic energy and the temperatures at each step in a fixed format i.e. each of these fields are printed with a fixed spacing between them. If the length of one of the fields is larger than the spacing, an exception should be thrown. This in a way also indicates that the values are incorrectly calculated by the program, since usually the lengths of the fields fall within the space allocated for them. As a test case, the forces of each of the atoms are not initialized in the force () method of the program. So, the values of the potential energy and kinetic energy keep increasing until they are no longer small to be printed out in the desired format. This test case is shown in the following table.
The following table describes the test cases and the results:
Result Read Data from files
Test Unit
Test Case
md.dat input file with line 9 Error : Line 9 in the file in incorrect format
md.dat is not in the format expected.
Read Data from files vel.in input file with line 38 Error : Line 38in the file in incorrect format
vel.in is not in the format expected.
Read Data from files init_positions input file Error : Line 256 in the file with line 256 in incorrect init_positions is not in the format
format expected. Format values for output
Forces are not initialized.
Error: The values of the fields are too large to be printed.
Read program arguments
java mdpar/MdPar
Usage: java mdpar/MdPar arg1 arg2 where
arg1: number of threads = 1,2,4 or 8 for a small system
= 1,2,4,8 or 16 for large system
arg2: system identifier = 0 for small system = 1 for large system
Read Program arguments
java mdpar/MdPar 16 0
Error: Incorrect number of threads for the system chosen Usage: java mdpar/MdPar arg1 arg2 where
arg1: number of threads = 1,2,4 or 8 for a small system
= 1,2,4,8 or 16 for large system
arg2: system identifier = 0 for small system = 1 for large system
Read Program Arguments
Java mdpar/MdPar 4 3
Error: Incorrect choice for system identifier Usage : java mdpar/MdPar Error: Incorrect choice for system identifier Usage : java mdpar/MdPar
arg1: number of threads = 1,2,4 or 8 for a small system
= 1,2,4,8 or 16 for large system
arg2: system identifier = 0 for small system = 1 for large system
Table 7: Test Cases and Results