malsyned / pfstest

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

Revisit decision to copy strings and memory buffers into allocated memory #33

Open malsyned opened 6 years ago

malsyned commented 6 years ago

the_string and the_memory copy the buffer that is passed to them into a freshly allocated new buffer. Why have I done this? I think only to support this use pattern:

static char *make_me_a_string(void)
{
    char stack_string[] = "foo";
    return stack_string;
}

test(foo) {
    assert_that(the_string(make_me_a_string()), is_the_string("foo"));
}

However, is this pattern really likely? And if it is, wouldn't the user be better advised to pfstest_alloc the buffer requiring dynamic extent themselves?