ga6 done
This commit is contained in:
parent
0ca300b35f
commit
a22f8bb6cb
4 changed files with 36 additions and 8 deletions
28
SQ-2023-H6/answer.md
Normal file
28
SQ-2023-H6/answer.md
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
---
|
||||||
|
title: Software Quality & Testing -- Graded Assignment 6
|
||||||
|
author: Claudio Maggioni
|
||||||
|
geometry: margin=2.5cm,bottom=3cm
|
||||||
|
---
|
||||||
|
|
||||||
|
# Are there mutants that you cannot kill?
|
||||||
|
|
||||||
|
Yes.
|
||||||
|
|
||||||
|
# If yes, why and which are mutants that you cannot kill?
|
||||||
|
|
||||||
|
The mutants I cannot kill are:
|
||||||
|
|
||||||
|
```
|
||||||
|
replaced boolean return with true for org/usi/sq/util/CircularFifoQueue::offer → SURVIVED
|
||||||
|
```
|
||||||
|
|
||||||
|
at line 135 (which is impossible to kill since the parent method always returns true, thus
|
||||||
|
the mutant is semantically equivalent to the implementation), and:
|
||||||
|
|
||||||
|
```
|
||||||
|
changed conditional boundary → SURVIVED
|
||||||
|
changed conditional boundary → SURVIVED
|
||||||
|
negated conditional → SURVIVED
|
||||||
|
```
|
||||||
|
|
||||||
|
for `if (start < lastReturnedIndex && pos < end)` at line 251.
|
BIN
SQ-2023-H6/answer.pdf
Normal file
BIN
SQ-2023-H6/answer.pdf
Normal file
Binary file not shown.
BIN
SQ-2023-H6/report.pdf
Normal file
BIN
SQ-2023-H6/report.pdf
Normal file
Binary file not shown.
|
@ -8,23 +8,23 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
class CircularFifoQueueTest {
|
class CircularFifoQueueTest {
|
||||||
|
|
||||||
private void testIteratorEmpty(Iterator<?> it) {
|
private void testIteratorEmpty(final Iterator<?> it) {
|
||||||
assertFalse(it.hasNext());
|
assertFalse(it.hasNext());
|
||||||
assertThrows(NoSuchElementException.class, it::next);
|
assertThrows(NoSuchElementException.class, it::next);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> void testIteratorNext(Iterator<T> it, T e) {
|
private <T> void testIteratorNext(final Iterator<T> it, final T e) {
|
||||||
assertTrue(it.hasNext());
|
assertTrue(it.hasNext());
|
||||||
assertEquals(e, it.next());
|
assertEquals(e, it.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> void testQueue(int initQueueSize, List<T> values, long removeQueueCount, List<Integer> itrRemoveIndexes) {
|
private <T> void testQueue(final int initQueueSize, final List<T> values, final long removeQueueCount, final List<Integer> itrRemoveIndexes) {
|
||||||
final Set<Integer> removeIndexesSet = new HashSet<>(itrRemoveIndexes);
|
final Set<Integer> removeIndexesSet = new HashSet<>(itrRemoveIndexes);
|
||||||
|
|
||||||
final CircularFifoQueue<T> queue = new CircularFifoQueue<>(initQueueSize);
|
final CircularFifoQueue<T> queue = new CircularFifoQueue<>(initQueueSize);
|
||||||
for (T e : values) assertTrue(queue.offer(e));
|
for (T e : values) assertTrue(queue.offer(e));
|
||||||
|
|
||||||
int queueSizeAfterOffers = Math.min(initQueueSize, values.size());
|
final int queueSizeAfterOffers = Math.min(initQueueSize, values.size());
|
||||||
for (int i = 0; i < removeQueueCount; i++) {
|
for (int i = 0; i < removeQueueCount; i++) {
|
||||||
assertEquals(values.get(values.size() - queueSizeAfterOffers + i), queue.remove());
|
assertEquals(values.get(values.size() - queueSizeAfterOffers + i), queue.remove());
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ class CircularFifoQueueTest {
|
||||||
|
|
||||||
// Test Iteration
|
// Test Iteration
|
||||||
for (int i = 0; i < expected.size(); i++) {
|
for (int i = 0; i < expected.size(); i++) {
|
||||||
T e = expected.get(i);
|
final T e = expected.get(i);
|
||||||
testIteratorNext(it, e);
|
testIteratorNext(it, e);
|
||||||
|
|
||||||
if (removeIndexesSet.contains(i)) {
|
if (removeIndexesSet.contains(i)) {
|
||||||
|
@ -59,11 +59,11 @@ class CircularFifoQueueTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final <T> List<T> list(T... es) {
|
public final <T> List<T> list(final T... es) {
|
||||||
return Arrays.asList(es);
|
return Arrays.asList(es);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final List<Integer> range(int start, int end) {
|
public final List<Integer> range(final int start, final int end) {
|
||||||
if (end < start) throw new IllegalArgumentException();
|
if (end < start) throw new IllegalArgumentException();
|
||||||
|
|
||||||
final List<Integer> toReturn = new ArrayList<>(end - start);
|
final List<Integer> toReturn = new ArrayList<>(end - start);
|
||||||
|
@ -71,7 +71,6 @@ class CircularFifoQueueTest {
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIterator() {
|
public void testIterator() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> new CircularFifoQueue<Void>(0));
|
assertThrows(IllegalArgumentException.class, () -> new CircularFifoQueue<Void>(0));
|
||||||
|
@ -87,6 +86,7 @@ class CircularFifoQueueTest {
|
||||||
testQueue(4, range(0, 9), 0, list(1, 3));
|
testQueue(4, range(0, 9), 0, list(1, 3));
|
||||||
testQueue(7, range(0, 13), 4, list(1, 3));
|
testQueue(7, range(0, 13), 4, list(1, 3));
|
||||||
testQueue(7, range(0, 13), 2, list(0, 2, 4, 5, 6));
|
testQueue(7, range(0, 13), 2, list(0, 2, 4, 5, 6));
|
||||||
|
testQueue(5, range(0, 34), 2, list(0, 2, 4));
|
||||||
testQueue(4, range(0, 5), 0, list(1, 3));
|
testQueue(4, range(0, 5), 0, list(1, 3));
|
||||||
testQueue(10, empty, 0, empty);
|
testQueue(10, empty, 0, empty);
|
||||||
testQueue(4, range(0, 5), 1, empty);
|
testQueue(4, range(0, 5), 1, empty);
|
||||||
|
|
Reference in a new issue