I'm only checking on what it already does which is to use the lower-case hashCode() for all the strings regardless of the isCaseSensitive flag and regardless of the flag itself.
Easily changed, but, don't know what the original intent was....

+1 : For changing and no one is relying on all dictionaries built with different case sensitivity to return the same hashCode().

James

On 8/17/2011 4:43 AM, Jörn Kottmann wrote:
Hi,

the hash code of two dictionaries does not have to be equals,
if the case is different.

So we should remove these lines:
assertEquals(dictB.hashCode(), dictC.hashCode());

and if that works its ok, but that could change:
assertEquals(dictC.hashCode(), dictD.hashCode())

Anyway the question is, do we consider two dictionaries
with a different case flag to be equals?

I believe we shouldn't because they behave different.
Any other opinions?

Jörn

On 8/16/11 4:15 AM, [email protected] wrote:
+  /**
* Tests serialization and deserailization of the {@link Dictionary}.
     *
     * @throws IOException
@@ -154,14 +174,23 @@ public class DictionaryTest {
    @Test
    public void testHashCode() {
      StringList entry1 = new StringList(new String[]{"1a", "1b"});
+    StringList entry2 = new StringList(new String[]{"1A", "1B"});

      Dictionary dictA = getCaseInsensitive();
      dictA.put(entry1);

      Dictionary dictB = getCaseInsensitive();
-    dictB.put(entry1);
+    dictB.put(entry2);
+
+    Dictionary dictC = getCaseSensitive();
+    dictC.put(entry1);
+
+    Dictionary dictD = getCaseSensitive();
+    dictD.put(entry2);

      assertEquals(dictA.hashCode(), dictB.hashCode());
+    assertEquals(dictB.hashCode(), dictC.hashCode());
+    assertEquals(dictC.hashCode(), dictD.hashCode());
    }


Reply via email to