Question: 2. Write unit testing code for the following program. Make sure all the methods are tested. import java.util. Iterator; import java.util. NoSuch Element Exception; import

 2. Write unit testing code for the following program. Make sure

2. Write unit testing code for the following program. Make sure all the methods are tested. import java.util. Iterator; import java.util. NoSuch Element Exception; import java.util. TreeSet; public class SET> implements Iterable { private TreeSet set; public SET() { set = new TreeSet(); } public SET (SET x) { set = new TreeSet(x. set); } public void add (Key key) { if (key = null) throw new Illegal Argument Exception ("called Ladd ().-withuanullukey"); set add (key); public boolean contains (Key key) { if (key = null) throw new IllegalArgumentException ("called contains () with wanullukey" return set.contains (key); } public void delete (Key key) { if (key = null) throw new IllegalArgumentException("called delete () with wawnullukey"); set remove (key); } public int size () { return set.size(): } public boolean is Empty() { return size () = 0; } public Iterator iterator() { return set. iterator (); } public static void main(String[] args) { SET set = new SET(); set.add("www.cs. princeton.edu"); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!