#!/usr/bin/env qore

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

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

%exec-class ParseRangesTest

public class ParseRangesTest inherits QUnit::Test {
    constructor() : Test ("ParseRangesTest", "1.0") {
        addTestCase ("Tests for parse_ranges() function", \test_parse_ranges());
        set_return_value(main());
    }

    test_parse_ranges() {
        assertEq ((), parse_ranges (""));
        assertEq ((1,), parse_ranges ("1"));
        assertEq ((2,3,4,5), parse_ranges ("2-5"));
        assertEq ((3,5,7,8,9), parse_ranges ("3,5, 7-9"));
        # and a special "broken" input that I think is handled just right
        assertEq ((1,3,5,6,7,12,4), parse_ranges ("1,3, ,5-7-, 12, 4-"));
    }
}
