package org.formulachess.util.tests;


import static org.junit.jupiter.api.Assertions.*;

import org.formulachess.util.HashtableOfLong;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

public class TestHashtableOfLong {

	@Test
	@DisplayName("test001")
	public void test001() {
		HashtableOfLong table = new HashtableOfLong();
		assertNotNull(table);
		table.put("test", 3);
		assertNotNull(table.get("test"), "key not found");
		assertEquals(HashtableOfLong.NO_VALUE, table.get("test2"), "key found");
		assertTrue(table.containsKey("test"), "key not found");
	}

	@Test
	@DisplayName("test002")
	public void test002() {
		HashtableOfLong table = new HashtableOfLong();
		assertNotNull(table);
		table.put("test", 3);
		table.put("max", Long.MAX_VALUE);
		table.put("min", Long.MIN_VALUE);
		assertEquals(3, table.size(), "wrong size");
		
		for (String key : table) {
			assertNotNull(key);
		}
	}
	
	@Test
	@DisplayName("test003")
	public void test003() {
		HashtableOfLong table = new HashtableOfLong();
		assertNotNull(table);
		table.put("test", 3);
		table.put("max", Long.MAX_VALUE);
		table.put("min", Long.MIN_VALUE);
		assertEquals(3, table.size(), "wrong size");
		table.remove("test");
		assertEquals(2, table.size(), "wrong size");
	}

	@Test
	@DisplayName("test004")
	public void test004() {
		HashtableOfLong table = new HashtableOfLong(5);
		assertNotNull(table);
		table.put("test", 3);
		table.put("max", Long.MAX_VALUE);
		table.put("min", Long.MIN_VALUE);
		table.put("test2", 5677555);
		assertEquals(4, table.size(), "wrong size");
	}
}

@@ -83,16 +83,85 @@
 ons.*;%0A%0A
+import java.util.Iterator;%0Aimport java.util.NoSuchElementException;%0A%0A
 import o
@@ -1649,10 +1649,1274 @@
 e%22);%0A%09%7D%0A
+%0A%09@Test%0A%09@DisplayName(%22test005%22)%0A%09public void test005() %7B%0A%09%09HashtableOfLong table = new HashtableOfLong(30);%0A%09%09assertNotNull(table);%0A%09%09table.put(%22test%22, 3);%0A%09%09table.put(%22max%22, Long.MAX_VALUE);%0A%09%09table.put(%22min%22, Long.MIN_VALUE);%0A%09%09table.put(%22test%22, 5);%0A%09%09assertEquals(5, table.get(%22test%22), %22wrong value%22);%0A%09%09assertEquals(3, table.size(), %22wrong size%22);%0A%0A%09%09Iterator%3CString%3E iterator = table.iterator();%0A%09%09assertTrue(iterator.hasNext(), %22not more elements%22);%0A%09%09iterator.next();%0A%09%09assertTrue(iterator.hasNext(), %22not more elements%22);%0A%09%09iterator.next();%0A%09%09assertTrue(iterator.hasNext(), %22not more elements%22);%0A%09%09iterator.next();%0A%09%09try %7B%0A%09%09%09assertFalse(iterator.hasNext(), %22more elements%22);%0A%09%09%09iterator.next();%0A%09%09%09assertTrue(false, %22more elements%22);%0A%09%09%7D catch(NoSuchElementException e) %7B%0A%09%09%09// ignore%0A%09%09%7D%0A%09%7D%0A%09%0A%09@Test%0A%09@DisplayName(%22test006%22)%0A%09public void test006() %7B%0A%09%09HashtableOfLong table = new HashtableOfLong(30);%0A%09%09assertNotNull(table);%0A%09%09table.put(%22test%22, 3);%0A%09%09table.put(%22max%22, Long.MAX_VALUE);%0A%09%09table.put(%22min%22, Long.MIN_VALUE);%0A%09%09table.put(%22test%22, 5);%0A%09%09assertEquals(5, table.get(%22test%22), %22wrong value%22);%0A%09%09assertEquals(3, table.size(), %22wrong size%22);%0A%0A%09%09HashtableOfLong table2 = new HashtableOfLong(table);%0A%09%09assertEquals(3, table2.size(), %22wrong size%22);%0A%09%7D%0A%0A
 %7D%0A

Add more tests