Browse Source

tap: make examples compilable by ccanlint.

In particular, we can assume "somefunc()" exists in our examples.
Rusty Russell 15 years ago
parent
commit
43652dec7d
1 changed files with 20 additions and 13 deletions
  1. 20 13
      ccan/tap/tap.h

+ 20 - 13
ccan/tap/tap.h

@@ -53,7 +53,7 @@ void plan_tests(unsigned int tests);
  * file name, line number, and the expression itself.
  * file name, line number, and the expression itself.
  *
  *
  * Example:
  * Example:
- *	ok1(init_subsystem() == 1);
+ *	ok1(somefunc() == 1);
  */
  */
 # define ok1(e) ((e) ?							\
 # define ok1(e) ((e) ?							\
 		 _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
 		 _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
@@ -69,8 +69,8 @@ void plan_tests(unsigned int tests);
  * than simply the expression itself.
  * than simply the expression itself.
  *
  *
  * Example:
  * Example:
- *	ok1(init_subsystem() == 1);
- *	ok(init_subsystem() == 0, "Second initialization should fail");
+ *	ok1(somefunc() == 1);
+ *	ok(somefunc() == 0, "Second somefunc() should fail");
  */
  */
 # define ok(e, ...) ((e) ?						\
 # define ok(e, ...) ((e) ?						\
 		     _gen_result(1, __func__, __FILE__, __LINE__,	\
 		     _gen_result(1, __func__, __FILE__, __LINE__,	\
@@ -86,11 +86,11 @@ void plan_tests(unsigned int tests);
  * branch and fail() in another.
  * branch and fail() in another.
  *
  *
  * Example:
  * Example:
- *	x = do_something();
- *	if (!checkable(x) || check_value(x))
- *		pass("do_something() returned a valid value");
+ *	int x = somefunc();
+ *	if (x > 0)
+ *		pass("somefunc() returned a valid value");
  *	else		
  *	else		
- *		fail("do_something() returned an invalid value");
+ *		fail("somefunc() returned an invalid value");
  */
  */
 # define pass(...) ok(1, __VA_ARGS__)
 # define pass(...) ok(1, __VA_ARGS__)
 
 
@@ -148,7 +148,7 @@ void diag(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
  *
  *
  * Example:
  * Example:
  *	#ifdef HAVE_SOME_FEATURE
  *	#ifdef HAVE_SOME_FEATURE
- *	ok1(test_some_feature());
+ *	ok1(somefunc());
  *	#else
  *	#else
  *	skip(1, "Don't have SOME_FEATURE");
  *	skip(1, "Don't have SOME_FEATURE");
  *	#endif
  *	#endif
@@ -174,6 +174,11 @@ void skip(unsigned int n, const char *fmt, ...) PRINTF_ATTRIBUTE(2, 3);
  *   put tests in your testing script (always a good idea).
  *   put tests in your testing script (always a good idea).
  *
  *
  * Example:
  * Example:
+ * static bool dwim(void)
+ * {
+ *	return false; // NYI
+ * }
+ * ...
  *	todo_start("dwim() not returning true yet");
  *	todo_start("dwim() not returning true yet");
  *	ok(dwim(), "Did what the user wanted");
  *	ok(dwim(), "Did what the user wanted");
  *	todo_end();
  *	todo_end();
@@ -213,7 +218,7 @@ int exit_status(void);
  * Example:
  * Example:
  *	plan_no_plan();
  *	plan_no_plan();
  *	while (random() % 2)
  *	while (random() % 2)
- *		ok1(some_test());
+ *		ok1(somefunc());
  *	exit(exit_status());
  *	exit(exit_status());
  */
  */
 void plan_no_plan(void);
 void plan_no_plan(void);
@@ -228,11 +233,13 @@ void plan_no_plan(void);
  * in the running kernel) use plan_skip_all() instead of plan_tests().
  * in the running kernel) use plan_skip_all() instead of plan_tests().
  *
  *
  * Example:
  * Example:
- *	if (!have_some_feature) {
- *		plan_skip_all("Need some_feature support");
- *		exit(exit_status());
- *	}
+ *	#ifndef HAVE_SOME_FEATURE
+ *	plan_skip_all("Need SOME_FEATURE support");
+ *	exit(exit_status());
+ *	#else
  *	plan_tests(13);
  *	plan_tests(13);
+ *	...
+ *	#endif
  */
  */
 void plan_skip_all(const char *reason);
 void plan_skip_all(const char *reason);