malsyned / pfstest

Professional Firmware Services Unit Test Framework
Other
1 stars 0 forks source link

Easy way to supply enum strings for printers #21

Closed malsyned closed 6 years ago

malsyned commented 6 years ago

It would be nice if there was some way to do something like this:

const char *edge_names = {
    [EDGE_NONE] = "EDGE_NONE",
    [EDGE_RISING] = "EDGE_RISING",
    [EDGE_FALLING] = "EDGE_FALLING",
};
assert_that("", the_enum(edge_names, edge_get_edge(test_edge)), 
                is_the_enum(edge_names, EDGE_RISING));

and get output like this:

test_edge.c:should_detect_rising FAIL
    Location: test_edge.c:33
    Failed assertion
    Expected: the enum EDGE_RISING
    Actual:   the enum EDGE_NONE