Untitled
unknown
java
2 years ago
1.3 kB
11
Indexable
package com.comp301.a04junit; import com.comp301.a04junit.alphabetizer.Alphabetizer; import org.junit.Test; import java.util.NoSuchElementException; import static org.junit.Assert.*; /** Write tests for the Alphabetizer class here */ public class NoviceAlphabetizerTests { @Test public void unitTest1() { String[] a = {"C", "B", "A"}; String[] copy = a.clone(); Alphabetizer obj = new Alphabetizer(a); assertArrayEquals(copy, a); // TODO: Write your first unit test! } @Test public void unitTest2() { new Alphabetizer(null); } @Test public void unitTest3() { Alphabetizer obj = new Alphabetizer(new String[] {"C", "B", "A"}); String test = obj.next(); assertEquals("A", test); } @Test public void unitTest4() { try { Alphabetizer obj = new Alphabetizer(new String[] {}); String test = obj.next(); } catch (NoSuchElementException e) { } } @Test public void unitTest5() { Alphabetizer obj = new Alphabetizer(new String[] {"C", "B", "A"}); boolean test = obj.hasNext(); assertTrue(test); } @Test public void unitTest6() { Alphabetizer obj = new Alphabetizer(new String[] {}); boolean test = obj.hasNext(); assertFalse(test); } }
Editor is loading...