1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-26 15:16:09 +02:00
Commit Graph

3 Commits

Author SHA1 Message Date
René Scharfe 30ff05094c t-prio-queue: check result array bounds
Avoid reading past the end of the "result" array, which could otherwise
happen if the prio-queue were to yield more items than were put into it
due to an implementation bug, or if the array has not enough entries due
to a test bug.

Also check at the end whether all "result" entries were consumed, which
would not be the case if the prio-queue forgot some entries or the test
definition contained too many.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-18 09:25:54 -07:00
René Scharfe e6f9cb76ea t-prio-queue: shorten array index message
If we get an unexpected result, the prio-queue unit test reports it like
this:

 # check "result[j++] == show(get)" failed at t/unit-tests/t-prio-queue.c:43
 #    left: 5
 #   right: 1
 # failed at result[] index 0

That last line repeats "failed" and "result" from the first line.
Shorten it to resemble a similar one in t-ctype and also remove the
incrementation from the first line to avoid possible distractions from
the message of which comparison went wrong where:

 # check "result[j] == show(get)" failed at t/unit-tests/t-prio-queue.c:43
 #    left: 5
 #   right: 1
 #       j: 0

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-03-18 09:24:50 -07:00
Chandra Pratap 808b77e5d4 tests: move t0009-prio-queue.sh to the new unit testing framework
t/t0009-prio-queue.sh along with t/helper/test-prio-queue.c unit
tests Git's implementation of a priority queue. Migrate the
test over to the new unit testing framework to simplify debugging
and reduce test run-time. Refactor the required logic and add
a new test case in addition to porting over the original ones in
shell.

Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-01-22 10:55:01 -08:00