#!/usr/bin/env qore
# -*- mode: qore; indent-tabs-mode: nil -*-

%new-style
%enable-all-warnings
%require-types
%strict-args

%requires ../../../../qlib/QUnit.qm

%exec-class Compare

public class Compare inherits QUnit::Test {
    public {
        const Data = (
            (0, 1.00001, 1.00002, 0.0001),
            (-1, 1.00001, 1.00002, 0.000001),
            (1, 1.00002, 1.00001, 0.000001),

            (0, 1.00001n, 1.00002n, 0.0001n),
            (-1, 1.00001n, 1.00002n, 0.000001n),
            (1, 1.00002n, 1.00001n, 0.000001n),
        );
    }

    constructor() : Test("CompareTest", "1.0") {
        addTestCase("tests", \test());

        # Return for compatibility with test harness that checks return value.
        set_return_value(main());
    }

    test() {
        map assertEq($1[0], Qore::compare($1[1], $1[2], $1[3]), sprintf("%d/%d", $# + 1, Data.size())), Data;
    }
}
