rizin/test/unit
Maxim Ivanov 59c9767adc
Fix half-assed comparators (#16953)
The expression (x > y) returns 1 or 0.
strcmp(..) returns 1, 0 or -1... and is valid RItemComparator.

I.e. one can't give a boolean answer where {1,0,-1} is expected.

This bug impacts the order of enumeration of locals and args in
functions. Starts occuring from mid-sized and bigger funcs
(~50 locals, then the sorting algo switches to mergesort); leads
to unstable and incorrectly-sorted vars dumps in the project file.

A motivating unit test is added as well.

A little algebra trick keeps it simple and efficient:
using no branching, with two antisymmetric bool→int conversions
we achieve the required {-1,0,1} codomain.

TL;DR: if you write a comparator function (to sort with),
make sure it returns 3 distinct values, not just 1 & 0.
2020-05-28 11:18:06 +08:00
..
legacy_unit Make size arg of r_file_slurp() size_t (#16221) 2020-03-15 23:34:38 +01:00
.gitignore
Makefile Honor rc in unit runs and fix execution path in make run 2020-02-17 16:36:31 +01:00
meson.build Migrating RAnnotatedCode to radare2 (#16939) 2020-05-27 11:54:31 +08:00
minunit.h Extend RCmdDesc with different types (#16738) 2020-05-06 14:34:19 +08:00
r2r_cmd_test Fix r2r -i when fixing multiple tests (#16817) 2020-05-14 15:10:03 +02:00
test_addr_interval.c
test_anal_block.c Chop Basic Blocks instead of re-analyzing in noreturn propagation (#16612) 2020-04-17 19:51:47 +02:00
test_anal_block_invars.inl Remove unused Function Tree and Fix Relocate (#15898) 2020-01-26 00:07:54 +01:00
test_anal_function.c Fix all Warnings for GCC 9 (#16223) 2020-03-17 13:31:28 +01:00
test_anal_hints.c Refactor Anal Hints (#15876) ##anal 2020-02-13 11:48:24 +01:00
test_anal_meta.c Refactor Meta out of SDB (#16716) 2020-05-09 20:49:28 +02:00
test_anal_types.c Initial API for base type kinds (enum, struct, union) (#16723) ##anal 2020-05-13 20:49:25 +02:00
test_anal_var.c Improve BP vars/args detection ##anal (#16935) 2020-05-25 12:55:31 +08:00
test_anal_xrefs.c Minor Fixes for XRefs counting (#16546) ##anal 2020-04-12 16:42:19 +02:00
test_annotated_code.c Migrating RAnnotatedCode to radare2 (#16939) 2020-05-27 11:54:31 +08:00
test_base64.c
test_big.c Refactor r_big for gmp and ssl ##util (#16804) 2020-05-14 02:45:10 +02:00
test_bin.c
test_bitmap.c
test_buf.c Fix all Warnings for GCC 9 (#16223) 2020-03-17 13:31:28 +01:00
test_cmd.c Remove INNER nodes and merge inner node with the command with same name (#16784) 2020-05-11 10:55:49 +02:00
test_cons.c Fix r_cons_rgb_parse() harder (#16061) 2020-02-27 20:13:34 +01:00
test_contrbtree.c Honor rc in unit runs and fix execution path in make run 2020-02-17 16:36:31 +01:00
test_debruijn.c
test_debug.c Add test for x64 to verify fpu and xmm register size and offset (#16186) 2020-03-12 11:48:41 +08:00
test_diff.c
test_esil_dfg_filter.c
test_event.c
test_flags.c Fix Tests after Reports by asan (#16776) 2020-05-08 21:45:01 +02:00
test_glob.c
test_hex.c
test_intervaltree.c Add RIntervalTreeIter typedef 2020-05-09 12:27:17 +02:00
test_io.c
test_list.c Fix half-assed comparators (#16953) 2020-05-28 11:18:06 +08:00
test_parse_ctype.c
test_pj.c Add pj_reset() API ##json (#16802) 2020-05-12 00:11:42 +02:00
test_queue.c Convert preinc/predec in 3rd part of for statement to postinc/postdec (#16187) 2020-03-12 18:40:46 +01:00
test_r2r.c Fix r2r -i when fixing multiple tests (#16817) 2020-05-14 15:10:03 +02:00
test_range.c
test_rbtree.c Fix memory leak in test_rbtree (#15983) 2020-02-16 21:37:29 +01:00
test_reg.c Make r_reg_get_list() search harder (#16202) ##reg 2020-03-13 12:01:54 +01:00
test_skiplist.c Convert preinc/predec in 3rd part of for statement to postinc/postdec (#16187) 2020-03-12 18:40:46 +01:00
test_spaces.c
test_sparse.c
test_stack.c
test_str.c Use g->x and g->y to rebase x/y got with r_str_str_xy 2020-05-03 17:33:36 +02:00
test_strbuf.c Implement r_strbuf_setptr API and improve + test it more ##util (#16649) 2020-04-27 13:10:57 +02:00
test_table.c Fix Tests after Reports by asan (#16776) 2020-05-08 21:45:01 +02:00
test_tree.c
test_uleb128.c Add unit test for r_leb128 2020-05-05 18:47:23 +02:00
test_unum.c Convert preinc/predec in 3rd part of for statement to postinc/postdec (#16187) 2020-03-12 18:40:46 +01:00
test_util.c Add generic reference counting implementation ##util (#16604) 2020-04-17 11:56:28 +08:00
test_vector.c Add missing r_vector_fini implementation ##util (#16650) 2020-04-21 17:02:45 +02:00