In: Computer Science
specifications for Tasks:
1. Write a program which accepts a list of integers which may contain duplicated integers, and which outputs the input list as a sorted list in ascending order without duplication You can use either Ruby, C, C++, C# or Java to implement your program (referred to as P).
2. Design a test suite of 10 test cases (referred to as TC). Each test case has not more than 20 integers.
3. Test P against TC to make sure that your P passes every test case of TC prior to continuing the other tasks.
4. Manually construct two non-equivalent mutants for P (referred to M1 and M2).
5. Choose 2 MRs that you developed in Assignment 1 (referred to as MR1 and MR2).
6. Compute the effectiveness for MR1 and MR2 using M1, M2 and the test cases in TC as their source test cases.
7. You are required to submit a report which must contain at least the followings items:
a. Program listing of P.
b. A description of all elements of TC. 2
c. A description of the mutated statements in P for mutants M1 and M2. Note that you need not to give the complete program listings for mutants M1 and M2. You are only required to point out which statements in P are changed and how are they changed to construct M1 and M2.
d. Explain the process that you applied to guarantee that your M1 and M2 are nonequivalent mutants.
e. Explain with sufficient details on how the effectiveness for MR1 and MR2 are calculated, using the metric of expected ratio of violations.
f. Discuss and interpret your results about the effectiveness for MR1 and MR2.
This answer contain answer for first 3 parts.
1. Please find the below code in C#
using System;
using System.Collections.Generic;
using System.Linq;
namespace SortingPgm
{
class Sorting
{
static void Sorting_number(List<int> a)
{
List<int> q;
q = a.Distinct().ToList();
q.Sort();
Console.WriteLine("Sorted List: ");
for (int i = 0; i < q.Count; i++)
{
Console.WriteLine(q[i]);
}
}
static void Main(string[] args)
{
List<int> q=new List<int>();
Console.WriteLine("Enter number of elemets");
int n = Convert.ToInt32(Console.ReadLine());
if (n > 20) { Console.WriteLine("Out of limit"); }
else
{
Console.WriteLine("Enter the elemets");
for (int i = 0; i < n; i++)
{
q.Add(Convert.ToInt32(Console.ReadLine()));
}
}
Sorting_number(q);
Console.ReadLine();
}
}
}
2.Test suit
Test case |
Description |
Steps |
Expected Result |
Actual Result |
Pass/fail |
|
1 |
List with size 1 |
Test for list with one element |
1 . Enter number of element 1 2. enter 20 in keyboard |
Sorted list is: 20 |
||
2 |
List with duplicate elements |
Test for list with duplicate elements |
1.Enter the number of element 5 2.Enter 1 2 3 1 5 |
Sorted list is: 1 2 3 5 |
||
3 |
List without duplicate elements |
Test for list without duplicate elements |
1.Enter the number of element 6 2.Enter the elements 1 5 8 7 9 3 |
Sorted list is:1 3 5 7 8 9 |
||
4 |
List with sorted elements |
Test for list with elements are sorted in ascending order |
1.Enter the number of element 6 2.Enter the elements 1 3 5 7 8 9 |
Sorted list is:1 3 5 7 8 9 |
||
5 |
List with maximum number |
Test for list with maximum number of elements |
1.Enter the number of element 20 2.Enter the elements 1 2 3 4 1 2 3 4 5 9 6 7 8 5 2 3 4 5 6 7 |
Sorted list is: 1 2 3 4 5 6 7 8 9 |
||
6 |
List without elements |
Test for empty list |
1.Enter he number of elements 0 |
Sorted list is: |
||
7 |
List with sorted elements |
Test for list with elements are sorted in descending order |
1.Enter the number of element 6 2.Enter the elements 9 8 7 5 3 1 |
Sorted list is:1 3 5 7 8 9 |
||
8 |
List with negative numbers |
Test for list with negative numbers |
1.Enter the number of element 6 2.Enter the elements 9 8 7 -5 3 1 |
Sorted list is:--5 1 3 7 8 9 |
||
9 |
List with floating point numbers |
Test for list with floating point numbers |
1.Enter the number of element 6 2.Enter the elements 1.1 |
Raise exception |
||
10 |
List with more than 20 numbers |
Test for list more than 20 |
1.Enter the number of element 21 |
Display message out of limit |
3.
Please find below table contain result of test case test againts the program
Test case |
Description |
Steps |
Expected Result |
Actual Result |
Pass/fail |
Screenshot |
|
1 |
List with size 1 |
Test for list with one element |
1 . Enter number of element 1 2. enter 20 in keyboard |
Sorted list: 20 |
Sorted list is: 20 |
Pass |
|
2 |
List with duplicate elements |
Test for list with duplicate elements |
1.Enter the number of element 5 2.Enter 1 2 3 1 5 |
Sorted list : 1 2 3 5 |
Sorted list : 1 2 3 5 |
Pass |
|
3 |
List without duplicate elements |
Test for list without duplicate elements |
1.Enter the number of element 6 2.Enter the elements 1 5 8 7 9 3 |
Sorted list :1 3 5 7 8 9 |
Sorted list :1 3 5 7 8 9 |
Pass |
|
4 |
List with sorted elements |
Test for list with elements are sorted in ascending order |
1.Enter the number of element 6 2.Enter the elements 1 3 5 6 7 8 |
Sorted list :1 3 5 6 7 8 |
Sorted list :1 3 5 6 7 8 |
Pass |
|
5 |
List with maximum number |
Test for list with maximum number of elements |
1.Enter the number of element 20 2.Enter the elements 1 2 3 4 1 2 3 4 5 9 6 7 8 5 2 3 4 5 6 7 |
Sorted list : 1 2 3 4 5 6 7 8 9 |
Sorted list : 1 2 3 4 5 6 7 8 9 |
Pass |
|
6 |
List without elements |
Test for empty list |
1.Enter the number of elements 0 |
Sorted list : |
Sorted list : |
Pass |
|
7 |
List with sorted elements |
Test for list with elements are sorted in descending order |
1.Enter the number of element 6 2.Enter the elements 9 8 7 5 3 1 |
Sorted list : 1 3 5 7 8 9 |
Sorted list : 1 3 5 7 8 9 |
Pass |
|
8 |
List with negative numbers |
Test for list with negative numbers |
1.Enter the number of element 6 2.Enter the elements 9 8 7 -5 3 1 |
Sorted list is:--5 1 3 7 8 9 |
Sorted list is:--5 1 3 7 8 9 |
Pass |
|
9 |
List with floating point numbers |
Test for list with floating point numbers |
1.Enter the number of element 6 2.Enter the elements 1.1 |
Raise exception |
Exception raised |
Pass |
|
10 |
List with more than 20 numbers |
Test for list more than 20 |
1.Enter the number of element 21 |
Display message out of limit Sorted List: |
out of limit Sorted List: |
Pass |