Files
radaree2/test/unit/test_print.c
pancake 521e941ab8 More cleanup and refactoring for the rprint apis
* Reduce complexity and refactor heavy switches into separate functions
* Introduce RPrintPriv to hold the old thread local globals
* Use more RStrBuf and less RCons
* Return char* for some cases
2026-03-11 00:15:24 +01:00

27 lines
795 B
C

#include <r_util.h>
#include <r_util/r_print.h>
#include "minunit.h"
bool test_r_print_bytes(void) {
const ut8 buf[] = { 0x00, 0x12, 0xab };
mu_assert_streq_free (r_print_bytes (NULL, buf, sizeof (buf), "%02x", ' '), "00 12 ab", "space separated bytes");
mu_assert_streq_free (r_print_bytes (NULL, buf, sizeof (buf), "0x%02x", ','), "0x00,0x12,0xab", "comma separated bytes");
mu_end;
}
bool test_r_print_bytes_single(void) {
const ut8 buf[] = { 0xff };
mu_assert_streq_free (r_print_bytes (NULL, buf, sizeof (buf), "%02x", ' '), "ff", "single byte without trailing separator");
mu_end;
}
bool all_tests(void) {
mu_run_test (test_r_print_bytes);
mu_run_test (test_r_print_bytes_single);
return tests_passed != tests_run;
}
int main(int argc, char **argv) {
return all_tests ();
}