All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gnu.trove.map.hash.NoEntryValueTest Maven / Gradle / Ivy

The newest version!
package gnu.trove.map.hash;

import gnu.trove.map.TObjectIntMap;
import junit.framework.TestCase;

import java.util.Arrays;


/**
 * Test for a number of bugs related to no_entry_value, including 3432402
 */
public class NoEntryValueTest extends TestCase {
	public void testAdjustToNoEntry() {
		TObjectIntMap map = new TObjectIntHashMap();
		
		assertEquals( 0, map.getNoEntryValue() );
		assertEquals( 0, map.get( "NotInThere" ) );
		
		map.put( "Value", 1 );
		assertEquals( 1, map.size() );
		assertEquals( 1, map.get( "Value" ) );
		assertTrue( map.containsKey( "Value" ) );
		assertTrue( map.containsValue( 1 ) );
		assertTrue( Arrays.equals( new int[] { 1 }, map.values() ) );
		
		map.adjustValue( "Value", -1 );
		assertEquals( 1, map.size() );
		assertEquals( 0, map.get( "Value" ) );
		assertTrue( map.containsKey( "Value" ) );
		assertTrue( map.containsValue( 0 ) );
		assertTrue( Arrays.equals( new int[] { 0 }, map.values() ) );
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy