Skip to content

Instantly share code, notes, and snippets.

@ahmetozlu
Created June 5, 2021 13:18
Show Gist options
  • Save ahmetozlu/fc13d45a4d0a751c7d1767fff803202c to your computer and use it in GitHub Desktop.
Save ahmetozlu/fc13d45a4d0a751c7d1767fff803202c to your computer and use it in GitHub Desktop.
package mytest;
import org.junit.*;
import static org.junit.Assert.*;
import java.util.*;
public class ArrayListTest {
private ArrayList<String> list = new ArrayList<String>();
@Before
public void setUp() throws Exception {
}
@Test
public void testInsertion() {
list.add("Beijing");
assertEquals("Beijing", list.get(0));
list.add("Shanghai");
list.add("Hongkong");
assertEquals("Hongkong", list.get(list.size() – 1));
}
@Test
public void testDeletion() {
list.clear();
assertTrue(list.isEmpty());
list.add("A");
list.add("B");
list.add("C");
list.remove("B");
assertEquals(2, list.size());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment