Skip to content

Commit

Permalink
Add test for rz_il_op_new_float_from_f80
Browse files Browse the repository at this point in the history
    * Also add a float format check in `rz_il_sort_pure_eq`
    * Add a few `includes` so that some types are visible
  • Loading branch information
DMaroo committed Jan 3, 2024
1 parent bb8a91a commit 9d8bd00
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions librz/include/rz_il/definitions/sort.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define RZ_IL_SORT_H

#include <rz_types.h>
#include <rz_util/rz_float.h>

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -45,6 +46,9 @@ static inline bool rz_il_sort_pure_eq(RzILSortPure a, RzILSortPure b) {
if (a.type == RZ_IL_TYPE_PURE_BITVECTOR && a.props.bv.length != b.props.bv.length) {
return false;
}
if (a.type == RZ_IL_TYPE_PURE_FLOAT && a.props.f.format != b.props.f.format) {
return false;
}
return true;
}

Expand Down
1 change: 1 addition & 0 deletions librz/include/rz_util/rz_float.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef RZ_FLOAT_H
#define RZ_FLOAT_H
#include <rz_types.h>
#include <rz_util/rz_bitvector.h>

/**
*
Expand Down
16 changes: 16 additions & 0 deletions test/unit/test_il_validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,21 @@ static bool test_il_validate_pure_float() {
mu_end;
}

static bool test_il_validate_pure_float80() {
RzILValidateGlobalContext *ctx = rz_il_validate_global_context_new_empty(24);
RzILOpPure *op = rz_il_op_new_float_from_f80(4.2L);
RzILSortPure sort;
RzILValidateReport report;
bool val = rz_il_validate_pure(op, ctx, &sort, &report);
mu_assert_true(val, "valid");
mu_assert_true(rz_il_sort_pure_eq(sort, rz_il_sort_pure_float(RZ_FLOAT_IEEE754_BIN_80)), "sort");
mu_assert_null(report, "no report");
rz_il_op_pure_free(op);

rz_il_validate_global_context_free(ctx);
mu_end;
}

static bool test_il_validate_pure_fbits() {
RzILValidateGlobalContext *ctx = rz_il_validate_global_context_new_empty(24);

Expand Down Expand Up @@ -1745,6 +1760,7 @@ bool all_tests() {
mu_run_test(test_il_validate_effect_repeat);
mu_run_test(test_il_validate_effect_branch);
mu_run_test(test_il_validate_pure_float);
mu_run_test(test_il_validate_pure_float80);
mu_run_test(test_il_validate_pure_fbits);
mu_run_test(test_il_validate_pure_float_bool_uop);
mu_run_test(test_il_validate_pure_float_uop);
Expand Down

0 comments on commit 9d8bd00

Please sign in to comment.