Test Cases for C_Sort_Tutorial C_Sort_Tutorial Test Cases for c_sort_tutorial Version 0.1 Document creation date: September 1st , 2010 Author Name: Mohit Kumar 1 Test Cases for C_Sort_Tutorial 1:- Validation Test Cases 1.1 -- File not present. 1.2 -- -f argument is not present. 1.3 -- File name given with –f argument 1.4 – Check for multiple –f not present. 1.5 – File does not have read permission. 1.6 – Extra argument given. 2:- Sorting Test Cases 2.1- File has only valid records 2.1-1. File is empty 2.1-2. File has one record 2.1-3. File has two already sorted records 2.1-4. File has ten records. 2.2- File has some invalid records. 2.2-1. File has one invalid record 2.2-2. File has one valid and one invalid record 2.2-3. File has more than one valid and invalid records 3:-Test Cases for debug_log 3.1-- -D given with 1 argument. 3.2-- -D given with 2 argument 3.3-- -D given with any other argument 4:- Performance Test Cases 3.1-- Check for when file contains 1000 records. 3.2-- Check for when file contains 10000 records. 3.3-- Check for when file contains 100000 records. 2 Test Cases for C_Sort_Tutorial 1. Test cases for Validation 1.1 Check if file not present. Expected Results:- Should produce an error that file is not present Actual Results:- Error : File is not present at specific location. Input :- ./c_sort_tutorial –f no_file.csv Output:- Error in opening input file. Filename = no_file.csv, Error = No such file or directory Test Result:- Pass 1.2 Check if –f argument not present. Expected Results:- Should produce an error that –f argument must be present. Actual Results:- Error: -f argument must be present and print usage. Input :- ./c_sort_tutorial students.csv Output:Error: Mandatory option -f is missing Usage : c_sort_tutorial -f <in_file_name> -D <debug level> -f : Should be given with the file name . -D : Optional parameter to enable debug log by specifying debug level. 0 mean debug off. 1 and 2 are debug level for debug on. Test Result:- Pass 1.3 Check for file name must be given with –f argument Expected Results:- Should produce an error that file name must be given with –f arguments. Actual Results:- Error: Option requires an argument –f Input :- ./c_sort_tutorial -f Output:option requires an argument -- f Error: Invalid arguments. Usage : c_sort_tutorial -f <in_file_name> -D <debug level> -f : Should be given with the file name . -D : Optional parameter to enable debug log by specifying debug level. 0 mean debug off. 1 and 2 are debug level for debug on. Test Result:- Pass 3 Test Cases for C_Sort_Tutorial 1.4 Check for multiple –f arguments Expected Results:- Should produce an error that –f argument must be specified once. Actual Results:- Error: -f option is specified more than once and print Usage Input :- ./c_sort_tutorial –f students.csv –f file_one_valid.csv Output:Error: -f option is specified more than once. Usage : c_sort_tutorial -f <in_file_name> -D <debug level> -f : Should be given with the file name . -D : Optional parameter to enable debug log by specifying debug level. 0 mean debug off. 1 and 2 are debug level for debug on. Test Result:- Pass 1.5 Check for file does have read permission Expected Results:- Should produce an error that error in opening file. Actual Results:- Error: error in opening file in read mode. Input: - ./c_sort_tutorial –f students.csv Output:Error in opening input file. Filename = no_file.csv Usage : c_sort_tutorial -f <in_file_name> -D <debug level> -f : Should be given with the file name . -D : Optional parameter to enable debug log by specifying debug level. 0 mean debug off. 1 and 2 are debug level for debug on. Test Result:- Pass 1.6 Check for any extra argument given Expected Results:- Should produce an error . Actual Results:- Error: Invalid arguments. Input: - ./c_sort_tutorial –f students.csv –t 4 Test Cases for C_Sort_Tutorial Output:invalid option -- t Error: Invalid arguments. Usage : c_sort_tutorial -f <in_file_name> -D <debug level> -f : Should be given with the file name . -D : Optional parameter to enable debug log by specifying debug level. 0 mean debug off. 1 and 2 are debug level for debug on. Test Result:- Pass 5 Test Cases for C_Sort_Tutorial 2. Sorting Test Cases 2.1 File has only valid parameters. 2.1.1 Check for file is empty Expected Results:-Should produce an warning that Input file is empty Actual Results:- Warning : Output file has no record. Input File:-file_empty.csv Output:Warning : Output file has no record.completed sorting of data. Total time taken = 0 seconds Output File:- file_empty.csv.sorted Test Result :- Pass 2.1.2 File has one record Expected Results:-Output file should contain one record. Actual Results:- Output file contains one record Input File:-file_one_valid.csv Mohit,80 Output:- completed sorting of data. Total time taken = 0 seconds Output File:- file_one_valid.csv.sorted Mohit,80 Test Result :- Pass 2.1.3 File has two record that are already sorted Expected Results:-Output file should contains two records in same order as in input file Actual Results:-Output file also contains two records. Input File:- file_two_sorted_record.csv Amit,90 Ram,60 Output:- completed sorting of data. Total time taken = 0 seconds 6 Test Cases for C_Sort_Tutorial Output File:- file_two_sorted_record.csv.sorted Amit,90 Ram,60 Test Result :- Pass 2.1.4 File has ten records. Expected Results:-Output file should also contain ten sorted records. Actual Results:- Output file contains ten sorted records. Input File:- file_ten_record.csv Amit,70 Raj,75 Kshitij,85 Neeraj,90 Mohit,70 Ankit,75 Divya,75 Neha,80 Anushree,86 Rajesh,89 Output:- completed sorting of data. Total time taken = 0 seconds Output File:- file_ten_record.csv.sorted Amit,70.00 Ankit,75.00 Anushree,86.00 Divya,75.00 Kshitij,85.00 Mohit,70.00 Neeraj,90.00 Neha,80.00 Raj,75.00 Rajesh,89.00 Test Result :- Pass 7 Test Cases for C_Sort_Tutorial 2.2 File has some invalid records. 2.2.1 File has one invalid record Expected Results:- Should produce a warning and Output file must be empty Actual Results:- Warning : Invalid line and Output file is empty. Input File:-file_one_invalid.csv Mohit Output:Warning: Invalid line (Mohit ) at line number 1. Ignored Warning : Output file has no record.completed sorting of data. Total time taken = 0 seconds Output File:- file_one_invalid.csv.sorted Test Result:- Pass 2.2.2 File has one valid and one invalid record. Expected Results:- Should produce warning and output file must contain the valid record. Actual Results:- Warning : Invalid line and output file has only one valid record. Input File:- file_one_valid_invalid.csv Mohit Ankit,80 Output:Warning: Invalid line (Mohit ) at line number 1. Ignored completed sorting of data. Total time taken = 0 seconds Output File:- file_one_valid_invalid.csv.sorted Ankit,80 8 Test Cases for C_Sort_Tutorial Test Results:- Pass 2.2.3 File has more than one valid and invalid records Expected Results:- Should produce warning for all invalid records and output file must contain valid record. Actual Results:- Warning : Invalid line for all invalid lines and output file has only valid and sorted records. Input File:- file_valid_invalid.csv Ankit,90 Mohit Raj,90 Sanjeev,90 Rajesh Neeraj,90 Mohit,80 Mohit,90 Output:Starting sorting of data Warning: Invalid line (Mohit ) at line number 2. Ignored Warning: Invalid line (Rajesh ) at line number 5. Ignored completed sorting of data. Total time taken = 0 seconds Output File:- file_valid_invalid.csv.sorted Ankit,90.00 Mohit,80.00 Mohit,90.00 Neeraj,90.00 Raj,90.00 Sanjeev,90.00 Test Results:- Pass 9 Test Cases for C_Sort_Tutorial 3. Test cases for Debug_Log 3.1-- -D given with 1 argument Expected Results:- Debug_log file must be generated but contains the high level log. Actual Results:- debug_log file created with the high level logs. Input Argument:- ./c_sort_tutorial –f students.csv –D 1 debug_log file:Absolute Time Stamp|File|Line|Function|Logs 09/08/10 06:51:28|c_sort_tutorial.c|234|save_sorted_data|Method called. output_file = students.csv.sortedAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 06:51:28|c_sort_tutorial.c|252|save_sorted_data|Saving record number = 1, name = Amit, percentage = 80.00 Absolute Time Stamp|File|Line|Function|Logs 09/08/10 06:51:28|c_sort_tutorial.c|252|save_sorted_data|Saving record number = 2, name = Dev, percentage = 85.00 Absolute Time Stamp|File|Line|Function|Logs 09/08/10 06:51:28|c_sort_tutorial.c|252|save_sorted_data|Saving record number = 3, name = Mohit, percentage = 90.00 Absolute Time Stamp|File|Line|Function|Logs 09/08/10 06:51:28|c_sort_tutorial.c|252|save_sorted_data|Saving record number = 4, name = Rakesh, percentage = 75.00 Absolute Time Stamp|File|Line|Function|Logs 09/08/10 06:51:28|c_sort_tutorial.c|252|save_sorted_data|Saving record number = 5, name = Ram, percentage = 70.00 Absolute Time Stamp|File|Line|Function|Logs 09/08/10 06:58:16|c_sort_tutorial.c|358|sort_data|Method calledAbsolute Time Stamp|File|Line|Function|Logs 10 Test Cases for C_Sort_Tutorial 09/08/10 06:58:16|c_sort_tutorial.c|362|sort_data|Opening input file students.csvAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 06:58:16|c_sort_tutorial.c|373|sort_data|Starting reading of file and storing data in memoryAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 06:58:16|c_sort_tutorial.c|318|add_record|Method calledAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 06:58:16|c_sort_tutorial.c|293|create_table_entry|MY_REALLOC'ed Student Table done. ptr = 0x8705598, size = 360 for index -1 Absolute Time Stamp|File|Line|Function|Logs Absolute Time Stamp|File|Line|Function|Logs 09/08/10 06:58:16|c_sort_tutorial.c|318|add_record|Method calledAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 06:58:16|c_sort_tutorial.c|318|add_record|Method calledAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 06:58:16|c_sort_tutorial.c|318|add_record|Method calledAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 06:58:16|c_sort_tutorial.c|318|add_record|Method calledAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 06:58:16|c_sort_tutorial.c|398|sort_data|Finished reading of file and storing data in memory. Total records = 5Absolute Time Stamp|File|Line|Function|Logs 09/08/10 06:58:16|c_sort_tutorial.c|400|sort_data|Starting sorting of data using qsort()Absolute Time Stamp|File|Line|Function|Logs 09/08/10 06:58:16|c_sort_tutorial.c|403|sort_data|Finished sorting of data using qsort()Absolute Time Stamp|File|Line|Function|Logs 09/08/10 06:58:16|c_sort_tutorial.c|234|save_sorted_data|Method called. output_file = students.csv.sorted Test Result:- Pass 11 Test Cases for C_Sort_Tutorial 3.2-- -D given with 2 argument. Expected Results:- Debug_log file must be generated but contains detailed log of execution. Actual Results:- debug_log file created with detailed logs. Input Argument:- ./ c_sort_tutorial –f students.csv –D 2 debug_log file:Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|358|sort_data|Method calledAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|362|sort_data|Opening input file students.csvAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|373|sort_data|Starting reading of file and storing data in memoryAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|318|add_record|Method calledAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|293|create_table_entry|MY_REALLOC'ed Student Table done. ptr = 0x879b598, size = 360 for index -1 Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|300|create_table_entry|row_num = 0, total = 1, max = 10, ptr = 77bf2d5c, size = 36, name = Student TableAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|332|add_record|Adding record number Mohit in memory. Name = (null), percentage = 0.000000Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|318|add_record|Method calledAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|300|create_table_entry|row_num = 1, total = 2, max = 10, ptr = 77bf2d5c, size = 36, name = Student TableAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|332|add_record|Adding record number Amit in memory. Name = (null), percentage = 0.000000Absolute Time Stamp|File|Line|Function|Logs 12 Test Cases for C_Sort_Tutorial 09/08/10 07:15:50|c_sort_tutorial.c|318|add_record|Method calledAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|300|create_table_entry|row_num = 2, total = 3, max = 10, ptr = 77bf2d5c, size = 36, name = Student TableAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|332|add_record|Adding record number Ram in memory. Name = (null), percentage = 0.000000Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|318|add_record|Method calledAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|300|create_table_entry|row_num = 3, total = 4, max = 10, ptr = 77bf2d5c, size = 36, name = Student TableAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|332|add_record|Adding record number Rakesh in memory. Name = (null), percentage = 0.000000Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|318|add_record|Method calledAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|300|create_table_entry|row_num = 4, total = 5, max = 10, ptr = 77bf2d5c, size = 36, name = Student TableAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|332|add_record|Adding record number Dev in memory. Name = (null), percentage = 0.000000Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|398|sort_data|Finished reading of file and storing data in memory. Total records = 5Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|400|sort_data|Starting sorting of data using qsort()Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|403|sort_data|Finished sorting of data using qsort()Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|234|save_sorted_data|Method called. output_file = students.csv.sortedAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|252|save_sorted_data|Saving record number = 1, name = Amit, percentage = 80.00 Absolute Time Stamp|File|Line|Function|Logs 13 Test Cases for C_Sort_Tutorial 09/08/10 07:15:50|c_sort_tutorial.c|252|save_sorted_data|Saving record number = 2, name = Dev, percentage = 85.00 Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|252|save_sorted_data|Saving record number = 3, name = Mohit, percentage = 90.00 Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|252|save_sorted_data|Saving record number = 4, name = Rakesh, percentage = 75.00 Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|252|save_sorted_data|Saving record number = 5, name = Ram, percentage = 70.00 Test Result:- Pass 3.3-- -D given with extra argument. Expected Results:- Should give a warning and debug_log file must not be generated. Actual Results:- debug_log file created with high level logs. Input Arguments:- ./c_sort_tutorial –f students.csv –D 3 debug_log file:Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|358|sort_data|Method calledAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|362|sort_data|Opening input file students.csvAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|373|sort_data|Starting reading of file and storing data in memoryAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|318|add_record|Method calledAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|293|create_table_entry|MY_REALLOC'ed Student Table done. ptr = 0x879b598, size = 360 for index -1 14 Test Cases for C_Sort_Tutorial Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|300|create_table_entry|row_num = 0, total = 1, max = 10, ptr = 77bf2d5c, size = 36, name = Student TableAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|332|add_record|Adding record number Mohit in memory. Name = (null), percentage = 0.000000Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|318|add_record|Method calledAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|300|create_table_entry|row_num = 1, total = 2, max = 10, ptr = 77bf2d5c, size = 36, name = Student TableAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|332|add_record|Adding record number Amit in memory. Name = (null), percentage = 0.000000Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|318|add_record|Method calledAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|300|create_table_entry|row_num = 2, total = 3, max = 10, ptr = 77bf2d5c, size = 36, name = Student TableAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|332|add_record|Adding record number Ram in memory. Name = (null), percentage = 0.000000Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|318|add_record|Method calledAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|300|create_table_entry|row_num = 3, total = 4, max = 10, ptr = 77bf2d5c, size = 36, name = Student TableAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|332|add_record|Adding record number Rakesh in memory. Name = (null), percentage = 0.000000Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|318|add_record|Method calledAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|300|create_table_entry|row_num = 4, total = 5, max = 10, ptr = 77bf2d5c, size = 36, name = Student TableAbsolute Time Stamp|File|Line|Function|Logs 15 Test Cases for C_Sort_Tutorial 09/08/10 07:15:50|c_sort_tutorial.c|332|add_record|Adding record number Dev in memory. Name = (null), percentage = 0.000000Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|398|sort_data|Finished reading of file and storing data in memory. Total records = 5Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|400|sort_data|Starting sorting of data using qsort()Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|403|sort_data|Finished sorting of data using qsort()Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|234|save_sorted_data|Method called. output_file = students.csv.sortedAbsolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|252|save_sorted_data|Saving record number = 1, name = Amit, percentage = 80.00 Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|252|save_sorted_data|Saving record number = 2, name = Dev, percentage = 85.00 Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|252|save_sorted_data|Saving record number = 3, name = Mohit, percentage = 90.00 Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|252|save_sorted_data|Saving record number = 4, name = Rakesh, percentage = 75.00 Absolute Time Stamp|File|Line|Function|Logs 09/08/10 07:15:50|c_sort_tutorial.c|252|save_sorted_data|Saving record number = 5, name = Ram, percentage = 70.00 Test Result:- Fail 16 Test Cases for C_Sort_Tutorial 4. Test cases to check the performance. 4.1—Check for performance if file contains 1000 records Expected Result:- Program must perform consistently for thousand entries in the file. Actual Result:Test Result:4.2—Check for performance if file contains 10000 records. Expected Results:- Program must perform consistently for ten thousand entries in the file. Actual Result:Test Result:4.3—Check for performance if file contains 100000 or more records. Expected Records:- Program must perform consistently for more than one lakh entries in the file. Actual Records:Test Result:- 17
© Copyright 2026 Paperzz