Package 

Class CompareToContract


  • 
    public class CompareToContract
    
                        
    Tests the various properties the Comparable contract is supposed to uphold. If you think this isconfusing, realize that like equals(), it is often not possible to implement a one-sidedcompareTo() correctly with inheritance - it's a broken concept, but it's still used so often thatyou have to do your best with it.I got the idea of contract-based testing from watching Bill Venners:https://www.youtube.com/watch?v=bCTZQi2dpl8
    • Method Summary

      Modifier and Type Method Description
      static <S extends Comparable<Out Object>, T1 extends S, T2 extends S, T3 extends S> void testCompareTo(T1 least1, T1 least2, T2 middle1, T2 middle2, T3 greatest1, T3 greatest2) Tests the various properties the Comparable contract is supposed to uphold.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • testCompareTo

         static <S extends Comparable<Out Object>, T1 extends S, T2 extends S, T3 extends S> void testCompareTo(T1 least1, T1 least2, T2 middle1, T2 middle2, T3 greatest1, T3 greatest2)
        Tests the various properties the Comparable contract is supposed to uphold.