Complete the method that takes a boolean value and return a "Yes" string for true, or a "No" string for false.
#include<stdbool.h>
const char *bool_to_word (int value)
{
if (value == 0)
return "No";
else if (value!=0)
return "Yes";
}
#include <stdbool.h>
#include <criterion/criterion.h>
extern const char *bool_to_word (bool value);
static void do_test (bool b, const char *expected)
{
const char *actual = bool_to_word(b);
cr_assert_str_eq(actual, expected,
"for %s, expected \"%s\", but got \"%s\"",
b ? "true" : "false", expected, actual
);
}
Test (Bool_to_word, sample_tests)
{
do_test(true, "Yes");
do_test(false, "No");
}