Cxbx-Reloaded / xbox_kernel_test_suite

Xbox kernel APIs tester written using nxdk
GNU General Public License v3.0
22 stars 6 forks source link

Add GEN_CHECK_ARRAY_MEMBER and ARRAY_SIZE Macro Features #85

Closed RadWolfie closed 8 months ago

RadWolfie commented 8 months ago
typedef struct _test_struct {
    uint8_t expected_result;
    uint8_t result;
} test_struct;

test_struct tests[]{
    { .expected_result = 1, .result = 1 },
    { .expected_result = 2, .result = 5 },
    { .expected_result = 3, .result = 6 },
    { .expected_result = 4, .result = 7 }
};

GEN_CHECK_ARRAY_MEMBER(tests, result, expected_result, ARRAY_SIZE(tests), "tests");

As for GEN_CHECK_ARRAY_MEMBER test, using example above will output:

Expected array tests[1].expected_result = 0x2, Got tests[1].result = 0x5 Expected array tests[2].expected_result = 0x3, Got tests[2].result = 0x6 Expected array tests[3].expected_result = 0x4, Got tests[3].result = 0x7

With these additions, it will make future codes easier to write.

EDIT: Tested on hardware and all are passing. Plus confirmed with preexisting verbose passed tests such as RtlEqualString test. Beside, ARRAY_SIZE macro shouldn't harm and is well used common macro.

RadWolfie commented 8 months ago

Updated to resolve compilation issue I encountered from codespace vs locally. Turns out I shouldn't use the glue tokens method. I had removed that and fix side effect of printf usage carried over by accident. Now it's working according to my wip improve-log branch.