Skip to content

Feature: assert comparsion result method #781

Closed as not planned
Closed as not planned
@voho

Description

@voho

Hi, when testing comparable entities, some method for asserting the correct behavior - like this - would be useful and maybe generic enough to be in junit:

    public static void assertComparsionResult(Comparable lower, Comparable greater) {
        assertTrue("first argument must be lower than second argument", lower.compareTo(greater) < 0);
        assertTrue("second argument must be greater than first argument", greater.compareTo(lower) > 0);
        assertEquals("first argument must be equal to itself", 0L, lower.compareTo(lower));
        assertEquals("second argument must be equal to itself", greater.compareTo(greater));
    }

With possible extension to methods like this (array or iterable of comparables):

public static void assertComparsionResult(Comparable... itemsInOrder) {
  // ...
}

Thanks for considering and have a nice day :).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions