/usr/include/cutter/cutter.h is in libcutter-dev 1.1.7-1.2ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright (C) 2007-2009 Kouhei Sutou <kou@clear-code.com>
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __CUTTER_H__
#define __CUTTER_H__
#include <cutter/cut-version.h>
#include <cutter/cut-features.h>
#include <cutter/cut-assertions.h>
#include <cutter/cut-multi-process.h>
#include <cutter/cut-helper.h>
#include <cutter/cut-experimental.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* SECTION: cutter
* @title: Cutter
* @short_description: A Unit Testing Framework for C and C++.
* @see_also: <link linkend="cutter-Assertions">Assertions</link>
*
* Cutter is a Unit Testing Framework for C and C++ and has
* the following features:
* <itemizedlist>
* <listitem><para>
* Easy to use. Cutter doesn't introduce any magic macros
* like CUTTER_DEFINE_TEST_START and CUTTER_DEFINE_TEST_END
* into your test program. You can write your test program
* like normal program. You only use cut_assert_XXX() to
* check that your program works as you expect.
* |[
* #include <cutter.h>
* #include "my-stack.h"
*
* void
* test_my_stack (void)
* {
* MyStack *stack = my_stack_new();
*
* cut_assert_not_null(stack);
* cut_assert(my_stack_is_empty(stack));
* cut_assert_equal_int(0, my_stack_get_size(stack));
*
* my_stack_push(stack, 10);
* cut_assert(!my_stack_is_empty(stack));
* cut_assert_equal_int(1, my_stack_get_size(stack));
*
* my_stack_push(stack, 20);
* cut_assert_equal_int(2, my_stack_get_size(stack));
*
* cut_assert_equal(20, my_stack_pop(stack));
* cut_assert(!my_stack_is_empty(stack));
* cut_assert_equal_int(1, my_stack_get_size(stack));
*
* cut_assert_equal(10, my_stack_pop(stack));
* cut_assert(my_stack_is_empty(stack));
* cut_assert_equal_int(0, my_stack_get_size(stack));
* }
* ]|
* </para></listitem>
* <listitem><para>
* Simple but useful output. Cutter works quietly if tests
* are running without any problems by default. The
* following is an output of self test:
* |[
* ...........................................................
*
* Finished in 0.213021 seconds
*
* 59 test(s), 246 assertion(s), 0 failure(s), 0 error(s), 0 pending(s), 0 notification(s)
* ]|
* Cutter just outputs "." for a passed test and a summary
* at the end. Cutter doesn't output each test name, how
* many assertions are used for a test and so because we
* don't need the information on success.
* </para><para>
* Cutter outputs many information on failure:
* |[
* .....................F.....................................
*
* 1) Failure: test_error
* <"Strange" == cut_test_result_get_test_name(result)>
* expected: <Strange!!!>
* but was: <dummy-error-test>
* test/test-cut-assertions.c:240: cut_assert_test_result()
*
* Finished in 0.223657 seconds
*
* 59 test(s), 242 assertion(s), 1 failure(s), 0 error(s), 0 pending(s), 0 notification(s)
* ]|
* The above result is happened because I add a strange
* expected staring in Cutter's self test:
* |[
* cut_assert_equal_string("Strange!!!", cut_test_result_get_test_name(result));
* ]|
* The strange assertion is written in the 240th line in
* test/test-cut-assertions.c and the line is in the
* cut_assert_test_result() function. The function is called
* in test_error test. We expected
* cut_test_result_get_test_name(result) should return
* "Strange!!!" but got "dummy-error-name". We can get the
* above information from Cutter output. This will help your
* debug.
* </para><para>
* Cutter's output format is pragmatic. ' but was:' is
* indented and aligned with the above 'expected:'. This
* helps that you find difference between expected value and
* actual value by your eyes easily. The problem line is
* formated as 'FILENAME:LINE: FUNCTION' to integrate
* Emacs. In Emacs's compilation-mode, if the format is
* appeared in *compilation* buffer, we can jump to FILENAME
* at LINE with next-error command. (C-x `) This helps that you
* find the problem line rapidly.
* </para><para>
* Cutter supports not only easy test writing but also easy
* debugging.
* </para></listitem>
* </itemizedlist>
*/
#ifndef CUTTER_DISABLE_DEPRECATED
/**
* setup:
*
* If you define setup() in your test program, cutter will
* call your setup() before each your test is run. If you
* define cut_setup(), setup() is ignored.
*
* Deprecated: 1.0.7: Use cut_setup() instead.
*/
void setup(void);
#endif
/**
* cut_setup:
*
* If you define cut_setup() in your test program, cutter
* will call your cut_setup() before each your test is
* run. cut_setup() has priority over setup().
*
* Since: 1.0.6
*/
void cut_setup(void);
#ifndef CUTTER_DISABLE_DEPRECATED
/**
* teardown:
*
* If you define teardown() in your test program, cutter will
* call your teardown() after each your test is run even if
* a test is failed. If you define cut_teardown(),
* teardown() is ignored.
*
* Deprecated: 1.0.7: Use cut_teardown() instead.
*/
void teardown(void);
#endif
/**
* cut_teardown:
*
* If you define cut_teardown() in your test program, cutter
* will call your cut_teardown() after each your test is run
* even if a test is failed. cut_teardown() has priority
* over teardown().
*
* Since: 1.0.6
*/
void cut_teardown(void);
/**
* cut_startup:
*
* If you define cut_startup() in your test program, cutter
* will call your cut_startup() before each your test case
* is run. cut_startup() has priority over startup().
*
* Since: 1.0.6
*/
void cut_startup(void);
/**
* cut_shutdown:
*
* If you define shutdown() in your test program, cutter
* will call your shutdown() after each your test case is
* run. cut_shutdown() has priority over shutdown().
*
* Since: 1.0.6
*/
void cut_shutdown(void);
/**
* cut_add_data:
* @first_data_name: The first data name.
* @...: The data and destroy function of the first data,
* followed optionally by more
* name/data/destroy_function(#CutDestroyFunction)
* triples. The variable arguments should be terminated
* by %NULL since 1.0.6.
*
* Adds data to use data driven test.
*
* e.g.:
* |[
* #include <cutter.h>
*
* void data_translate (void);
* void test_translate (const void *data);
*
* static const char*
* translate (int input)
* {
* switch(input) {
* case 1:
* return "first";
* case 111:
* return "a hundred eleven";
* default:
* return "unsupported";
* }
* }
*
* typedef struct _TranslateTestData
* {
* char *translated;
* int input;
* } TranslateTestData;
*
* static TranslateTestData *
* translate_test_data_new (char *translated, int input)
* {
* TranslateTestData *data;
*
* data = malloc(sizeof(TranslateTestData));
* data->translated = strdup(translated);
* data->input = input;
*
* return data;
* }
*
* static void
* translate_test_data_free (TranslateTestData *data)
* {
* free(data->translated);
* free(data);
* }
*
* void
* data_translate(void)
* {
* cut_add_data("simple data",
* translate_test_data_new("first", 1),
* translate_test_data_free,
* "complex data",
* translate_test_data_new("a hundred eleven", 111),
* translate_test_data_free,
* NULL);
* }
*
* void
* test_translate(const void *data)
* {
* const TranslateTestData *test_data = data;
*
* cut_assert_equal_string(test_data->translated,
* translate(test_data->input));
* }
* ]|
*
* Since: 1.0.3
*/
#define cut_add_data(first_data_name, ...) \
cut_add_data_backward_compatibility(cut_get_current_test_context(), \
first_data_name, __VA_ARGS__)
#if !defined(CUTTER_DISABLE_DEPRECATED) && defined(__GNUC__)
#define cut_add_data_backward_compatibility(context, ...) \
cut_test_context_add_data(context, ## __VA_ARGS__, NULL)
#else
#define cut_add_data_backward_compatibility(context, ...) \
cut_test_context_add_data(context, __VA_ARGS__)
#endif
/**
* cut_set_attributes:
* @first_attribute_name: The first attribute name.
* @...: The value of the first attribute, followed
* optionally by more name/value pairs.
* %NULL-terminate is required since 1.0.7.
*
* Sets attributes of the test.
*
* e.g.:
* |[
* #include <cutter.h>
*
* void attributes_repeat (void);
* void test_repeat (void);
*
* void
* attributes_repeat(void)
* {
* cut_set_attributes("description", "a test for repeat function",
* "bug", "111",
* "priority", "high",
* NULL);
* }
*
* void
* test_repeat(void)
* {
* cut_assert_equal_string_with_free("XXX", repeat("X", 3));
* }
* ]|
*
* Since: 1.0.4
*/
#define cut_set_attributes(first_attribute_name, ...) \
cut_test_context_set_attributes(cut_get_current_test_context(), \
first_attribute_name, \
__VA_ARGS__)
/**
* cut_get_current_test_context:
*
* Returns the current test context. The current test
* context is a thread local object. It means that you don't
* need to care this if you don't create a new thread in your
* test. This is only needed to care if you create a new
* thread. You need to pass the current test context in your
* test thread to the current test context in a created
* thread.
*
* e.g.:
* |[
* int
* your_thread_function(void *data)
* {
* CutTestContext *test_context = data;
* cut_set_current_test_context(test_context);
* ...
* }
*
* void
* run_your_thread(void)
* {
* int result;
* pthread_t your_thread;
*
* result = pthread_create(&your_thread, NULL,
* your_thread_function,
* cut_get_current_test_context());
* ...
* }
* ]|
*
* Returns: a #CutTestContext.
*
* Since: 1.0.4
*/
#define cut_get_current_test_context() \
cut_test_context_current_peek()
/**
* cut_set_current_test_context:
* @test_context: the #CutTestContext to be the current test
* context.
*
* Set @test_context as the current test context. See
* cut_get_current_test_context() for more details.
*
* Since: 1.0.4
*/
#define cut_set_current_test_context(test_context) \
cut_test_context_current_push(test_context)
#ifndef CUTTER_DISABLE_DEPRECATED
/**
* cut_set_message:
* @format: the message format. See the printf() documentation.
* @...: the parameters to insert into the format string.
*
* Sets a message to be used by the next assertion.
*
* Since: 1.0.6
* Deprecated: 1.1.0: Use cut_message() instead.
*/
#define cut_set_message(...) \
cut_test_context_set_user_message(cut_get_current_test_context(), \
__VA_ARGS__)
/**
* cut_set_message_va_list:
* @format: the message format. See the printf() documentation.
* @args: the parameters to insert into the format string.
*
* Sets a message to be used by the next assertion.
*
* Since: 1.0.6
* Deprecated: 1.1.0: Use cut_message() instead.
*/
#define cut_set_message_va_list(format, args) \
cut_test_context_set_user_message_va_list( \
cut_get_current_test_context(), format, args)
/**
* cut_keep_message:
*
* Keeps the current message set by cut_set_message() or
* cut_set_message_va_list() after the next assertion.
*
* Since: 1.0.6
* Deprecated: 1.1.0: Use cut_message() instead.
*/
#define cut_keep_message() \
cut_test_context_keep_user_message(cut_get_current_test_context())
#endif
/**
* cut_message:
* @format: the message format. See the printf() documentation.
* @...: the parameters to insert into the format string.
*
* Specifies optional assertion message.
*
* e.g.:
* |[
* cut_assert_equal_string("abc", "def",
* cut_message("should fail!"));
* ]|
*
* Since: 1.1.0
*/
#define cut_message(...) \
cut_test_context_set_current_result_user_message( \
cut_get_current_test_context(), \
cut_take_printf(__VA_ARGS__))
/**
* CUT_EXPORT:
*
* Marks a function as a exported function. This is needed
* for just Windows environment. If you want to run your
* tests on Windows, you need to use this. Otherwise, you
* don't need to use this.
*
* e.g.:
* |[
* CUT_EXPORT void
* test_add (void)
* {
* ...
* }
* ]|
*
* Since: 1.1.2
*/
#ifdef _WIN32
# define CUT_EXPORT __declspec(dllexport)
#else
# define CUT_EXPORT
#endif
#ifdef __cplusplus
}
#endif
#endif /* __CUTTER_H__ */
/*
vi:nowrap:ai:expandtab:sw=4
*/
|