#define Hello "hello, world!" #define World ; char* hi(void) { return Hello World }
char* Hi (void){char* ans;asprintf(&ans, "Hello World.");return ans;}- #define Hello "hello, world!"
- #define World ;
- char* hi(void)
- {
- return Hello World
- }
#include <criterion/criterion.h> #include <string.h> char *hi(); Test(the_hello_world_function, should_pass_all_the_tests_provided) { cr_assert_eq(strcmp(hi(),"hello, world!"), 0); }
- #include <criterion/criterion.h>
const char* Hi ();- #include <string.h>
- char *hi();
Test(the_hello_world_function, should_pass_all_the_tests_provided) {cr_assert_eq(strcmp(Hi(),"Hello World."), 0);char *p = Hi();*p = 'X';printf("%s\n",p);- Test(the_hello_world_function, should_pass_all_the_tests_provided)
- {
- cr_assert_eq(strcmp(hi(),"hello, world!"), 0);
- }
Algorithms
#include <criterion/criterion.h> int foo; Test(function_foo, should_return_zero) { cr_assert_eq(foo, 0); } Test(function_bar, should_return_zero) { cr_assert_eq(foo, 0); } Test(function_baz, should_return_zero) { cr_assert_eq(foo, 0); }
- #include <criterion/criterion.h>
int foo(), bar(), baz();- int foo;
- Test(function_foo, should_return_zero) {
cr_assert_eq(foo(), 0);- cr_assert_eq(foo, 0);
- }
- Test(function_bar, should_return_zero) {
cr_assert_eq(bar(), 0);- cr_assert_eq(foo, 0);
- }
- Test(function_baz, should_return_zero) {
cr_assert_eq(baz(), 0);- cr_assert_eq(foo, 0);
- }