Question: How to build a JUnit tester for setPartition class based on a given template in JAVA This is the setPartition class import java.util.*; public class
How to build a JUnit tester for setPartition class based on a given template in JAVA
This is the setPartition class
import java.util.*;
public class SetPartition
public void add(T elem) { list.add(elem); reps.add(elem); } public void remove(T elem) { // option method int i = list.indexOf(elem); if (i < 0) return; if (reps.get(i) == list.get(i)) { T subset = null; for (int j = 0; j < list.size(); j++) { if (reps.get(j) == reps.get(i) && list.get(i) != list.get(j)) { subset = list.get(j); break; } } if (subset != null) { for (int j = 0; j < list.size(); j++) { if (reps.get(j) == reps.get(i)) reps.set(j, subset); } }
} list.remove(i); reps.remove(i); } public String subsetString(T subset) { // optional method String result = "{"; int count = 0; for (int i = 0; i < reps.size(); i++) { if (reps.get(i) != subset) continue; if (count++ > 0) result += ", "; result += list.get(i).toString(); } return result + "}"; } public String toString() { // optional method ArrayList
This is the template for the tester:
import org.junit.*; import static org.junit.Assert.*;
public class E10tester { public static void main(String[] args) { // what goes here to run the tests? } @Test public void check_constructor() { SetPartition
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
