1 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * Copyright (C) 2007-2010 Kouhei Sutou <kou@clear-code.com> 4 * 5 * This library is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU Lesser General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 #ifndef __CUT_ASSERTIONS_H__ 21 #define __CUT_ASSERTIONS_H__ 22 23 #include <cutter/cut-assertions-helper.h> 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 /** 30 * SECTION: cut-assertions 31 * @title: Assertions 32 * @short_description: Checks that your program works as you expect. 33 * 34 * To check that your program works as you expect, you use 35 * cut_assert_XXX() where you want to check expected value 36 * is got. 37 * 38 * e.g.: 39 * |[ 40 * cut_assert_equal_int(3, 1 + 2); 41 * ]| 42 */ 43 44 /** 45 * cut_assert: 46 * @expression: the expression to be checked. 47 * @...: optional message. See cut_message() for details. 48 * 49 * Passes if @expression is not 0 or %NULL. 50 * 51 * e.g.: 52 * |[ 53 * char *string; 54 * string = malloc(16); 55 * cut_assert(string); 56 * ]| 57 * 58 * |[ 59 * MyObject *object; 60 * object = my_object_new(); 61 * cut_assert(object, cut_message("my_object_new() should not be failed")); 62 * ]| 63 */ 64 #define cut_assert(expression, ...) do \ 65 { \ 66 cut_trace_with_info_expression( \ 67 cut_test_with_user_message( \ 68 cut_assert_helper((expression) ? CUT_TRUE : CUT_FALSE, \ 69 #expression), \ 70 __VA_ARGS__), \ 71 cut_assert(expression, __VA_ARGS__)); \ 72 } while (0) 73 74 /** 75 * cut_assert_true: 76 * @expression: the expression to be checked. 77 * @...: optional message. See cut_message() for details. 78 * 79 * Passes if @expression is %CUT_TRUE value (not 0 or %NULL). 80 * 81 * Since: 0.9 82 */ 83 #define cut_assert_true(expression, ...) do \ 84 { \ 85 cut_trace_with_info_expression( \ 86 cut_test_with_user_message( \ 87 cut_assert_true_helper((expression) ? CUT_TRUE : CUT_FALSE, \ 88 #expression), \ 89 __VA_ARGS__), \ 90 cut_assert_true(expression, __VA_ARGS__)); \ 91 } while (0) 92 93 /** 94 * cut_assert_false: 95 * @expression: the expression to be checked. 96 * @...: optional message. See cut_message() for details. 97 * 98 * Passes if @expression is 0 or %NULL. 99 * 100 * Since: 0.9 101 */ 102 #define cut_assert_false(expression, ...) do \ 103 { \ 104 cut_trace_with_info_expression( \ 105 cut_test_with_user_message( \ 106 cut_assert_false_helper((expression) ? CUT_TRUE : CUT_FALSE, \ 107 #expression), \ 108 __VA_ARGS__), \ 109 cut_assert_false(expression, __VA_ARGS__)); \ 110 } while (0) 111 112 /** 113 * cut_assert_equal_boolean: 114 * @expected: the expected boolean. 115 * @actual: the actual boolean. 116 * @...: optional message. See cut_message() for details. 117 * 118 * Passes if both of @expected and @actual are %CUT_TRUE 119 * value or both of @expected and @actual are %CUT_FALSE 120 * value. 121 * 122 * e.g.: 123 * |[ 124 * cut_assert_equal_boolean(CUT_TRUE, CUT_TRUE); -> Pass 125 * cut_assert_equal_boolean(CUT_FALSE, CUT_FALSE); -> Pass 126 * cut_assert_equal_boolean(CUT_TRUE, CUT_FALSE); -> Fail 127 * ]| 128 * 129 * Since: 1.0.7 130 */ 131 #define cut_assert_equal_boolean(expected, actual, ...) do \ 132 { \ 133 cut_trace_with_info_expression( \ 134 cut_test_with_user_message( \ 135 cut_assert_equal_boolean_helper((expected), (actual), \ 136 #expected, #actual), \ 137 __VA_ARGS__), \ 138 cut_assert_equal_boolean(expected, actual)); \ 139 } while (0) 140 141 /** 142 * cut_assert_not_equal_boolean: 143 * @expected: the expected boolean. 144 * @actual: the actual boolean. 145 * @...: optional message. See cut_message() for details. 146 * 147 * Passes if @expected is %CUT_TRUE value 148 * but @actual is %CUT_FALSE value or @expected is 149 * %CUT_FALSE value but @actual is %CUT_TRUE value. 150 * 151 * e.g.: 152 * |[ 153 * cut_assert_not_equal_boolean(CUT_TRUE, CUT_TRUE); -> Fail 154 * cut_assert_not_equal_boolean(CUT_FALSE, CUT_FALSE); -> Fail 155 * cut_assert_not_equal_boolean(CUT_TRUE, CUT_FALSE); -> Pass 156 * ]| 157 * 158 * Since: 1.0.7 159 */ 160 #define cut_assert_not_equal_boolean(expected, actual, ...) do \ 161 { \ 162 cut_trace_with_info_expression( \ 163 cut_test_with_user_message( \ 164 cut_assert_not_equal_boolean_helper((expected), (actual), \ 165 #expected, #actual), \ 166 __VA_ARGS__), \ 167 cut_assert_not_equal_boolean(expected, actual)); \ 168 } while (0) 169 170 /** 171 * cut_assert_null: 172 * @expression: the expression to be checked. 173 * @...: optional message. See cut_message() for details. 174 * 175 * Passes if @expression is %NULL. 176 */ 177 #define cut_assert_null(expression, ...) do \ 178 { \ 179 cut_trace_with_info_expression( \ 180 cut_test_with_user_message( \ 181 cut_assert_null_helper((expression), #expression), \ 182 __VA_ARGS__), \ 183 cut_assert_null(expression, __VA_ARGS__)); \ 184 } while (0) 185 186 /** 187 * cut_assert_null_string: 188 * @string: the string to be checked. 189 * @...: optional message. See cut_message() for details. 190 * 191 * Passes if @string is %NULL. 192 * 193 * Since: 0.3 194 */ 195 #define cut_assert_null_string(string, ...) do \ 196 { \ 197 cut_trace_with_info_expression( \ 198 cut_test_with_user_message( \ 199 cut_assert_null_string_helper((string), #string), \ 200 __VA_ARGS__), \ 201 cut_assert_null_string(string, __VA_ARGS__)); \ 202 } while (0) 203 204 /** 205 * cut_assert_not_null: 206 * @expression: the expression to be checked. 207 * @...: optional message. See cut_message() for details. 208 * 209 * Passes if @expression is not %NULL. 210 */ 211 #define cut_assert_not_null(expression, ...) do \ 212 { \ 213 cut_trace_with_info_expression( \ 214 cut_test_with_user_message( \ 215 cut_assert_not_null_helper((expression), #expression), \ 216 __VA_ARGS__), \ 217 cut_assert_not_null(expression, __VA_ARGS__)); \ 218 } while (0) 219 220 /** 221 * cut_assert_equal_int: 222 * @expected: an expected integer value. 223 * @actual: an actual integer value. 224 * @...: optional message. See cut_message() for details. 225 * 226 * Passes if @expected == @actual. 227 */ 228 #define cut_assert_equal_int(expected, actual, ...) do \ 229 { \ 230 cut_trace_with_info_expression( \ 231 cut_test_with_user_message( \ 232 cut_assert_equal_int_helper((expected), (actual), \ 233 #expected, #actual), \ 234 __VA_ARGS__), \ 235 cut_assert_equal_int(expected, actual, __VA_ARGS__)); \ 236 } while (0) 237 238 /** 239 * cut_assert_not_equal_int: 240 * @expected: an expected integer value. 241 * @actual: an actual integer value. 242 * @...: optional message. See cut_message() for details. 243 * 244 * Passes if @expected != @actual. 245 * 246 * Since: 1.0.7 247 */ 248 #define cut_assert_not_equal_int(expected, actual, ...) do \ 249 { \ 250 cut_trace_with_info_expression( \ 251 cut_test_with_user_message( \ 252 cut_assert_not_equal_int_helper((expected), (actual), \ 253 #expected, #actual), \ 254 __VA_ARGS__), \ 255 cut_assert_not_equal_int(expected, actual)); \ 256 } while (0) 257 258 #ifdef CUT_SUPPORT_C99_STDINT_TYPES 259 /** 260 * cut_assert_equal_int_least8: 261 * @expected: an expected integer value. 262 * @actual: an actual integer value. 263 * @...: optional message. See cut_message() for details. 264 * 265 * Passes if @expected == @actual. 266 * 267 * This function is available only when 268 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 269 * 270 * Since: 1.1.0 271 */ 272 #define cut_assert_equal_int_least8(expected, actual, ...) do \ 273 { \ 274 cut_trace_with_info_expression( \ 275 cut_test_with_user_message( \ 276 cut_assert_equal_int_least8_helper((expected), (actual), \ 277 #expected, #actual), \ 278 __VA_ARGS__), \ 279 cut_assert_equal_int_least8(expected, actual)); \ 280 } while (0) 281 282 /** 283 * cut_assert_not_equal_int_least8: 284 * @expected: an expected integer value. 285 * @actual: an actual integer value. 286 * @...: optional message. See cut_message() for details. 287 * 288 * Passes if @expected != @actual. 289 * 290 * This function is available only when 291 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 292 * 293 * Since: 1.1.0 294 */ 295 #define cut_assert_not_equal_int_least8(expected, actual, ...) do \ 296 { \ 297 cut_trace_with_info_expression( \ 298 cut_test_with_user_message( \ 299 cut_assert_not_equal_int_least8_helper((expected), \ 300 (actual), \ 301 #expected, \ 302 #actual), \ 303 __VA_ARGS__), \ 304 cut_assert_not_equal_int_least8(expected, actual)); \ 305 } while (0) 306 307 /** 308 * cut_assert_equal_int_least16: 309 * @expected: an expected integer value. 310 * @actual: an actual integer value. 311 * @...: optional message. See cut_message() for details. 312 * 313 * Passes if @expected == @actual. 314 * 315 * This function is available only when 316 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 317 * 318 * Since: 1.1.0 319 */ 320 #define cut_assert_equal_int_least16(expected, actual, ...) do \ 321 { \ 322 cut_trace_with_info_expression( \ 323 cut_test_with_user_message( \ 324 cut_assert_equal_int_least16_helper((expected), (actual), \ 325 #expected, #actual), \ 326 __VA_ARGS__), \ 327 cut_assert_equal_int_least16(expected, actual)); \ 328 } while (0) 329 330 /** 331 * cut_assert_not_equal_int_least16: 332 * @expected: an expected integer value. 333 * @actual: an actual integer value. 334 * @...: optional message. See cut_message() for details. 335 * 336 * Passes if @expected != @actual. 337 * 338 * This function is available only when 339 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 340 * 341 * Since: 1.1.0 342 */ 343 #define cut_assert_not_equal_int_least16(expected, actual, ...) do \ 344 { \ 345 cut_trace_with_info_expression( \ 346 cut_test_with_user_message( \ 347 cut_assert_not_equal_int_least16_helper((expected), \ 348 (actual), \ 349 #expected, \ 350 #actual), \ 351 __VA_ARGS__), \ 352 cut_assert_not_equal_int_least16(expected, actual)); \ 353 } while (0) 354 355 /** 356 * cut_assert_equal_int_least32: 357 * @expected: an expected integer value. 358 * @actual: an actual integer value. 359 * @...: optional message. See cut_message() for details. 360 * 361 * Passes if @expected == @actual. 362 * 363 * This function is available only when 364 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 365 * 366 * Since: 1.1.0 367 */ 368 #define cut_assert_equal_int_least32(expected, actual, ...) do \ 369 { \ 370 cut_trace_with_info_expression( \ 371 cut_test_with_user_message( \ 372 cut_assert_equal_int_least32_helper((expected), (actual), \ 373 #expected, #actual), \ 374 __VA_ARGS__), \ 375 cut_assert_equal_int_least32(expected, actual)); \ 376 } while (0) 377 378 /** 379 * cut_assert_not_equal_int_least32: 380 * @expected: an expected integer value. 381 * @actual: an actual integer value. 382 * @...: optional message. See cut_message() for details. 383 * 384 * Passes if @expected != @actual. 385 * 386 * This function is available only when 387 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 388 * 389 * Since: 1.1.0 390 */ 391 #define cut_assert_not_equal_int_least32(expected, actual, ...) do \ 392 { \ 393 cut_trace_with_info_expression( \ 394 cut_test_with_user_message( \ 395 cut_assert_not_equal_int_least32_helper((expected), \ 396 (actual), \ 397 #expected, \ 398 #actual), \ 399 __VA_ARGS__), \ 400 cut_assert_not_equal_int_least32(expected, actual)); \ 401 } while (0) 402 403 /** 404 * cut_assert_equal_int_least64: 405 * @expected: an expected integer value. 406 * @actual: an actual integer value. 407 * @...: optional message. See cut_message() for details. 408 * 409 * Passes if @expected == @actual. 410 * 411 * This function is available only when 412 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 413 * 414 * Since: 1.1.0 415 */ 416 #define cut_assert_equal_int_least64(expected, actual, ...) do \ 417 { \ 418 cut_trace_with_info_expression( \ 419 cut_test_with_user_message( \ 420 cut_assert_equal_int_least64_helper((expected), (actual), \ 421 #expected, #actual), \ 422 __VA_ARGS__), \ 423 cut_assert_equal_int_least64(expected, actual)); \ 424 } while (0) 425 426 /** 427 * cut_assert_not_equal_int_least64: 428 * @expected: an expected integer value. 429 * @actual: an actual integer value. 430 * @...: optional message. See cut_message() for details. 431 * 432 * Passes if @expected != @actual. 433 * 434 * This function is available only when 435 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 436 * 437 * Since: 1.1.0 438 */ 439 #define cut_assert_not_equal_int_least64(expected, actual, ...) do \ 440 { \ 441 cut_trace_with_info_expression( \ 442 cut_test_with_user_message( \ 443 cut_assert_not_equal_int_least64_helper((expected), \ 444 (actual), \ 445 #expected, \ 446 #actual), \ 447 __VA_ARGS__), \ 448 cut_assert_not_equal_int_least64(expected, actual)); \ 449 } while (0) 450 451 /** 452 * cut_assert_equal_int_fast8: 453 * @expected: an expected integer value. 454 * @actual: an actual integer value. 455 * @...: optional message. See cut_message() for details. 456 * 457 * Passes if @expected == @actual. 458 * 459 * This function is available only when 460 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 461 * 462 * Since: 1.1.0 463 */ 464 #define cut_assert_equal_int_fast8(expected, actual, ...) do \ 465 { \ 466 cut_trace_with_info_expression( \ 467 cut_test_with_user_message( \ 468 cut_assert_equal_int_fast8_helper((expected), (actual), \ 469 #expected, #actual), \ 470 __VA_ARGS__), \ 471 cut_assert_equal_int_fast8(expected, actual)); \ 472 } while (0) 473 474 /** 475 * cut_assert_not_equal_int_fast8: 476 * @expected: an expected integer value. 477 * @actual: an actual integer value. 478 * @...: optional message. See cut_message() for details. 479 * 480 * Passes if @expected != @actual. 481 * 482 * This function is available only when 483 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 484 * 485 * Since: 1.1.0 486 */ 487 #define cut_assert_not_equal_int_fast8(expected, actual, ...) do \ 488 { \ 489 cut_trace_with_info_expression( \ 490 cut_test_with_user_message( \ 491 cut_assert_not_equal_int_fast8_helper((expected), (actual), \ 492 #expected, #actual), \ 493 __VA_ARGS__), \ 494 cut_assert_not_equal_int_fast8(expected, actual)); \ 495 } while (0) 496 497 /** 498 * cut_assert_equal_int_fast16: 499 * @expected: an expected integer value. 500 * @actual: an actual integer value. 501 * @...: optional message. See cut_message() for details. 502 * 503 * Passes if @expected == @actual. 504 * 505 * This function is available only when 506 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 507 * 508 * Since: 1.1.0 509 */ 510 #define cut_assert_equal_int_fast16(expected, actual, ...) do \ 511 { \ 512 cut_trace_with_info_expression( \ 513 cut_test_with_user_message( \ 514 cut_assert_equal_int_fast16_helper((expected), (actual), \ 515 #expected, #actual), \ 516 __VA_ARGS__), \ 517 cut_assert_equal_int_fast16(expected, actual)); \ 518 } while (0) 519 520 /** 521 * cut_assert_not_equal_int_fast16: 522 * @expected: an expected integer value. 523 * @actual: an actual integer value. 524 * @...: optional message. See cut_message() for details. 525 * 526 * Passes if @expected != @actual. 527 * 528 * This function is available only when 529 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 530 * 531 * Since: 1.1.0 532 */ 533 #define cut_assert_not_equal_int_fast16(expected, actual, ...) do \ 534 { \ 535 cut_trace_with_info_expression( \ 536 cut_test_with_user_message( \ 537 cut_assert_not_equal_int_fast16_helper((expected), \ 538 (actual), \ 539 #expected, \ 540 #actual), \ 541 __VA_ARGS__), \ 542 cut_assert_not_equal_int_fast16(expected, actual)); \ 543 } while (0) 544 545 /** 546 * cut_assert_equal_int_fast32: 547 * @expected: an expected integer value. 548 * @actual: an actual integer value. 549 * @...: optional message. See cut_message() for details. 550 * 551 * Passes if @expected == @actual. 552 * 553 * This function is available only when 554 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 555 * 556 * Since: 1.1.0 557 */ 558 #define cut_assert_equal_int_fast32(expected, actual, ...) do \ 559 { \ 560 cut_trace_with_info_expression( \ 561 cut_test_with_user_message( \ 562 cut_assert_equal_int_fast32_helper((expected), (actual), \ 563 #expected, #actual), \ 564 __VA_ARGS__), \ 565 cut_assert_equal_int_fast32(expected, actual)); \ 566 } while (0) 567 568 /** 569 * cut_assert_not_equal_int_fast32: 570 * @expected: an expected integer value. 571 * @actual: an actual integer value. 572 * @...: optional message. See cut_message() for details. 573 * 574 * Passes if @expected != @actual. 575 * 576 * This function is available only when 577 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 578 * 579 * Since: 1.1.0 580 */ 581 #define cut_assert_not_equal_int_fast32(expected, actual, ...) do \ 582 { \ 583 cut_trace_with_info_expression( \ 584 cut_test_with_user_message( \ 585 cut_assert_not_equal_int_fast32_helper((expected), \ 586 (actual), \ 587 #expected, \ 588 #actual), \ 589 __VA_ARGS__), \ 590 cut_assert_not_equal_int_fast32(expected, actual)); \ 591 } while (0) 592 593 /** 594 * cut_assert_equal_int_fast64: 595 * @expected: an expected integer value. 596 * @actual: an actual integer value. 597 * @...: optional message. See cut_message() for details. 598 * 599 * Passes if @expected == @actual. 600 * 601 * This function is available only when 602 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 603 * 604 * Since: 1.1.0 605 */ 606 #define cut_assert_equal_int_fast64(expected, actual, ...) do \ 607 { \ 608 cut_trace_with_info_expression( \ 609 cut_test_with_user_message( \ 610 cut_assert_equal_int_fast64_helper((expected), (actual), \ 611 #expected, #actual), \ 612 __VA_ARGS__), \ 613 cut_assert_equal_int_fast64(expected, actual)); \ 614 } while (0) 615 616 /** 617 * cut_assert_not_equal_int_fast64: 618 * @expected: an expected integer value. 619 * @actual: an actual integer value. 620 * @...: optional message. See cut_message() for details. 621 * 622 * Passes if @expected != @actual. 623 * 624 * This function is available only when 625 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 626 * 627 * Since: 1.1.0 628 */ 629 #define cut_assert_not_equal_int_fast64(expected, actual, ...) do \ 630 { \ 631 cut_trace_with_info_expression( \ 632 cut_test_with_user_message( \ 633 cut_assert_not_equal_int_fast64_helper((expected), \ 634 (actual), \ 635 #expected, \ 636 #actual), \ 637 __VA_ARGS__), \ 638 cut_assert_not_equal_int_fast64(expected, actual)); \ 639 } while (0) 640 641 /** 642 * cut_assert_equal_intptr: 643 * @expected: an expected integer value. 644 * @actual: an actual integer value. 645 * @...: optional message. See cut_message() for details. 646 * 647 * Passes if @expected == @actual. 648 * 649 * This function is available only when 650 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 651 * 652 * Since: 1.1.0 653 */ 654 #define cut_assert_equal_intptr(expected, actual, ...) do \ 655 { \ 656 cut_trace_with_info_expression( \ 657 cut_test_with_user_message( \ 658 cut_assert_equal_intptr_helper((expected), (actual), \ 659 #expected, #actual), \ 660 __VA_ARGS__), \ 661 cut_assert_equal_intptr(expected, actual)); \ 662 } while (0) 663 664 /** 665 * cut_assert_not_equal_intptr: 666 * @expected: an expected integer value. 667 * @actual: an actual integer value. 668 * @...: optional message. See cut_message() for details. 669 * 670 * Passes if @expected != @actual. 671 * 672 * This function is available only when 673 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 674 * 675 * Since: 1.1.0 676 */ 677 #define cut_assert_not_equal_intptr(expected, actual, ...) do \ 678 { \ 679 cut_trace_with_info_expression( \ 680 cut_test_with_user_message( \ 681 cut_assert_not_equal_intptr_helper((expected), (actual), \ 682 #expected, #actual), \ 683 __VA_ARGS__), \ 684 cut_assert_not_equal_intptr(expected, actual)); \ 685 } while (0) 686 687 /** 688 * cut_assert_equal_intmax: 689 * @expected: an expected integer value. 690 * @actual: an actual integer value. 691 * @...: optional message. See cut_message() for details. 692 * 693 * Passes if @expected == @actual. 694 * 695 * This function is available only when 696 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 697 * 698 * Since: 1.1.0 699 */ 700 #define cut_assert_equal_intmax(expected, actual, ...) do \ 701 { \ 702 cut_trace_with_info_expression( \ 703 cut_test_with_user_message( \ 704 cut_assert_equal_intmax_helper((expected), (actual), \ 705 #expected, #actual), \ 706 __VA_ARGS__), \ 707 cut_assert_equal_intmax(expected, actual)); \ 708 } while (0) 709 710 /** 711 * cut_assert_not_equal_intmax: 712 * @expected: an expected integer value. 713 * @actual: an actual integer value. 714 * @...: optional message. See cut_message() for details. 715 * 716 * Passes if @expected != @actual. 717 * 718 * This function is available only when 719 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 720 * 721 * Since: 1.1.0 722 */ 723 #define cut_assert_not_equal_intmax(expected, actual, ...) do \ 724 { \ 725 cut_trace_with_info_expression( \ 726 cut_test_with_user_message( \ 727 cut_assert_not_equal_intmax_helper((expected), (actual), \ 728 #expected, #actual), \ 729 __VA_ARGS__), \ 730 cut_assert_not_equal_intmax(expected, actual)); \ 731 } while (0) 732 #endif 733 734 /** 735 * cut_assert_equal_uint: 736 * @expected: an expected unsigned integer value. 737 * @actual: an actual unsigned integer value. 738 * @...: optional message. See cut_message() for details. 739 * 740 * Passes if @expected == @actual. 741 */ 742 #define cut_assert_equal_uint(expected, actual, ...) do \ 743 { \ 744 cut_trace_with_info_expression( \ 745 cut_test_with_user_message( \ 746 cut_assert_equal_uint_helper((expected), (actual), \ 747 #expected, #actual), \ 748 __VA_ARGS__), \ 749 cut_assert_equal_uint(expected, actual, __VA_ARGS__)); \ 750 } while (0) 751 752 /** 753 * cut_assert_not_equal_uint: 754 * @expected: an expected unsigned integer value. 755 * @actual: an actual unsigned integer value. 756 * @...: optional message. See cut_message() for details. 757 * 758 * Passes if @expected != @actual. 759 * 760 * Since: 1.0.7 761 */ 762 #define cut_assert_not_equal_uint(expected, actual, ...) do \ 763 { \ 764 cut_trace_with_info_expression( \ 765 cut_test_with_user_message( \ 766 cut_assert_not_equal_uint_helper((expected), (actual), \ 767 #expected, #actual), \ 768 __VA_ARGS__), \ 769 cut_assert_not_equal_uint(expected, actual)); \ 770 } while (0) 771 772 #ifdef CUT_SUPPORT_C99_STDINT_TYPES 773 /** 774 * cut_assert_equal_uint_least8: 775 * @expected: an expected unsigned integer value. 776 * @actual: an actual unsigned integer value. 777 * @...: optional message. See cut_message() for details. 778 * 779 * Passes if @expected == @actual. 780 * 781 * This function is available only when 782 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 783 * 784 * Since: 1.1.0 785 */ 786 #define cut_assert_equal_uint_least8(expected, actual, ...) do \ 787 { \ 788 cut_trace_with_info_expression( \ 789 cut_test_with_user_message( \ 790 cut_assert_equal_uint_least8_helper((expected), (actual), \ 791 #expected, #actual), \ 792 __VA_ARGS__), \ 793 cut_assert_equal_uint_least8(expected, actual)); \ 794 } while (0) 795 796 /** 797 * cut_assert_not_equal_uint_least8: 798 * @expected: an expected unsigned integer value. 799 * @actual: an actual unsigned integer value. 800 * @...: optional message. See cut_message() for details. 801 * 802 * Passes if @expected != @actual. 803 * 804 * This function is available only when 805 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 806 * 807 * Since: 1.1.0 808 */ 809 #define cut_assert_not_equal_uint_least8(expected, actual, ...) do \ 810 { \ 811 cut_trace_with_info_expression( \ 812 cut_test_with_user_message( \ 813 cut_assert_not_equal_uint_least8_helper((expected), \ 814 (actual), \ 815 #expected, \ 816 #actual), \ 817 __VA_ARGS__), \ 818 cut_assert_not_equal_uint_least8(expected, actual)); \ 819 } while (0) 820 821 /** 822 * cut_assert_equal_uint_least16: 823 * @expected: an expected unsigned integer value. 824 * @actual: an actual unsigned integer value. 825 * @...: optional message. See cut_message() for details. 826 * 827 * Passes if @expected == @actual. 828 * 829 * This function is available only when 830 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 831 * 832 * Since: 1.1.0 833 */ 834 #define cut_assert_equal_uint_least16(expected, actual, ...) do \ 835 { \ 836 cut_trace_with_info_expression( \ 837 cut_test_with_user_message( \ 838 cut_assert_equal_uint_least16_helper((expected), (actual), \ 839 #expected, #actual), \ 840 __VA_ARGS__), \ 841 cut_assert_equal_uint_least16(expected, actual)); \ 842 } while (0) 843 844 /** 845 * cut_assert_not_equal_uint_least16: 846 * @expected: an expected unsigned integer value. 847 * @actual: an actual unsigned integer value. 848 * @...: optional message. See cut_message() for details. 849 * 850 * Passes if @expected != @actual. 851 * 852 * This function is available only when 853 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 854 * 855 * Since: 1.1.0 856 */ 857 #define cut_assert_not_equal_uint_least16(expected, actual, ...) do \ 858 { \ 859 cut_trace_with_info_expression( \ 860 cut_test_with_user_message( \ 861 cut_assert_not_equal_uint_least16_helper((expected), \ 862 (actual), \ 863 #expected, \ 864 #actual), \ 865 __VA_ARGS__), \ 866 cut_assert_not_equal_uint_least16(expected, actual)); \ 867 } while (0) 868 869 /** 870 * cut_assert_equal_uint_least32: 871 * @expected: an expected unsigned integer value. 872 * @actual: an actual unsigned integer value. 873 * @...: optional message. See cut_message() for details. 874 * 875 * Passes if @expected == @actual. 876 * 877 * This function is available only when 878 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 879 * 880 * Since: 1.1.0 881 */ 882 #define cut_assert_equal_uint_least32(expected, actual, ...) do \ 883 { \ 884 cut_trace_with_info_expression( \ 885 cut_test_with_user_message( \ 886 cut_assert_equal_uint_least32_helper((expected), (actual), \ 887 #expected, #actual), \ 888 __VA_ARGS__), \ 889 cut_assert_equal_uint_least32(expected, actual)); \ 890 } while (0) 891 892 /** 893 * cut_assert_not_equal_uint_least32: 894 * @expected: an expected unsigned integer value. 895 * @actual: an actual unsigned integer value. 896 * @...: optional message. See cut_message() for details. 897 * 898 * Passes if @expected != @actual. 899 * 900 * This function is available only when 901 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 902 * 903 * Since: 1.1.0 904 */ 905 #define cut_assert_not_equal_uint_least32(expected, actual, ...) do \ 906 { \ 907 cut_trace_with_info_expression( \ 908 cut_test_with_user_message( \ 909 cut_assert_not_equal_uint_least32_helper((expected), \ 910 (actual), \ 911 #expected, \ 912 #actual), \ 913 __VA_ARGS__), \ 914 cut_assert_not_equal_uint_least32(expected, actual)); \ 915 } while (0) 916 917 /** 918 * cut_assert_equal_uint_least64: 919 * @expected: an expected unsigned integer value. 920 * @actual: an actual unsigned integer value. 921 * @...: optional message. See cut_message() for details. 922 * 923 * Passes if @expected == @actual. 924 * 925 * This function is available only when 926 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 927 * 928 * Since: 1.1.0 929 */ 930 #define cut_assert_equal_uint_least64(expected, actual, ...) do \ 931 { \ 932 cut_trace_with_info_expression( \ 933 cut_test_with_user_message( \ 934 cut_assert_equal_uint_least64_helper((expected), (actual), \ 935 #expected, #actual), \ 936 __VA_ARGS__), \ 937 cut_assert_equal_uint_least64(expected, actual)); \ 938 } while (0) 939 940 /** 941 * cut_assert_not_equal_uint_least64: 942 * @expected: an expected unsigned integer value. 943 * @actual: an actual unsigned integer value. 944 * @...: optional message. See cut_message() for details. 945 * 946 * Passes if @expected != @actual. 947 * 948 * This function is available only when 949 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 950 * 951 * Since: 1.1.0 952 */ 953 #define cut_assert_not_equal_uint_least64(expected, actual, ...) do \ 954 { \ 955 cut_trace_with_info_expression( \ 956 cut_test_with_user_message( \ 957 cut_assert_not_equal_uint_least64_helper((expected), \ 958 (actual), \ 959 #expected, \ 960 #actual), \ 961 __VA_ARGS__), \ 962 cut_assert_not_equal_uint_least64(expected, actual)); \ 963 } while (0) 964 965 /** 966 * cut_assert_equal_uint_fast8: 967 * @expected: an expected unsigned integer value. 968 * @actual: an actual unsigned integer value. 969 * @...: optional message. See cut_message() for details. 970 * 971 * Passes if @expected == @actual. 972 * 973 * This function is available only when 974 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 975 * 976 * Since: 1.1.0 977 */ 978 #define cut_assert_equal_uint_fast8(expected, actual, ...) do \ 979 { \ 980 cut_trace_with_info_expression( \ 981 cut_test_with_user_message( \ 982 cut_assert_equal_uint_fast8_helper((expected), (actual), \ 983 #expected, #actual), \ 984 __VA_ARGS__), \ 985 cut_assert_equal_uint_fast8(expected, actual)); \ 986 } while (0) 987 988 /** 989 * cut_assert_not_equal_uint_fast8: 990 * @expected: an expected unsigned integer value. 991 * @actual: an actual unsigned integer value. 992 * @...: optional message. See cut_message() for details. 993 * 994 * Passes if @expected != @actual. 995 * 996 * This function is available only when 997 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 998 * 999 * Since: 1.1.0 1000 */ 1001 #define cut_assert_not_equal_uint_fast8(expected, actual, ...) do \ 1002 { \ 1003 cut_trace_with_info_expression( \ 1004 cut_test_with_user_message( \ 1005 cut_assert_not_equal_uint_fast8_helper((expected), \ 1006 (actual), \ 1007 #expected, \ 1008 #actual), \ 1009 __VA_ARGS__), \ 1010 cut_assert_not_equal_uint_fast8(expected, actual)); \ 1011 } while (0) 1012 1013 /** 1014 * cut_assert_equal_uint_fast16: 1015 * @expected: an expected unsigned integer value. 1016 * @actual: an actual unsigned integer value. 1017 * @...: optional message. See cut_message() for details. 1018 * 1019 * Passes if @expected == @actual. 1020 * 1021 * This function is available only when 1022 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 1023 * 1024 * Since: 1.1.0 1025 */ 1026 #define cut_assert_equal_uint_fast16(expected, actual, ...) do \ 1027 { \ 1028 cut_trace_with_info_expression( \ 1029 cut_test_with_user_message( \ 1030 cut_assert_equal_uint_fast16_helper((expected), (actual), \ 1031 #expected, #actual), \ 1032 __VA_ARGS__), \ 1033 cut_assert_equal_uint_fast16(expected, actual)); \ 1034 } while (0) 1035 1036 /** 1037 * cut_assert_not_equal_uint_fast16: 1038 * @expected: an expected unsigned integer value. 1039 * @actual: an actual unsigned integer value. 1040 * @...: optional message. See cut_message() for details. 1041 * 1042 * Passes if @expected != @actual. 1043 * 1044 * This function is available only when 1045 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 1046 * 1047 * Since: 1.1.0 1048 */ 1049 #define cut_assert_not_equal_uint_fast16(expected, actual, ...) do \ 1050 { \ 1051 cut_trace_with_info_expression( \ 1052 cut_test_with_user_message( \ 1053 cut_assert_not_equal_uint_fast16_helper((expected), \ 1054 (actual), \ 1055 #expected, \ 1056 #actual), \ 1057 __VA_ARGS__), \ 1058 cut_assert_not_equal_uint_fast16(expected, actual)); \ 1059 } while (0) 1060 1061 /** 1062 * cut_assert_equal_uint_fast32: 1063 * @expected: an expected unsigned integer value. 1064 * @actual: an actual unsigned integer value. 1065 * @...: optional message. See cut_message() for details. 1066 * 1067 * Passes if @expected == @actual. 1068 * 1069 * This function is available only when 1070 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 1071 * 1072 * Since: 1.1.0 1073 */ 1074 #define cut_assert_equal_uint_fast32(expected, actual, ...) do \ 1075 { \ 1076 cut_trace_with_info_expression( \ 1077 cut_test_with_user_message( \ 1078 cut_assert_equal_uint_fast32_helper((expected), (actual), \ 1079 #expected, #actual), \ 1080 __VA_ARGS__), \ 1081 cut_assert_equal_uint_fast32(expected, actual)); \ 1082 } while (0) 1083 1084 /** 1085 * cut_assert_not_equal_uint_fast32: 1086 * @expected: an expected unsigned integer value. 1087 * @actual: an actual unsigned integer value. 1088 * @...: optional message. See cut_message() for details. 1089 * 1090 * Passes if @expected != @actual. 1091 * 1092 * This function is available only when 1093 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 1094 * 1095 * Since: 1.1.0 1096 */ 1097 #define cut_assert_not_equal_uint_fast32(expected, actual, ...) do \ 1098 { \ 1099 cut_trace_with_info_expression( \ 1100 cut_test_with_user_message( \ 1101 cut_assert_not_equal_uint_fast32_helper((expected), \ 1102 (actual), \ 1103 #expected,\ 1104 #actual), \ 1105 __VA_ARGS__), \ 1106 cut_assert_not_equal_uint_fast32(expected, actual)); \ 1107 } while (0) 1108 1109 /** 1110 * cut_assert_equal_uint_fast64: 1111 * @expected: an expected unsigned integer value. 1112 * @actual: an actual unsigned integer value. 1113 * @...: optional message. See cut_message() for details. 1114 * 1115 * Passes if @expected == @actual. 1116 * 1117 * This function is available only when 1118 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 1119 * 1120 * Since: 1.1.0 1121 */ 1122 #define cut_assert_equal_uint_fast64(expected, actual, ...) do \ 1123 { \ 1124 cut_trace_with_info_expression( \ 1125 cut_test_with_user_message( \ 1126 cut_assert_equal_uint_fast64_helper((expected), (actual), \ 1127 #expected, #actual), \ 1128 __VA_ARGS__), \ 1129 cut_assert_equal_uint_fast64(expected, actual)); \ 1130 } while (0) 1131 1132 /** 1133 * cut_assert_not_equal_uint_fast64: 1134 * @expected: an expected unsigned integer value. 1135 * @actual: an actual unsigned integer value. 1136 * @...: optional message. See cut_message() for details. 1137 * 1138 * Passes if @expected != @actual. 1139 * 1140 * This function is available only when 1141 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 1142 * 1143 * Since: 1.1.0 1144 */ 1145 #define cut_assert_not_equal_uint_fast64(expected, actual, ...) do \ 1146 { \ 1147 cut_trace_with_info_expression( \ 1148 cut_test_with_user_message( \ 1149 cut_assert_not_equal_uint_fast64_helper((expected), \ 1150 (actual), \ 1151 #expected, \ 1152 #actual), \ 1153 __VA_ARGS__), \ 1154 cut_assert_not_equal_uint_fast64(expected, actual)); \ 1155 } while (0) 1156 1157 /** 1158 * cut_assert_equal_uintptr: 1159 * @expected: an expected unsigned integer value. 1160 * @actual: an actual unsigned integer value. 1161 * @...: optional message. See cut_message() for details. 1162 * 1163 * Passes if @expected == @actual. 1164 * 1165 * This function is available only when 1166 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 1167 * 1168 * Since: 1.1.0 1169 */ 1170 #define cut_assert_equal_uintptr(expected, actual, ...) do \ 1171 { \ 1172 cut_trace_with_info_expression( \ 1173 cut_test_with_user_message( \ 1174 cut_assert_equal_uintptr_helper((expected), (actual), \ 1175 #expected, #actual), \ 1176 __VA_ARGS__), \ 1177 cut_assert_equal_uintptr(expected, actual)); \ 1178 } while (0) 1179 1180 /** 1181 * cut_assert_not_equal_uintptr: 1182 * @expected: an expected unsigned integer value. 1183 * @actual: an actual unsigned integer value. 1184 * @...: optional message. See cut_message() for details. 1185 * 1186 * Passes if @expected != @actual. 1187 * 1188 * This function is available only when 1189 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 1190 * 1191 * Since: 1.1.0 1192 */ 1193 #define cut_assert_not_equal_uintptr(expected, actual, ...) do \ 1194 { \ 1195 cut_trace_with_info_expression( \ 1196 cut_test_with_user_message( \ 1197 cut_assert_not_equal_uintptr_helper((expected), (actual), \ 1198 #expected, #actual), \ 1199 __VA_ARGS__), \ 1200 cut_assert_not_equal_uintptr(expected, actual)); \ 1201 } while (0) 1202 1203 /** 1204 * cut_assert_equal_uintmax: 1205 * @expected: an expected unsigned integer value. 1206 * @actual: an actual unsigned integer value. 1207 * @...: optional message. See cut_message() for details. 1208 * 1209 * Passes if @expected == @actual. 1210 * 1211 * This function is available only when 1212 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 1213 * 1214 * Since: 1.1.0 1215 */ 1216 #define cut_assert_equal_uintmax(expected, actual, ...) do \ 1217 { \ 1218 cut_trace_with_info_expression( \ 1219 cut_test_with_user_message( \ 1220 cut_assert_equal_uintmax_helper((expected), (actual), \ 1221 #expected, #actual), \ 1222 __VA_ARGS__), \ 1223 cut_assert_equal_uintmax(expected, actual)); \ 1224 } while (0) 1225 1226 /** 1227 * cut_assert_not_equal_uintmax: 1228 * @expected: an expected unsigned integer value. 1229 * @actual: an actual unsigned integer value. 1230 * @...: optional message. See cut_message() for details. 1231 * 1232 * Passes if @expected != @actual. 1233 * 1234 * This function is available only when 1235 * CUT_SUPPORT_C99_STDINT_TYPES is defined. 1236 * 1237 * Since: 1.1.0 1238 */ 1239 #define cut_assert_not_equal_uintmax(expected, actual, ...) do \ 1240 { \ 1241 cut_trace_with_info_expression( \ 1242 cut_test_with_user_message( \ 1243 cut_assert_not_equal_uintmax_helper((expected), (actual), \ 1244 #expected, #actual), \ 1245 __VA_ARGS__), \ 1246 cut_assert_not_equal_uintmax(expected, actual)); \ 1247 } while (0) 1248 #endif 1249 1250 /** 1251 * cut_assert_equal_size: 1252 * @expected: an expected size_t value. 1253 * @actual: an actual size_t value. 1254 * @...: optional message. See cut_message() for details. 1255 * 1256 * Passes if @expected == @actual. 1257 * 1258 * Since: 1.0.6 1259 */ 1260 #define cut_assert_equal_size(expected, actual, ...) do \ 1261 { \ 1262 cut_trace_with_info_expression( \ 1263 cut_test_with_user_message( \ 1264 cut_assert_equal_size_helper((expected), (actual), \ 1265 #expected, #actual), \ 1266 __VA_ARGS__), \ 1267 cut_assert_equal_size(expected, actual, __VA_ARGS__)); \ 1268 } while (0) 1269 1270 /** 1271 * cut_assert_not_equal_size: 1272 * @expected: an expected size_t value. 1273 * @actual: an actual size_t value. 1274 * @...: optional message. See cut_message() for details. 1275 * 1276 * Passes if @expected != @actual. 1277 * 1278 * Since: 1.0.7 1279 */ 1280 #define cut_assert_not_equal_size(expected, actual, ...) do \ 1281 { \ 1282 cut_trace_with_info_expression( \ 1283 cut_test_with_user_message( \ 1284 cut_assert_not_equal_size_helper((expected), (actual), \ 1285 #expected, #actual), \ 1286 __VA_ARGS__), \ 1287 cut_assert_not_equal_size(expected, actual)); \ 1288 } while (0) 1289 1290 /** 1291 * cut_assert_equal_double: 1292 * @expected: an expected float value. 1293 * @error: a float value that specifies error range. 1294 * @actual: an actual float value. 1295 * @...: optional message. See cut_message() for details. 1296 * 1297 * Passes if (@expected - @error) <= @actual <= (@expected + @error). 1298 */ 1299 #define cut_assert_equal_double(expected, error, actual, ...) do \ 1300 { \ 1301 cut_trace_with_info_expression( \ 1302 cut_test_with_user_message( \ 1303 cut_assert_equal_double_helper((expected), (error), \ 1304 (actual), \ 1305 #expected, #error, #actual), \ 1306 __VA_ARGS__), \ 1307 cut_assert_equal_double(expected, error, actual, __VA_ARGS__)); \ 1308 } while (0) 1309 1310 /** 1311 * cut_assert_not_equal_double: 1312 * @expected: an expected float value. 1313 * @error: a float value that specifies error range. 1314 * @actual: an actual float value. 1315 * @...: optional message. See cut_message() for details. 1316 * 1317 * Passes if @actual < (@expected - @error) && (@expected + @error) < @actual. 1318 * 1319 * Since: 1.0.7 1320 */ 1321 #define cut_assert_not_equal_double(expected, error, actual, ...) do \ 1322 { \ 1323 cut_trace_with_info_expression( \ 1324 cut_test_with_user_message( \ 1325 cut_assert_not_equal_double_helper( \ 1326 (expected), (error), (actual), \ 1327 #expected, #error, #actual), \ 1328 __VA_ARGS__), \ 1329 cut_assert_not_equal_double(expected, error, actual)); \ 1330 } while (0) 1331 1332 /** 1333 * cut_assert_equal_char: 1334 * @expected: an expected char value. 1335 * @actual: an actual char value. 1336 * @...: optional message. See cut_message() for details. 1337 * 1338 * Passes if @expected == @actual. 1339 * 1340 * e.g.: 1341 * |[ 1342 * cut_assert_equal_char('a', 'a'); -> Pass 1343 * cut_assert_equal_char('a', 'b'); -> Fail 1344 * ]| 1345 * 1346 * Since: 1.1.3 1347 */ 1348 #define cut_assert_equal_char(expected, actual, ...) do \ 1349 { \ 1350 cut_trace_with_info_expression( \ 1351 cut_test_with_user_message( \ 1352 cut_assert_equal_char_helper(expected, actual, \ 1353 #expected, #actual), \ 1354 __VA_ARGS__), \ 1355 cut_assert_equal_char(expected, actual, __VA_ARGS__)); \ 1356 } while (0) 1357 1358 /** 1359 * cut_assert_not_equal_char: 1360 * @expected: an expected char value. 1361 * @actual: an actual char value. 1362 * @...: optional message. See cut_message() for details. 1363 * 1364 * Passes if @expected != @actual. 1365 * 1366 * e.g.: 1367 * |[ 1368 * cut_assert_not_equal_char('a', 'b'); -> Pass 1369 * cut_assert_not_equal_char('a', 'a'); -> Fail 1370 * ]| 1371 * 1372 * Since: 1.1.3 1373 */ 1374 #define cut_assert_not_equal_char(expected, actual, ...) do \ 1375 { \ 1376 cut_trace_with_info_expression( \ 1377 cut_test_with_user_message( \ 1378 cut_assert_not_equal_char_helper(expected, actual, \ 1379 #expected, #actual), \ 1380 __VA_ARGS__), \ 1381 cut_assert_not_equal_char(expected, actual)); \ 1382 } while (0) 1383 1384 /** 1385 * cut_assert_equal_string: 1386 * @expected: an expected string value. 1387 * @actual: an actual string value. 1388 * @...: optional message. See cut_message() for details. 1389 * 1390 * Passes if both @expected and @actual are %NULL or 1391 * strcmp(@expected, @actual) == 0. 1392 * 1393 * e.g.: 1394 * |[ 1395 * cut_assert_equal_string("abc", "abc"); -> Pass 1396 * cut_assert_equal_string(NULL, NULL); -> Pass 1397 * cut_assert_equal_string("abc", "ABC"); -> Fail 1398 * cut_assert_equal_string("abc", NULL); -> Fail 1399 * cut_assert_equal_string(NULL, "abc"); -> Fail 1400 * ]| 1401 */ 1402 #define cut_assert_equal_string(expected, actual, ...) do \ 1403 { \ 1404 cut_trace_with_info_expression( \ 1405 cut_test_with_user_message( \ 1406 cut_assert_equal_string_helper(expected, actual, \ 1407 #expected, #actual), \ 1408 __VA_ARGS__), \ 1409 cut_assert_equal_string(expected, actual, __VA_ARGS__)); \ 1410 } while (0) 1411 1412 /** 1413 * cut_assert_not_equal_string: 1414 * @expected: an expected string value. 1415 * @actual: an actual string value. 1416 * @...: optional message. See cut_message() for details. 1417 * 1418 * Passes if one of @expected and @actual is %NULL or 1419 * strcmp(@expected, @actual) != 0. 1420 * 1421 * e.g.: 1422 * |[ 1423 * cut_assert_not_equal_string("abc", NULL); -> Pass 1424 * cut_assert_not_equal_string(NULL, "abc"); -> Pass 1425 * cut_assert_not_equal_string("abc", "ABC"); -> Pass 1426 * cut_assert_not_equal_string("abc", "abc"); -> Fail 1427 * cut_assert_not_equal_string(NULL, NULL); -> Fail 1428 * ]| 1429 * 1430 * Since: 1.0.7 1431 */ 1432 #define cut_assert_not_equal_string(expected, actual, ...) do \ 1433 { \ 1434 cut_trace_with_info_expression( \ 1435 cut_test_with_user_message( \ 1436 cut_assert_not_equal_string_helper(expected, actual, \ 1437 #expected, #actual), \ 1438 __VA_ARGS__), \ 1439 cut_assert_not_equal_string(expected, actual)); \ 1440 } while (0) 1441 1442 /** 1443 * cut_assert_equal_string_with_free: 1444 * @expected: an expected string value. 1445 * @actual: an actual string value that is freed. 1446 * @...: optional message. See cut_message() for details. 1447 * 1448 * Passes if both @expected and @actual are %NULL or 1449 * strcmp(@expected, @actual) == 0. 1450 * 1451 * See also cut_assert_equal_string() for examples. 1452 * 1453 * Since: 0.3 1454 */ 1455 #define cut_assert_equal_string_with_free(expected, actual, ...) do \ 1456 { \ 1457 cut_trace_with_info_expression( \ 1458 cut_test_with_user_message( \ 1459 cut_assert_equal_string_helper(expected, \ 1460 cut_take_string(actual), \ 1461 #expected, #actual), \ 1462 __VA_ARGS__), \ 1463 cut_assert_equal_string_with_free(expected, actual, \ 1464 __VA_ARGS__)); \ 1465 } while (0) 1466 1467 #ifndef CUTTER_DISABLE_DEPRECATED 1468 /** 1469 * cut_assert_equal_string_or_null: 1470 * @expected: an expected string value. 1471 * @actual: an actual string value. 1472 * @...: optional message. See cut_message() for details. 1473 * 1474 * Deprecated: 0.3: Use cut_assert_equal_string() instead. 1475 */ 1476 #define cut_assert_equal_string_or_null(expected, actual, ...) do \ 1477 { \ 1478 cut_trace_with_info_expression( \ 1479 cut_test_with_user_message( \ 1480 cut_assert_equal_string(expected, actual), \ 1481 __VA_ARGS__), \ 1482 cut_assert_equal_string_or_null(expected, actual, \ 1483 __VA_ARGS__)); \ 1484 } while (0) 1485 #endif 1486 1487 /** 1488 * cut_assert_equal_substring: 1489 * @expected: an expected string value. 1490 * @actual: an actual string value. 1491 * @length: compared string length. 1492 * @...: optional message. See cut_message() for details. 1493 * 1494 * Passes if (1) both @expected and @actual are %NULL and 1495 * @length == 1 or (2) strncmp(@expected, @actual, @length) 1496 * == 0. 1497 * 1498 * e.g.: 1499 * |[ 1500 * cut_assert_equal_substring("abcdef", "abcDEF", 3); -> Pass 1501 * cut_assert_equal_substring(NULL, NULL, 0); -> Pass 1502 * cut_assert_equal_substring(NULL, NULL, 3); -> Fail 1503 * cut_assert_equal_substring("abc", "ABC", 3); -> Fail 1504 * cut_assert_equal_substring("abc", NULL, 3); -> Fail 1505 * cut_assert_equal_substring(NULL, "abc", 3); -> Fail 1506 * ]| 1507 * 1508 * Since: 1.0.7 1509 */ 1510 #define cut_assert_equal_substring(expected, actual, length, ...) do \ 1511 { \ 1512 cut_trace_with_info_expression( \ 1513 cut_test_with_user_message( \ 1514 cut_assert_equal_substring_helper(expected, actual, length, \ 1515 #expected, #actual, \ 1516 #length), \ 1517 __VA_ARGS__), \ 1518 cut_assert_equal_substring(expected, actual, length)); \ 1519 } while (0) 1520 1521 /** 1522 * cut_assert_not_equal_substring: 1523 * @expected: an expected string value. 1524 * @actual: an actual string value. 1525 * @length: compared string length. 1526 * @...: optional message. See cut_message() for details. 1527 * 1528 * Passes if (1) one of @expected and @actual is %NULL or 1529 * (2) strncmp(@expected, @actual, @length) != 0. 1530 * 1531 * e.g.: 1532 * |[ 1533 * cut_assert_not_equal_substring("abc", "ABC", 3); -> Pass 1534 * cut_assert_not_equal_substring("abc", NULL, 3); -> Pass 1535 * cut_assert_not_equal_substring(NULL, "abc", 3); -> Pass 1536 * cut_assert_not_equal_substring("abcdef", "abcDEF", 3); -> Fail 1537 * cut_assert_not_equal_substring(NULL, NULL, 0); -> Fail 1538 * cut_assert_not_equal_substring(NULL, NULL, 3); -> Fail 1539 * ]| 1540 * 1541 * Since: 1.0.7 1542 */ 1543 #define cut_assert_not_equal_substring(expected, actual, length, \ 1544 ...) do \ 1545 { \ 1546 cut_trace_with_info_expression( \ 1547 cut_test_with_user_message( \ 1548 cut_assert_not_equal_substring_helper(expected, actual, \ 1549 length, \ 1550 #expected, #actual, \ 1551 #length), \ 1552 __VA_ARGS__), \ 1553 cut_assert_not_equal_substring(expected, actual, length)); \ 1554 } while (0) 1555 1556 /** 1557 * cut_assert_equal_memory: 1558 * @expected: an expected data. 1559 * @expected_size: a size of @expected. 1560 * @actual: an actual data. 1561 * @actual_size: a size of @actual. 1562 * @...: optional message. See cut_message() for details. 1563 * 1564 * Passes if @expected_size == @actual_size and 1565 * memcmp(@expected, @actual, @expected_size) == 0. 1566 */ 1567 #define cut_assert_equal_memory(expected, expected_size, \ 1568 actual, actual_size, ...) do \ 1569 { \ 1570 cut_trace_with_info_expression( \ 1571 cut_test_with_user_message( \ 1572 cut_assert_equal_memory_helper(expected, expected_size, \ 1573 actual, actual_size, \ 1574 #expected, #expected_size, \ 1575 #actual, #actual_size), \ 1576 __VA_ARGS__), \ 1577 cut_assert_equal_memory(expected, expected_size, \ 1578 actual, actual_size, __VA_ARGS__)); \ 1579 } while (0) 1580 1581 /** 1582 * cut_assert_not_equal_memory: 1583 * @expected: an expected data. 1584 * @expected_size: a size of @expected. 1585 * @actual: an actual data. 1586 * @actual_size: a size of @actual. 1587 * @...: optional message. See cut_message() for details. 1588 * 1589 * Passes if @expected_size != @actual_size or 1590 * memcmp(@expected, @actual, @expected_size) != 0. 1591 * 1592 * Since: 1.0.7 1593 */ 1594 #define cut_assert_not_equal_memory(expected, expected_size, \ 1595 actual, actual_size, ...) do \ 1596 { \ 1597 cut_trace_with_info_expression( \ 1598 cut_test_with_user_message( \ 1599 cut_assert_not_equal_memory_helper(expected, expected_size, \ 1600 actual, actual_size, \ 1601 #expected, \ 1602 #expected_size, \ 1603 #actual, \ 1604 #actual_size), \ 1605 __VA_ARGS__), \ 1606 cut_assert_not_equal_memory(expected, expected_size, \ 1607 actual, actual_size)); \ 1608 } while (0) 1609 1610 /** 1611 * cut_assert_equal_string_array: 1612 * @expected: an expected %NULL-terminated array of strings. 1613 * @actual: an actual %NULL-terminated array of strings. 1614 * @...: optional message. See cut_message() for details. 1615 * 1616 * Passes if both @expected and @actual are not %NULL and 1617 * have same content (strcmp() == 0) strings. 1618 */ 1619 #define cut_assert_equal_string_array(expected, actual, ...) do \ 1620 { \ 1621 cut_trace_with_info_expression( \ 1622 cut_test_with_user_message( \ 1623 cut_assert_equal_string_array_helper(expected, actual, \ 1624 #expected, #actual), \ 1625 __VA_ARGS__), \ 1626 cut_assert_equal_string_array(expected, actual, __VA_ARGS__)); \ 1627 } while (0) 1628 1629 /** 1630 * cut_assert_equal_string_array_with_free: 1631 * @expected: an expected %NULL-terminated array of strings. 1632 * @actual: an actual %NULL-terminated array of strings that are freed. 1633 * @...: optional message. See cut_message() for details. 1634 * 1635 * Passes if both @expected and @actual are not %NULL and 1636 * have same content (strcmp() == 0) strings. 1637 * 1638 * Since: 0.9 1639 */ 1640 #define cut_assert_equal_string_array_with_free(expected, actual, \ 1641 ...) do \ 1642 { \ 1643 cut_trace_with_info_expression( \ 1644 cut_test_with_user_message( \ 1645 cut_assert_equal_string_array_helper( \ 1646 expected, (char **)cut_take_string_array(actual), \ 1647 #expected, #actual), \ 1648 __VA_ARGS__), \ 1649 cut_assert_equal_string_array_with_free(expected, actual, \ 1650 __VA_ARGS__)); \ 1651 } while (0) 1652 1653 /** 1654 * cut_assert_operator: 1655 * @lhs: a left hand side value. 1656 * @operator: a binary operator. 1657 * @rhs: a right hand side value. 1658 * @...: optional message. See cut_message() for details. 1659 * 1660 * Passes if (@lhs @operator @rhs) is TRUE. 1661 * 1662 * e.g.: 1663 * |[ 1664 * cut_assert_operator(1, <, 2) -> (1 < 2); 1665 * ]| 1666 */ 1667 #define cut_assert_operator(lhs, operator, rhs, ...) do \ 1668 { \ 1669 cut_trace_with_info_expression( \ 1670 cut_test_with_user_message( \ 1671 cut_assert_operator_helper(((lhs) operator (rhs)), \ 1672 #lhs, #operator, #rhs), \ 1673 __VA_ARGS__), \ 1674 cut_assert_operator(lhs, operator, rhs, __VA_ARGS__)); \ 1675 } while (0) 1676 1677 /** 1678 * cut_assert_operator_int: 1679 * @lhs: a left hand side integer value. 1680 * @operator: a binary operator. 1681 * @rhs: a right hand side integer value. 1682 * @...: optional message. See cut_message() for details. 1683 * 1684 * Passes if (@lhs @operator @rhs) is TRUE. 1685 * 1686 * e.g.: 1687 * |[ 1688 * cut_assert_operator_int(1, <, 2) -> (1 < 2); 1689 * ]| 1690 */ 1691 #define cut_assert_operator_int(lhs, operator, rhs, ...) do \ 1692 { \ 1693 long _lhs = (lhs); \ 1694 long _rhs = (rhs); \ 1695 \ 1696 cut_trace_with_info_expression( \ 1697 cut_test_with_user_message( \ 1698 cut_assert_operator_int_helper((_lhs operator _rhs), \ 1699 _lhs, _rhs, \ 1700 #lhs, #operator, #rhs), \ 1701 __VA_ARGS__), \ 1702 cut_assert_operator_int(lhs, operator, rhs, __VA_ARGS__)); \ 1703 } while(0) 1704 1705 /** 1706 * cut_assert_operator_uint: 1707 * @lhs: a left hand side unsigned integer value. 1708 * @operator: a binary operator. 1709 * @rhs: a right hand side unsigned integer value. 1710 * @...: optional message. See cut_message() for details. 1711 * 1712 * Passes if (@lhs @operator @rhs) is TRUE. 1713 * 1714 * e.g.: 1715 * |[ 1716 * cut_assert_operator_uint(1, <, 2) -> (1 < 2); 1717 * ]| 1718 * 1719 * Since: 1.0.5 1720 */ 1721 #define cut_assert_operator_uint(lhs, operator, rhs, ...) do \ 1722 { \ 1723 unsigned long _lhs = (lhs); \ 1724 unsigned long _rhs = (rhs); \ 1725 \ 1726 cut_trace_with_info_expression( \ 1727 cut_test_with_user_message( \ 1728 cut_assert_operator_uint_helper((_lhs operator _rhs), \ 1729 _lhs, _rhs, \ 1730 #lhs, #operator, #rhs), \ 1731 __VA_ARGS__), \ 1732 cut_assert_operator_uint(lhs, operator, rhs, __VA_ARGS__)); \ 1733 } while(0) 1734 1735 /** 1736 * cut_assert_operator_size: 1737 * @lhs: a left hand side size_t value. 1738 * @operator: a binary operator. 1739 * @rhs: a right hand side size_t value. 1740 * @...: optional message. See cut_message() for details. 1741 * 1742 * Passes if (@lhs @operator @rhs) is TRUE. 1743 * 1744 * e.g.: 1745 * |[ 1746 * cut_assert_operator_size(1, <, 2) -> (1 < 2); 1747 * ]| 1748 * 1749 * Since: 1.0.5 1750 */ 1751 #define cut_assert_operator_size(lhs, operator, rhs, ...) do \ 1752 { \ 1753 size_t _lhs = (lhs); \ 1754 size_t _rhs = (rhs); \ 1755 \ 1756 cut_trace_with_info_expression( \ 1757 cut_test_with_user_message( \ 1758 cut_assert_operator_size_helper((_lhs operator _rhs), \ 1759 _lhs, _rhs, \ 1760 #lhs, #operator, #rhs), \ 1761 __VA_ARGS__), \ 1762 cut_assert_operator_size(lhs, operator, rhs, __VA_ARGS__)); \ 1763 } while(0) 1764 1765 /** 1766 * cut_assert_operator_double: 1767 * @lhs: a left hand side double value. 1768 * @operator: a binary operator. 1769 * @rhs: a right hand side double value. 1770 * @...: optional message. See cut_message() for details. 1771 * 1772 * Passes if (@lhs @operator @rhs) is TRUE. 1773 * 1774 * e.g.: 1775 * |[ 1776 * cut_assert_operator_double(1.1, <, 2.2) -> (1.1 < 2.2); 1777 * ]| 1778 * 1779 * Since: 1.0.5 1780 */ 1781 #define cut_assert_operator_double(lhs, operator, rhs, ...) do \ 1782 { \ 1783 double _lhs = (lhs); \ 1784 double _rhs = (rhs); \ 1785 \ 1786 cut_trace_with_info_expression( \ 1787 cut_test_with_user_message( \ 1788 cut_assert_operator_double_helper((_lhs operator _rhs), \ 1789 _lhs, _rhs, \ 1790 #lhs, #operator, #rhs), \ 1791 __VA_ARGS__), \ 1792 cut_assert_operator_double(lhs, operator, rhs, __VA_ARGS__)); \ 1793 } while(0) 1794 1795 /** 1796 * cut_assert_equal: 1797 * @function: a function that compares @actual with @expected. 1798 * @expected: an expected value. 1799 * @actual: an actual value. 1800 * @...: optional message. See cut_message() for details. 1801 * 1802 * Passes if @function(@expected, @actual) returns %CUT_TRUE. 1803 * 1804 * e.g.: 1805 * |[ 1806 * cut_assert_equal(!strcmp, "abc", "abc"); -> Pass 1807 * ]| 1808 */ 1809 #define cut_assert_equal(function, expected, actual, ...) do \ 1810 { \ 1811 cut_trace_with_info_expression( \ 1812 cut_test_with_user_message( \ 1813 cut_assert_equal_helper(function(expected, actual), \ 1814 #function, #expected, #actual), \ 1815 __VA_ARGS__), \ 1816 cut_assert_equal(function, expected, actual, __VA_ARGS__)); \ 1817 } while (0) 1818 1819 /** 1820 * cut_assert_errno: 1821 * @...: optional message. See cut_message() for details. 1822 * 1823 * Passes if errno is 0. 1824 * 1825 * e.g.: 1826 * |[ 1827 * count = write(stdout, buffer, strlen(buffer)); 1828 * cut_assert_errno("Failed to write"); -> Pass when count != -1 1829 * ]| 1830 * 1831 * Since: 0.8 1832 */ 1833 #define cut_assert_errno(...) do \ 1834 { \ 1835 cut_trace_with_info_expression( \ 1836 cut_test_with_user_message( \ 1837 cut_assert_errno_helper(), \ 1838 __VA_ARGS__), \ 1839 cut_assert_errno(__VA_ARGS__)); \ 1840 } while (0) 1841 1842 #ifndef CUTTER_DISABLE_DEPRECATED 1843 /** 1844 * cut_assert_file_exist: 1845 * @path: the path to test. 1846 * @...: optional message. See cut_message() for details. 1847 * 1848 * Passes if @path exists. It may or may not be a regular file. 1849 * 1850 * e.g.: 1851 * |[ 1852 * cut_assert_file_exist("/tmp"); -> Pass on many environment 1853 * cut_assert_file_exist("/non-existent"); -> Fail 1854 * ]| 1855 * 1856 * Since: 0.9 1857 * Deprecated: 1.0.2: Use cut_assert_path_exist() instead. 1858 */ 1859 #define cut_assert_file_exist(path, ...) do \ 1860 { \ 1861 cut_trace_with_info_expression( \ 1862 cut_test_with_user_message( \ 1863 cut_assert_exist_path(path), \ 1864 __VA_ARGS__), \ 1865 cut_assert_file_exist(path, __VA_ARGS__)); \ 1866 } while (0) 1867 1868 /** 1869 * cut_assert_path_exist: 1870 * @path: the path to test. 1871 * @...: optional message. See cut_message() for details. 1872 * 1873 * Passes if @path exists. It may or may not be a regular file. 1874 * 1875 * e.g.: 1876 * |[ 1877 * cut_assert_path_exist("/tmp"); -> Pass on many environment 1878 * cut_assert_path_exist("/non-existent"); -> Fail 1879 * ]| 1880 * 1881 * Since: 1.0.2 1882 * Deprecated: 1.1.5: Use cut_assert_exist_path() instead. 1883 */ 1884 #define cut_assert_path_exist(path, ...) do \ 1885 { \ 1886 cut_trace_with_info_expression( \ 1887 cut_test_with_user_message( \ 1888 cut_assert_exist_path_helper(path, #path), \ 1889 __VA_ARGS__), \ 1890 cut_assert_path_exist(path, __VA_ARGS__)); \ 1891 } while (0) 1892 #endif 1893 1894 /** 1895 * cut_assert_exist_path: 1896 * @path: the path to test. 1897 * @...: optional message. See cut_message() for details. 1898 * 1899 * Passes if @path exists. It may or may not be a regular file. 1900 * 1901 * e.g.: 1902 * |[ 1903 * cut_assert_exist_path("/tmp"); -> Pass on many environment 1904 * cut_assert_exist_path("/non-existent"); -> Fail 1905 * ]| 1906 * 1907 * Since: 1.1.5 1908 */ 1909 #define cut_assert_exist_path(path, ...) do \ 1910 { \ 1911 cut_trace_with_info_expression( \ 1912 cut_test_with_user_message( \ 1913 cut_assert_exist_path_helper(path, #path), \ 1914 __VA_ARGS__), \ 1915 cut_assert_exist_path(path, __VA_ARGS__)); \ 1916 } while (0) 1917 1918 #ifndef CUTTER_DISABLE_DEPRECATED 1919 /** 1920 * cut_assert_path_not_exist: 1921 * @path: the path to test. 1922 * @...: optional message. See cut_message() for details. 1923 * 1924 * Passes if @path doesn't exist. 1925 * 1926 * e.g.: 1927 * |[ 1928 * cut_assert_path_not_exist("/non-existent"); -> Pass on many environment 1929 * cut_assert_path_not_exist("/tmp"); -> Fail 1930 * ]| 1931 * 1932 * Since: 1.0.2 1933 * Deprecated: 1.1.5: Use cut_assert_not_exist_path() instead. 1934 */ 1935 #define cut_assert_path_not_exist(path, ...) do \ 1936 { \ 1937 cut_trace_with_info_expression( \ 1938 cut_test_with_user_message( \ 1939 cut_assert_not_exist_path_helper(path, #path), \ 1940 __VA_ARGS__), \ 1941 cut_assert_path_not_exist(path, __VA_ARGS__)); \ 1942 } while (0) 1943 #endif 1944 1945 /** 1946 * cut_assert_not_exist_path: 1947 * @path: the path to test. 1948 * @...: optional message. See cut_message() for details. 1949 * 1950 * Passes if @path doesn't exist. 1951 * 1952 * e.g.: 1953 * |[ 1954 * cut_assert_not_exist_path("/non-existent"); -> Pass on many environment 1955 * cut_assert_not_exist_path("/tmp"); -> Fail 1956 * ]| 1957 * 1958 * Since: 1.1.5 1959 */ 1960 #define cut_assert_not_exist_path(path, ...) do \ 1961 { \ 1962 cut_trace_with_info_expression( \ 1963 cut_test_with_user_message( \ 1964 cut_assert_not_exist_path_helper(path, #path), \ 1965 __VA_ARGS__), \ 1966 cut_assert_not_exist_path(path, __VA_ARGS__)); \ 1967 } while (0) 1968 1969 /** 1970 * cut_assert_match: 1971 * @pattern: the regular expression pattern. 1972 * @actual: the string to be matched. 1973 * @...: optional message. See cut_message() for details. 1974 * 1975 * Passes if @pattern matches @string. 1976 * 1977 * e.g.: 1978 * |[ 1979 * cut_assert_match("^abc", "abc"); -> Pass 1980 * cut_assert_match("^abc", " abc"); -> Fail 1981 * ]| 1982 * 1983 * Since: 1.0 1984 */ 1985 #define cut_assert_match(pattern, actual, ...) do \ 1986 { \ 1987 cut_trace_with_info_expression( \ 1988 cut_test_with_user_message( \ 1989 cut_assert_match_helper(pattern, actual, #pattern, #actual),\ 1990 __VA_ARGS__), \ 1991 cut_assert_match(path, actual, __VA_ARGS__)); \ 1992 } while (0) 1993 1994 /** 1995 * cut_assert_match_with_free: 1996 * @pattern: the regular expression as string. 1997 * @actual: the string to be matched that is freed. 1998 * @...: optional message. See cut_message() for details. 1999 * 2000 * Passes if @pattern matches @string. See cut_assert_match() 2001 * for detail. 2002 * 2003 * Since: 1.0 2004 */ 2005 #define cut_assert_match_with_free(pattern, actual, ...) do \ 2006 { \ 2007 cut_trace_with_info_expression( \ 2008 cut_test_with_user_message( \ 2009 cut_assert_match_helper(pattern, cut_take_string(actual), \ 2010 #pattern, #actual), \ 2011 __VA_ARGS__), \ 2012 cut_assert_match_with_free(pattern, actual, __VA_ARGS__)); \ 2013 } while (0) 2014 2015 /** 2016 * cut_assert_equal_pointer: 2017 * @expected: an expected pointer. 2018 * @actual: an actual pointer. 2019 * @...: optional message. See cut_message() for details. 2020 * 2021 * Passes if @expected == @actual. 2022 * 2023 * Since: 1.0 2024 */ 2025 #define cut_assert_equal_pointer(expected, actual, ...) do \ 2026 { \ 2027 cut_trace_with_info_expression( \ 2028 cut_test_with_user_message( \ 2029 cut_assert_equal_pointer_helper(expected, actual, \ 2030 #expected, #actual), \ 2031 __VA_ARGS__), \ 2032 cut_assert_equal_pointer(expected, actual, __VA_ARGS__)); \ 2033 } while (0) 2034 2035 /** 2036 * cut_assert_equal_fixture_data_string: 2037 * @expected: an expected string. 2038 * @path: a first element of the path to the fixture data. 2039 * @...: remaining elements in path. %NULL terminated. 2040 * 2041 * Passes if @expected == cut_get_fixture_data_string(@path, ...). 2042 * 2043 * Since: 1.0.2 2044 */ 2045 #define cut_assert_equal_fixture_data_string(expected, path, ...) \ 2046 cut_trace_with_info_expression( \ 2047 cut_assert_equal_fixture_data_string_helper(expected, \ 2048 #expected, \ 2049 path, __VA_ARGS__), \ 2050 cut_assert_equal_fixture_data_string(expected, path, \ 2051 __VA_ARGS__)) 2052 2053 /** 2054 * cut_assert_equal_sockaddr: 2055 * @expected: an expected socket address. 2056 * @actual: an actual socket address. 2057 * @...: optional message. See cut_message() for details. 2058 * 2059 * Passes if @expected == @actual. 2060 * 2061 * This assertion can be disabled by defining CUT_DISABLE_SOCKET_SUPPORT. 2062 * 2063 * Since: 1.1.1 2064 */ 2065 #ifdef CUT_DISABLE_SOCKET_SUPPORT 2066 #define cut_assert_equal_sockaddr(expected, actual, ...) \ 2067 cut_notify("don't define CUT_DISABLE_SOCKET_SUPPORT " \ 2068 "to use cut_assert_equal_sockaddr().") 2069 #else 2070 #define cut_assert_equal_sockaddr(expected, actual, ...) do \ 2071 { \ 2072 cut_trace_with_info_expression( \ 2073 cut_test_with_user_message( \ 2074 cut_assert_equal_sockaddr_helper(expected, actual, \ 2075 #expected, #actual), \ 2076 __VA_ARGS__), \ 2077 cut_assert_equal_sockaddr(expected, actual, __VA_ARGS__)); \ 2078 } while (0) 2079 #endif 2080 2081 /** 2082 * cut_assert_equal_file_raw: 2083 * @expected: a path. 2084 * @actual: a path. 2085 * @...: optional message. See cut_message() for details. 2086 * 2087 * Passes if the content of @expected == the content of @actual. 2088 * 2089 * Since: 1.1.4 2090 */ 2091 #define cut_assert_equal_file_raw(expected, actual, ...) do \ 2092 { \ 2093 cut_trace_with_info_expression( \ 2094 cut_test_with_user_message( \ 2095 cut_assert_equal_file_raw_helper(expected, actual, \ 2096 #expected, #actual), \ 2097 __VA_ARGS__), \ 2098 cut_assert_equal_file_raw(expected, actual, __VA_ARGS__)); \ 2099 } while (0) 2100 2101 /** 2102 * cut_assert_not_equal_file_raw: 2103 * @expected: a path. 2104 * @actual: a path. 2105 * @...: optional message. See cut_message() for details. 2106 * 2107 * Passes if the content of @expected != the content of @actual. 2108 * 2109 * Since: 1.1.4 2110 */ 2111 #define cut_assert_not_equal_file_raw(expected, actual, ...) do \ 2112 { \ 2113 cut_trace_with_info_expression( \ 2114 cut_test_with_user_message( \ 2115 cut_assert_not_equal_file_raw_helper(expected, actual, \ 2116 #expected, #actual), \ 2117 __VA_ARGS__), \ 2118 cut_assert_not_equal_file_raw(expected, actual, __VA_ARGS__)); \ 2119 } while (0) 2120 2121 /** 2122 * cut_error: 2123 * @format: the message format. See the printf() documentation. 2124 * @...: the parameters to insert into the format string. 2125 * 2126 * Raises an error with message. 2127 */ 2128 #define cut_error(...) do \ 2129 { \ 2130 cut_trace_with_info_expression( \ 2131 cut_test_terminate(ERROR, NULL, cut_message(__VA_ARGS__)), \ 2132 cut_error(__VA_ARGS__)); \ 2133 } while (0) 2134 2135 /** 2136 * cut_error_errno: 2137 * @...: optional message. See cut_message() for details. 2138 * 2139 * e.g.: 2140 * |[ 2141 * void 2142 * setup (void) 2143 * { 2144 * mkdir("tmp", 0700); 2145 * cut_error_errno("Failed to make tmp directory"); 2146 * -> Error when tmp directory isn't made successfully. 2147 * } 2148 * ]| 2149 * 2150 * Since: 1.0.2 2151 */ 2152 #define cut_error_errno(...) do \ 2153 { \ 2154 cut_trace_with_info_expression( \ 2155 cut_test_with_user_message(cut_error_errno_helper(), \ 2156 __VA_ARGS__), \ 2157 cut_error_errno(__VA_ARGS__)); \ 2158 } while (0) 2159 2160 /** 2161 * cut_fail: 2162 * @format: the message format. See the printf() documentation. 2163 * @...: the parameters to insert into the format string. 2164 * 2165 * Raises a failure with message. 2166 */ 2167 #define cut_fail(...) do \ 2168 { \ 2169 cut_trace_with_info_expression( \ 2170 cut_test_terminate(FAILURE, NULL, cut_message(__VA_ARGS__)), \ 2171 cut_fail(__VA_ARGS__)); \ 2172 } while (0) 2173 2174 /** 2175 * cut_pend: 2176 * @format: the message format. See the printf() documentation. 2177 * @...: the parameters to insert into the format string. 2178 * 2179 * Marks the test is pending with message. The test is 2180 * stopped. 2181 */ 2182 #define cut_pend(...) do \ 2183 { \ 2184 cut_trace_with_info_expression( \ 2185 cut_test_terminate(PENDING, NULL, cut_message(__VA_ARGS__)), \ 2186 cut_pend(__VA_ARGS__)); \ 2187 } while (0) 2188 2189 #ifndef CUTTER_DISABLE_DEPRECATED 2190 /** 2191 * cut_pending: 2192 * @format: the message format. See the printf() documentation. 2193 * @...: the parameters to insert into the format string. 2194 * 2195 * Marks the test is pending with message. The test is 2196 * stopped. 2197 * 2198 * Deprecated: 0.4: Use cut_pend() instead. 2199 */ 2200 #define cut_pending(...) do \ 2201 { \ 2202 cut_trace_with_info_expression( \ 2203 cut_test_terminate(PENDING, NULL, cut_message(__VA_ARGS__)), \ 2204 cut_pend(__VA_ARGS__)); \ 2205 } while (0) 2206 #endif 2207 2208 /** 2209 * cut_notify: 2210 * @format: the message format. See the printf() documentation. 2211 * @...: the parameters to insert into the format string. 2212 * 2213 * Leaves a notification message. The test is continued. 2214 */ 2215 #define cut_notify(...) do \ 2216 { \ 2217 cut_trace_with_info_expression( \ 2218 cut_test_register_result(NOTIFICATION, NULL, \ 2219 cut_message(__VA_ARGS__)), \ 2220 cut_notify(__VA_ARGS__)); \ 2221 } while (0) 2222 2223 /** 2224 * cut_omit: 2225 * @format: the message format. See the printf() documentation. 2226 * @...: the parameters to insert into the format string. 2227 * 2228 * Omit the test. 2229 * 2230 * e.g.: 2231 * |[ 2232 * if (version < 2.0) 2233 * cut_omit("Require >= 2.0"); 2234 * ]| 2235 * 2236 * Since: 0.8 2237 */ 2238 #define cut_omit(...) do \ 2239 { \ 2240 cut_trace_with_info_expression( \ 2241 cut_test_terminate(OMISSION, NULL, cut_message(__VA_ARGS__)), \ 2242 cut_omit(__VA_ARGS__)); \ 2243 } while (0) 2244 2245 /** 2246 * cut_return: 2247 * 2248 * Finish the test. 2249 * 2250 * e.g.: 2251 * |[ 2252 * static void 2253 * sub_xxx (void) 2254 * { 2255 * some_assertions(); 2256 * if (no_need_more_test) 2257 * cut_return(); 2258 * some_assertions(); 2259 * } 2260 * 2261 * void 2262 * test_xxx (void) 2263 * { 2264 * some_assertions(); 2265 * cut_trace(sub_xxx()); 2266 * some_assertions(); 2267 * } 2268 * ]| 2269 * 2270 * Since: 1.0.6 2271 */ 2272 #define cut_return() \ 2273 cut_test_context_long_jump(cut_get_current_test_context()) 2274 2275 #ifdef __cplusplus 2276 } 2277 #endif 2278 2279 #endif /* __CUT_ASSERTIONS_H__ */ 2280 2281 /* 2282 vi:nowrap:ai:expandtab:sw=4 2283 */ 2284