Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in macro "PREPARE_FIRST_COPY" #6

Open
zwxdlut opened this issue Sep 25, 2019 · 0 comments
Open

Bug in macro "PREPARE_FIRST_COPY" #6

zwxdlut opened this issue Sep 25, 2019 · 0 comments

Comments

@zwxdlut
Copy link

zwxdlut commented Sep 25, 2019

Add test case in "test_set_bitfield":
.....
START_TEST (test_set_bitfield)
{
uint8_t data[4] = {0};
fail_unless(set_bitfield(0x12, 0, 8, data, sizeof(data)));
fail_unless(set_bitfield(bitmask(3), 10, 3, data, sizeof(data)));
ck_assert_int_eq(data[0], 0x12);
ck_assert_int_eq(data[1], 0x38);
// Add test case
fail_unless(set_bitfield(0x1, 23, 1, data, sizeof(data)));
ck_assert_int_eq(data[2], 0x1); // Should be 0x1
fail_unless(set_bitfield(0x1, 21, 2, data, sizeof(data)));
ck_assert_int_eq(data[2], 0x3); // Should be 0x3

}
END_TEST
.....
As above, when call "set_bitfield(0x1, 21, 2, data, sizeof(data));", data2 will be set to "0" by macro "PREPARE_FIRST_COPY", and then the result will be 0x2. Test failed as follow:

90%: Checks: 10, Failures: 1, Errors: 0
tests/bitfield_tests.c:39:F:core:test_set_bitfield:0: Assertion 'data[2]==0x3' failed: data[2]==2, 0x3==3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant