PreviousUpNext

15.4.905  src/lib/src/int-red-black-set-unit-test.pkg

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

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

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



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

    include package   int_red_black_set;

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

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

            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, 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, i));
            };

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

                assert (all_invariants_hold set'');
            };


            assert (is_empty empty);

            summarize_unit_tests  name;
        };
};


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext