Finally got back to programming the alu during my week off and tried to fix varying bugs, this bug however eludes me, basically I converted a couple of bit search functions to accept searching for first/final 0 instead of first/final 1 but later found it was giving erroneous result/s which leads to the failure of a previously working alup_mov_int2flt() function (at least on positive numbers, recently found out I had made some misunderstanding somewhere about how negative numbers are stored in floats and that lead to erroneous results regarding normal +-*/ math). I've now added a couple of tests for those functions having realised there was none already added to the tests that were being done and tried running them only to find they were not catching the error of the known faulty function (alup_first_bit_with_val). Can someone take a look and see if they can correct the test for me (haven't uploaded any changes yet because I did a massive overhaul and didn't want to upload broken code, if you need to see it say so and I will upload a zip of the project and just link to that instead). Btw the bug was incorrect position & bit being given back (was one off), I'll circle back to that bug after the test for it is corrected.
Code:
START_TEST( test_alup_first_bit_with_val )
{
if ( !stop_checks )
{
uintmax_t before = 0x86 << _i, expect = 0x2 << _i;
alup_t _BEFORE;
alub_t result;
alup_init_unsigned( _BEFORE, &before, bitsof(uint_t) );
result = alup_first_bit_with_val( &_BEFORE, true );
stop_checks = ((*(result.ptr) & result.mask) != expect);
ck_assert_msg
(
(*(result.ptr) & result.mask) == expect
, "Expected 0x%016jX, Got 0x%016jX, Before = 0x%016jX"
, expect
, result.mask
, before
);
expect = _i + 1;
stop_checks = (stop_checks || result.pos != expect);
ck_assert_msg
(
result.pos == expect
, "Expected %ju, Got %zu"
, expect
, result.pos
);
stop_checks = (stop_checks || result.bit != expect);
ck_assert_msg
(
result.bit == expect
, "Expected %ju, Got %zu"
, expect
, result.bit
);
}
}
END_TEST
START_TEST( test_alup_final_bit_with_val )
{
if ( !stop_checks )
{
uintmax_t before = 0x86 << _i, expect = 0x80 << _i;
alup_t _BEFORE;
alub_t result;
alup_init_unsigned( _BEFORE, &before, bitsof(uint_t) );
result = alup_final_bit_with_val( &_BEFORE, true );
stop_checks = ((*(result.ptr) & result.mask) != expect);
ck_assert_msg
(
(*(result.ptr) & result.mask) == expect
, "Expected 0x%016jX, Got 0x%016jX, Before = 0x%016jX"
, expect
, result.mask
, before
);
expect = _i + 7;
stop_checks = (stop_checks || result.pos != expect);
ck_assert_msg
(
result.pos == expect
, "Expected %ju, Got %zu"
, expect
, result.pos
);
stop_checks = (stop_checks || result.bit != expect);
ck_assert_msg
(
result.bit == expect
, "Expected %ju, Got %zu"
, expect
, result.bit
);
}
}
END_TEST
Edit: Went ahead and compressed the project anyways, alu.tar.gz - Google Drive