@Test(expected = UnsupportedOperationException.class) public void testNotSortedNoIndexOf() { GenericIndexed.fromArray(new String[]{"a", "c", "b"}, GenericIndexed.STRING_STRATEGY).indexOf("a"); }
@Test public void testNotSortedSerialization() throws Exception { final String[] strings = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "k", "j", "l"}; GenericIndexed<String> deserialized = serializeAndDeserialize( GenericIndexed.fromArray(strings, GenericIndexed.STRING_STRATEGY) ); checkBasicAPIs(strings, deserialized, false); }
@Test(expected = UnsupportedOperationException.class) public void testSerializationNotSortedNoIndexOf() throws Exception { serializeAndDeserialize( GenericIndexed.fromArray( new String[]{"a", "c", "b"}, GenericIndexed.STRING_STRATEGY ) ).indexOf("a"); }
@Test public void testSanity() { final String[] strings = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"}; Indexed<String> indexed = GenericIndexed.fromArray(strings, GenericIndexed.STRING_STRATEGY); checkBasicAPIs(strings, indexed, true); Assert.assertEquals(-13, indexed.indexOf("q")); Assert.assertEquals(-9, indexed.indexOf("howdydo")); Assert.assertEquals(-1, indexed.indexOf("1111")); }
@Test public void testSortedSerialization() throws Exception { final String[] strings = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"}; GenericIndexed<String> deserialized = serializeAndDeserialize( GenericIndexed.fromArray(strings, GenericIndexed.STRING_STRATEGY) ); checkBasicAPIs(strings, deserialized, true); Assert.assertEquals(-13, deserialized.indexOf("q")); Assert.assertEquals(-9, deserialized.indexOf("howdydo")); Assert.assertEquals(-1, deserialized.indexOf("1111")); }