[Biojava-dev] Odd test failure (SymbolListCharSequence)

Thomas Down td2 at sanger.ac.uk
Tue Nov 4 08:04:17 EST 2003


Hi...

I'm currently seeing test failures for SymbolListCharSequence:

Testsuite: org.biojava.bio.seq.io.SymbolListCharSequenceTest
Tests run: 3, Failures: 1, Errors: 0, Time elapsed: 0.858 sec

Testcase: testCharAt took 0.846 sec
Testcase: testLength took 0 sec
Testcase: testSubSequence took 0.005 sec
        FAILED
expected:<g> but was:<g>
junit.framework.AssertionFailedError: expected:<g> but was:<g>
        at org.biojava.bio.seq.io.SymbolListCharSequenceTest.testSubSequence(Sym
bolListCharSequenceTest.java:70)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)

Testcase: testSubSequence


SymbolListCharSequence doesn't have equals and hashCode methods.
I've just looked at the javadoc for CharSequence, and Sun specifically
say that there isn't a special contract for equals and hashCode
on CharSequences.  So we've got two options:

  - Fix SymbolListCharSequence by implementing equals.
  - Fix the test so that it no longer uses equals to compare
    arbitrary CharSequences.

The first option is arguably the most helpful, the second is
probably more correct.  Any preferences?

It would have been nice is Sun had defined equals and hashCode for
CharSequences in the same way they have for some other interfaces.
But they've obviously considered this and rejected it...

     Thomas.


More information about the biojava-dev mailing list