PreviousUpNext

15.4.997  src/lib/src/unt-red-black-set-unit-test.pkg

## unt-red-black-set-unit-test.pkg

# Compiled by:
#     src/lib/test/unit-tests.lib

# Run by:
#     src/lib/test/all-unit-tests.pkg



package unt_red_black_set_unit_test {

    include unit_test;                                          # unit_test                     is from   src/lib/src/unit-test.pkg

    include unt_red_black_set;

    name =  "src/lib/src/unt-red-black-set-unit-test.pkg unit tests";

    fun run ()
        =
        {
            printf "\nDoing %s:\n" name;

            my limit = 100;

        # debug_print (m, printf "%d", printf "%d");

            # Create a map by successive appends:
            #
            my test_set
                =
                for (m = empty, i = 0;  i < limit;  ++i; m) {

                    m = add (m, unt::from_int i);
                    assert (all_invariants_hold   m);
                    assert (not (is_empty m));
                    assert (     vals_count m  == i+1);

                };

            # Check resulting set's contents:
            #
            for (i = 0;  i < limit;  ++i) {
                assert (member (test_set, unt::from_int i));
            };

            # Try removing at all possible positions in map:
            #
            for (set' = test_set, i = 0;   i < limit;   ++i) {

                set'' = delete (set', unt::from_int i);

                assert (all_invariants_hold set'');
            };




            assert (is_empty empty);

            summarize_unit_tests  name;
        };
};


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext