testunity.c 78.8 KB
Newer Older
1 2 3 4 5
/* ==========================================
    Unity Project - A Test Framework for C
    Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
    [Released under MIT License. Please refer to license.txt for details]
========================================== */
G
greg-williams 已提交
6 7 8 9

#include <setjmp.h>
#include "unity.h"

10 11
// Dividing by these constants produces +/- infinity.
// The rationale is given in UnityAssertFloatIsInf's body.
12
#ifndef UNITY_EXCLUDE_FLOAT
13
static const _UF f_zero = 0.0f;
14 15
#endif

16 17 18 19
#ifndef UNITY_EXCLUDE_DOUBLE
static const _UD d_zero = 0.0;
#endif

20
#define EXPECT_ABORT_BEGIN \
21
    if (TEST_PROTECT())    \
22
    {
23

24 25 26 27
#define VERIFY_FAILS_END                                                       \
    }                                                                          \
    Unity.CurrentTestFailed = (Unity.CurrentTestFailed == 1) ? 0 : 1;          \
    if (Unity.CurrentTestFailed == 1) {                                        \
M
mvandervoord 已提交
28 29 30
      SetToOneMeanWeAlreadyCheckedThisGuy = 1;                                 \
      UnityPrint("[[[[ Previous Test Should Have Failed But Did Not ]]]]");    \
      UNITY_OUTPUT_CHAR('\n');                                                 \
31
    }
32

33 34 35 36 37
#define VERIFY_IGNORES_END                                                     \
    }                                                                          \
    Unity.CurrentTestFailed = (Unity.CurrentTestIgnored == 1) ? 0 : 1;         \
    Unity.CurrentTestIgnored = 0;                                              \
    if (Unity.CurrentTestFailed == 1) {                                        \
M
mvandervoord 已提交
38 39 40
      SetToOneMeanWeAlreadyCheckedThisGuy = 1;                                 \
      UnityPrint("[[[[ Previous Test Should Have Ignored But Did Not ]]]]");   \
      UNITY_OUTPUT_CHAR('\n');                                                 \
41
    }
M
mvandervoord 已提交
42

43
int SetToOneToFailInTearDown;
M
mvandervoord 已提交
44
int SetToOneMeanWeAlreadyCheckedThisGuy;
45

G
greg-williams 已提交
46 47
void setUp(void)
{
48
  SetToOneToFailInTearDown = 0;
M
mvandervoord 已提交
49
  SetToOneMeanWeAlreadyCheckedThisGuy = 0;
G
greg-williams 已提交
50 51 52 53
}

void tearDown(void)
{
54
  if (SetToOneToFailInTearDown == 1)
55
    TEST_FAIL_MESSAGE("<= Failed in tearDown");
M
mvandervoord 已提交
56 57 58 59 60
  if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0))
  {
    UnityPrint("[[[[ Previous Test Should Have Passed But Did Not ]]]]");
    UNITY_OUTPUT_CHAR('\n');
  }
G
greg-williams 已提交
61 62
}

63
void testUnitySizeInitializationReminder(void)
64 65 66 67
{
    /* This test ensures that sizeof(struct _Unity) doesn't change. If this
     * test breaks, go look at the initialization of the Unity global variable
     * in unity.c and make sure we're filling in the proper fields. */
68
    const char* message = "Unexpected size for _Unity struct. Please check that "
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
                     "the initialization of the Unity symbol in unity.c is "
                     "still correct.";

    /* Define a structure with all the same fields as `struct _Unity`. */
    struct {
        const char* TestFile;
        const char* CurrentTestName;
        UNITY_LINE_TYPE CurrentTestLineNumber;
        UNITY_COUNTER_TYPE NumberOfTests;
        UNITY_COUNTER_TYPE TestFailures;
        UNITY_COUNTER_TYPE TestIgnores;
        UNITY_COUNTER_TYPE CurrentTestFailed;
        UNITY_COUNTER_TYPE CurrentTestIgnored;
        jmp_buf AbortFrame;
    } _Expected_Unity;

    /* Compare our fake structure's size to the actual structure's size. They
     * should be the same.
     *
     * This accounts for alignment, padding, and packing issues that might come
     * up between different architectures. */
    TEST_ASSERT_EQUAL_MESSAGE(sizeof(_Expected_Unity), sizeof(Unity), message);
91 92
}

G
greg-williams 已提交
93 94 95
void testTrue(void)
{
    TEST_ASSERT(1);
96

G
greg-williams 已提交
97 98 99 100 101 102
    TEST_ASSERT_TRUE(1);
}

void testFalse(void)
{
    TEST_ASSERT_FALSE(0);
103

G
greg-williams 已提交
104 105 106 107 108 109 110 111 112 113
    TEST_ASSERT_UNLESS(0);
}

void testPreviousPass(void)
{
    TEST_ASSERT_EQUAL_INT(0U, Unity.TestFailures);
}

void testNotVanilla(void)
{
114 115
    EXPECT_ABORT_BEGIN
    TEST_ASSERT(0);
116
    VERIFY_FAILS_END
G
greg-williams 已提交
117 118 119 120
}

void testNotTrue(void)
{
121 122
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_TRUE(0);
123
    VERIFY_FAILS_END
G
greg-williams 已提交
124 125 126 127
}

void testNotFalse(void)
{
128 129
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_FALSE(1);
130
    VERIFY_FAILS_END
G
greg-williams 已提交
131 132 133 134
}

void testNotUnless(void)
{
135 136
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_UNLESS(1);
137
    VERIFY_FAILS_END
G
greg-williams 已提交
138 139
}

140 141 142 143
void testNotNotEqual(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_NOT_EQUAL(10, 10);
144
    VERIFY_FAILS_END
145 146
}

G
greg-williams 已提交
147 148
void testFail(void)
{
149
    EXPECT_ABORT_BEGIN
150
    TEST_FAIL_MESSAGE("Expected for testing");
151
    VERIFY_FAILS_END
G
greg-williams 已提交
152 153
}

154 155 156
void testIsNull(void)
{
    char* ptr1 = NULL;
157 158
    const char* ptr2 = "hello";

159 160 161 162 163 164
    TEST_ASSERT_NULL(ptr1);
    TEST_ASSERT_NOT_NULL(ptr2);
}

void testIsNullShouldFailIfNot(void)
{
165 166
    const char* ptr1 = "hello";

167 168
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_NULL(ptr1);
169
    VERIFY_FAILS_END
170 171 172 173 174
}

void testNotNullShouldFailIfNULL(void)
{
    char* ptr1 = NULL;
175

176 177
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_NOT_NULL(ptr1);
178
    VERIFY_FAILS_END
179 180
}

G
greg-williams 已提交
181 182
void testIgnore(void)
{
183 184
    EXPECT_ABORT_BEGIN
    TEST_IGNORE();
185
    TEST_FAIL_MESSAGE("This should not be reached");
186
    VERIFY_IGNORES_END
G
greg-williams 已提交
187 188 189 190
}

void testIgnoreMessage(void)
{
191 192
    EXPECT_ABORT_BEGIN
    TEST_IGNORE_MESSAGE("This is an expected TEST_IGNORE_MESSAGE string!");
193
    TEST_FAIL_MESSAGE("This should not be reached");
194
    VERIFY_IGNORES_END
G
greg-williams 已提交
195 196 197 198
}

void testNotEqualInts(void)
{
199 200
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_INT(3982, 3983);
201
    VERIFY_FAILS_END
G
greg-williams 已提交
202 203
}

204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
void testNotEqualInt8s(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_INT8(-127, -126);
    VERIFY_FAILS_END
}

void testNotEqualInt16s(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_INT16(-16383, -16382);
    VERIFY_FAILS_END
}

void testNotEqualInt32s(void)
{
    EXPECT_ABORT_BEGIN
221
    TEST_ASSERT_EQUAL_INT32(-2147483647, -2147483648); //use largest 32 bit negative to test printability
222 223 224
    VERIFY_FAILS_END
}

G
greg-williams 已提交
225 226
void testNotEqualBits(void)
{
227 228
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_BITS(0xFF00, 0x5555, 0x5A55);
229
    VERIFY_FAILS_END
G
greg-williams 已提交
230 231 232 233
}

void testNotEqualUInts(void)
{
234
    _UU16 v0, v1;
235

236 237
    v0 = 9000;
    v1 = 9001;
238

239
    EXPECT_ABORT_BEGIN
240
    TEST_ASSERT_EQUAL_UINT(v0, v1);
241
    VERIFY_FAILS_END
G
greg-williams 已提交
242 243
}

244 245 246
void testNotEqualUInt8s(void)
{
    _UU8 v0, v1;
247

248 249 250 251 252 253 254 255 256 257 258
    v0 = 254;
    v1 = 255;

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_UINT8(v0, v1);
    VERIFY_FAILS_END
}

void testNotEqualUInt16s(void)
{
    _UU16 v0, v1;
259

260 261 262 263 264 265 266 267 268 269 270
    v0 = 65535;
    v1 = 65534;

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_UINT16(v0, v1);
    VERIFY_FAILS_END
}

void testNotEqualUInt32s(void)
{
    _UU32 v0, v1;
271

272 273 274 275 276 277 278 279
    v0 = 4294967295;
    v1 = 4294967294;

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_UINT32(v0, v1);
    VERIFY_FAILS_END
}

G
greg-williams 已提交
280 281
void testNotEqualHex8s(void)
{
282
    _UU8 v0, v1;
283

284 285
    v0 = 0x23;
    v1 = 0x22;
286

287
    EXPECT_ABORT_BEGIN
288
    TEST_ASSERT_EQUAL_HEX8(v0, v1);
289
    VERIFY_FAILS_END
G
greg-williams 已提交
290 291
}

M
mvandervoord 已提交
292 293 294
void testNotEqualHex8sIfSigned(void)
{
    _US8 v0, v1;
295

M
mvandervoord 已提交
296 297 298 299 300
    v0 = -2;
    v1 = 2;

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_HEX8(v0, v1);
301
    VERIFY_FAILS_END
M
mvandervoord 已提交
302 303
}

G
greg-williams 已提交
304 305
void testNotEqualHex16s(void)
{
306
    _UU16 v0, v1;
307

308 309
    v0 = 0x1234;
    v1 = 0x1235;
310

311
    EXPECT_ABORT_BEGIN
312
    TEST_ASSERT_EQUAL_HEX16(v0, v1);
313
    VERIFY_FAILS_END
G
greg-williams 已提交
314 315
}

M
mvandervoord 已提交
316 317 318
void testNotEqualHex16sIfSigned(void)
{
    _US16 v0, v1;
319

M
mvandervoord 已提交
320 321 322 323 324
    v0 = -1024;
    v1 = -1028;

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_HEX16(v0, v1);
325
    VERIFY_FAILS_END
M
mvandervoord 已提交
326 327
}

G
greg-williams 已提交
328 329
void testNotEqualHex32s(void)
{
330
    _UU32 v0, v1;
331

332 333
    v0 = 900000;
    v1 = 900001;
334

335
    EXPECT_ABORT_BEGIN
336
    TEST_ASSERT_EQUAL_HEX32(v0, v1);
337
    VERIFY_FAILS_END
G
greg-williams 已提交
338 339
}

M
mvandervoord 已提交
340 341 342
void testNotEqualHex32sIfSigned(void)
{
    _US32 v0, v1;
343

M
mvandervoord 已提交
344 345 346 347 348
    v0 = -900000;
    v1 = 900001;

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_HEX32(v0, v1);
349
    VERIFY_FAILS_END
M
mvandervoord 已提交
350 351
}

G
greg-williams 已提交
352 353 354 355
void testEqualInts(void)
{
    int v0, v1;
    int *p0, *p1;
356

G
greg-williams 已提交
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
    v0 = 19467;
    v1 = 19467;
    p0 = &v0;
    p1 = &v1;

    TEST_ASSERT_EQUAL_INT(1837, 1837);
    TEST_ASSERT_EQUAL_INT(-27365, -27365);
    TEST_ASSERT_EQUAL_INT(v0, v1);
    TEST_ASSERT_EQUAL_INT(19467, v1);
    TEST_ASSERT_EQUAL_INT(v0, 19467);
    TEST_ASSERT_EQUAL_INT(*p0, v1);
    TEST_ASSERT_EQUAL_INT(*p0, *p1);
    TEST_ASSERT_EQUAL_INT(*p0, 19467);
}

372 373 374 375
void testEqualInt8s(void)
{
    _US8 v0, v1;
    _US8 *p0, *p1;
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
    v0 = 0x22;
    v1 = 0x22;
    p0 = &v0;
    p1 = &v1;

    TEST_ASSERT_EQUAL_INT8(0x22, 0x22);
    TEST_ASSERT_EQUAL_INT8(v0, v1);
    TEST_ASSERT_EQUAL_INT8(0x22, v1);
    TEST_ASSERT_EQUAL_INT8(v0, 0x22);
    TEST_ASSERT_EQUAL_INT8(*p0, v1);
    TEST_ASSERT_EQUAL_INT8(*p0, *p1);
    TEST_ASSERT_EQUAL_INT8(*p0, 0x22);
}

void testEqualInt8sWhenThereAreDifferencesOutside8Bits(void)
{
    TEST_ASSERT_EQUAL_INT8(0x321,0x421);
    TEST_ASSERT_EQUAL_INT8(0xFF21,0x0021);
}

void testEqualInt16s(void)
{
    _US16 v0, v1;
    _US16 *p0, *p1;
401

402 403
    v0 = 0x7876;
    v1 = 0x7876;
404 405 406
    p0 = &v0;
    p1 = &v1;

407
    TEST_ASSERT_EQUAL_INT16(0x7876, 0x7876);
408
    TEST_ASSERT_EQUAL_INT16(v0, v1);
409 410
    TEST_ASSERT_EQUAL_INT16(0x7876, v1);
    TEST_ASSERT_EQUAL_INT16(v0, 0x7876);
411 412
    TEST_ASSERT_EQUAL_INT16(*p0, v1);
    TEST_ASSERT_EQUAL_INT16(*p0, *p1);
413 414 415 416 417 418 419
    TEST_ASSERT_EQUAL_INT16(*p0, 0x7876);
}

void testEqualInt16sNegatives(void)
{
    _US16 v0, v1;
    _US16 *p0, *p1;
420

421 422 423 424 425 426 427 428 429 430 431 432
    v0 = -7876;
    v1 = -7876;
    p0 = &v0;
    p1 = &v1;

    TEST_ASSERT_EQUAL_INT16(-7876, -7876);
    TEST_ASSERT_EQUAL_INT16(v0, v1);
    TEST_ASSERT_EQUAL_INT16(-7876, v1);
    TEST_ASSERT_EQUAL_INT16(v0, -7876);
    TEST_ASSERT_EQUAL_INT16(*p0, v1);
    TEST_ASSERT_EQUAL_INT16(*p0, *p1);
    TEST_ASSERT_EQUAL_INT16(*p0, -7876);
433 434 435 436 437 438 439 440
}

void testEqualInt16sWhenThereAreDifferencesOutside16Bits(void)
{
    TEST_ASSERT_EQUAL_INT16(0x54321,0x64321);
    TEST_ASSERT_EQUAL_INT16(0xFFFF4321,0x00004321);
}

441 442 443 444
void testEqualInt32s(void)
{
    _US32 v0, v1;
    _US32 *p0, *p1;
445

446 447 448 449
    v0 = 0x78760000;
    v1 = 0x78760000;
    p0 = &v0;
    p1 = &v1;
450

451 452 453 454 455 456 457 458 459 460 461 462 463
    TEST_ASSERT_EQUAL_INT32(0x78760000, 0x78760000);
    TEST_ASSERT_EQUAL_INT32(v0, v1);
    TEST_ASSERT_EQUAL_INT32(0x78760000, v1);
    TEST_ASSERT_EQUAL_INT32(v0, 0x78760000);
    TEST_ASSERT_EQUAL_INT32(*p0, v1);
    TEST_ASSERT_EQUAL_INT32(*p0, *p1);
    TEST_ASSERT_EQUAL_INT32(*p0, 0x78760000);
}

void testEqualInt32sNegatives(void)
{
    _US32 v0, v1;
    _US32 *p0, *p1;
464

465 466 467 468
    v0 = -123456789;
    v1 = -123456789;
    p0 = &v0;
    p1 = &v1;
469

470 471 472 473 474 475 476 477 478 479
    TEST_ASSERT_EQUAL_INT32(-123456789, -123456789);
    TEST_ASSERT_EQUAL_INT32(v0, v1);
    TEST_ASSERT_EQUAL_INT32(-123456789, v1);
    TEST_ASSERT_EQUAL_INT32(v0, -123456789);
    TEST_ASSERT_EQUAL_INT32(*p0, v1);
    TEST_ASSERT_EQUAL_INT32(*p0, *p1);
    TEST_ASSERT_EQUAL_INT32(*p0, -123456789);
}


G
greg-williams 已提交
480 481 482 483
void testEqualUints(void)
{
    unsigned int v0, v1;
    unsigned int *p0, *p1;
484

G
greg-williams 已提交
485 486 487 488 489 490 491 492 493 494 495 496
    v0 = 19467;
    v1 = 19467;
    p0 = &v0;
    p1 = &v1;

    TEST_ASSERT_EQUAL_UINT(1837, 1837);
    TEST_ASSERT_EQUAL_UINT(v0, v1);
    TEST_ASSERT_EQUAL_UINT(19467, v1);
    TEST_ASSERT_EQUAL_UINT(v0, 19467);
    TEST_ASSERT_EQUAL_UINT(*p0, v1);
    TEST_ASSERT_EQUAL_UINT(*p0, *p1);
    TEST_ASSERT_EQUAL_UINT(*p0, 19467);
497
    TEST_ASSERT_EQUAL_UINT(60872u, 60872u);
G
greg-williams 已提交
498 499
}

500 501 502 503 504

void testEqualUint8s(void)
{
    _UU8 v0, v1;
    _UU8 *p0, *p1;
505

506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529
    v0 = 0x22;
    v1 = 0x22;
    p0 = &v0;
    p1 = &v1;

    TEST_ASSERT_EQUAL_UINT8(0x22, 0x22);
    TEST_ASSERT_EQUAL_UINT8(v0, v1);
    TEST_ASSERT_EQUAL_UINT8(0x22, v1);
    TEST_ASSERT_EQUAL_UINT8(v0, 0x22);
    TEST_ASSERT_EQUAL_UINT8(*p0, v1);
    TEST_ASSERT_EQUAL_UINT8(*p0, *p1);
    TEST_ASSERT_EQUAL_UINT8(*p0, 0x22);
}

void testEqualUint8sWhenThereAreDifferencesOutside8Bits(void)
{
    TEST_ASSERT_EQUAL_UINT8(0x321,0x421);
    TEST_ASSERT_EQUAL_UINT8(0xFF21,0x0021);
}

void testEqualUint16s(void)
{
    _UU16 v0, v1;
    _UU16 *p0, *p1;
530

531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
    v0 = 0x9876;
    v1 = 0x9876;
    p0 = &v0;
    p1 = &v1;

    TEST_ASSERT_EQUAL_UINT16(0x9876, 0x9876);
    TEST_ASSERT_EQUAL_UINT16(v0, v1);
    TEST_ASSERT_EQUAL_UINT16(0x9876, v1);
    TEST_ASSERT_EQUAL_UINT16(v0, 0x9876);
    TEST_ASSERT_EQUAL_UINT16(*p0, v1);
    TEST_ASSERT_EQUAL_UINT16(*p0, *p1);
    TEST_ASSERT_EQUAL_UINT16(*p0, 0x9876);
}

void testEqualUint16sWhenThereAreDifferencesOutside16Bits(void)
{
    TEST_ASSERT_EQUAL_UINT16(0x54321,0x64321);
    TEST_ASSERT_EQUAL_UINT16(0xFFFF4321,0x00004321);
}

551 552 553 554
void testEqualUint32s(void)
{
    _UU32 v0, v1;
    _UU32 *p0, *p1;
555

556 557 558 559
    v0 = 0x98760000;
    v1 = 0x98760000;
    p0 = &v0;
    p1 = &v1;
560

561 562 563 564 565 566 567 568 569
    TEST_ASSERT_EQUAL_UINT32(0x98760000, 0x98760000);
    TEST_ASSERT_EQUAL_UINT32(v0, v1);
    TEST_ASSERT_EQUAL_UINT32(0x98760000, v1);
    TEST_ASSERT_EQUAL_UINT32(v0, 0x98760000);
    TEST_ASSERT_EQUAL_UINT32(*p0, v1);
    TEST_ASSERT_EQUAL_UINT32(*p0, *p1);
    TEST_ASSERT_EQUAL_UINT32(*p0, 0x98760000);
}

570 571 572 573 574 575 576 577 578 579 580
void testNotEqual(void)
{
    TEST_ASSERT_NOT_EQUAL(0, 1);
    TEST_ASSERT_NOT_EQUAL(1, 0);
    TEST_ASSERT_NOT_EQUAL(100, 101);
    TEST_ASSERT_NOT_EQUAL(0, -1);
    TEST_ASSERT_NOT_EQUAL(65535, -65535);
    TEST_ASSERT_NOT_EQUAL(75, 900);
    TEST_ASSERT_NOT_EQUAL(-100, -101);
}

G
greg-williams 已提交
581 582
void testEqualHex8s(void)
{
583 584
    _UU8 v0, v1;
    _UU8 *p0, *p1;
585

G
greg-williams 已提交
586 587 588 589 590 591 592 593 594 595 596 597 598 599
    v0 = 0x22;
    v1 = 0x22;
    p0 = &v0;
    p1 = &v1;

    TEST_ASSERT_EQUAL_HEX8(0x22, 0x22);
    TEST_ASSERT_EQUAL_HEX8(v0, v1);
    TEST_ASSERT_EQUAL_HEX8(0x22, v1);
    TEST_ASSERT_EQUAL_HEX8(v0, 0x22);
    TEST_ASSERT_EQUAL_HEX8(*p0, v1);
    TEST_ASSERT_EQUAL_HEX8(*p0, *p1);
    TEST_ASSERT_EQUAL_HEX8(*p0, 0x22);
}

600 601 602 603 604 605
void testEqualHex8sWhenThereAreDifferencesOutside8Bits(void)
{
    TEST_ASSERT_EQUAL_HEX8(0x321,0x421);
    TEST_ASSERT_EQUAL_HEX8(0xFF21,0x0021);
}

606 607 608 609
void testEqualHex8sNegatives(void)
{
    _UU8 v0, v1;
    _UU8 *p0, *p1;
610

611 612 613 614 615 616 617 618 619 620 621 622 623 624
    v0 = 0xDD;
    v1 = 0xDD;
    p0 = &v0;
    p1 = &v1;

    TEST_ASSERT_EQUAL_HEX8(0xDD, 0xDD);
    TEST_ASSERT_EQUAL_HEX8(v0, v1);
    TEST_ASSERT_EQUAL_HEX8(0xDD, v1);
    TEST_ASSERT_EQUAL_HEX8(v0, 0xDD);
    TEST_ASSERT_EQUAL_HEX8(*p0, v1);
    TEST_ASSERT_EQUAL_HEX8(*p0, *p1);
    TEST_ASSERT_EQUAL_HEX8(*p0, 0xDD);
}

G
greg-williams 已提交
625 626
void testEqualHex16s(void)
{
627 628
    _UU16 v0, v1;
    _UU16 *p0, *p1;
629

G
greg-williams 已提交
630 631 632 633 634 635 636 637 638 639 640 641 642 643
    v0 = 0x9876;
    v1 = 0x9876;
    p0 = &v0;
    p1 = &v1;

    TEST_ASSERT_EQUAL_HEX16(0x9876, 0x9876);
    TEST_ASSERT_EQUAL_HEX16(v0, v1);
    TEST_ASSERT_EQUAL_HEX16(0x9876, v1);
    TEST_ASSERT_EQUAL_HEX16(v0, 0x9876);
    TEST_ASSERT_EQUAL_HEX16(*p0, v1);
    TEST_ASSERT_EQUAL_HEX16(*p0, *p1);
    TEST_ASSERT_EQUAL_HEX16(*p0, 0x9876);
}

644 645 646 647 648 649
void testEqualHex16sWhenThereAreDifferencesOutside16Bits(void)
{
    TEST_ASSERT_EQUAL_HEX16(0x54321,0x64321);
    TEST_ASSERT_EQUAL_HEX16(0xFFFF4321,0x00004321);
}

G
greg-williams 已提交
650 651
void testEqualHex32s(void)
{
652 653
    _UU32 v0, v1;
    _UU32 *p0, *p1;
654

655 656
    v0 = 0x98765432ul;
    v1 = 0x98765432ul;
G
greg-williams 已提交
657 658 659
    p0 = &v0;
    p1 = &v1;

660
    TEST_ASSERT_EQUAL_HEX32(0x98765432ul, 0x98765432ul);
G
greg-williams 已提交
661
    TEST_ASSERT_EQUAL_HEX32(v0, v1);
662 663
    TEST_ASSERT_EQUAL_HEX32(0x98765432ul, v1);
    TEST_ASSERT_EQUAL_HEX32(v0, 0x98765432ul);
G
greg-williams 已提交
664 665
    TEST_ASSERT_EQUAL_HEX32(*p0, v1);
    TEST_ASSERT_EQUAL_HEX32(*p0, *p1);
666
    TEST_ASSERT_EQUAL_HEX32(*p0, 0x98765432ul);
G
greg-williams 已提交
667 668 669 670
}

void testEqualBits(void)
{
671 672
    _UU32 v0 = 0xFF55AA00;
    _UU32 v1 = 0x55550000;
G
greg-williams 已提交
673 674 675 676 677 678 679 680 681 682 683 684

    TEST_ASSERT_BITS(v1, v0, 0x55550000);
    TEST_ASSERT_BITS(v1, v0, 0xFF55CC00);
    TEST_ASSERT_BITS(0xFFFFFFFF, v0, 0xFF55AA00);
    TEST_ASSERT_BITS(0xFFFFFFFF, v0, v0);
    TEST_ASSERT_BITS(0xF0F0F0F0, v0, 0xFC5DAE0F);
    TEST_ASSERT_BITS_HIGH(v1, v0);
    TEST_ASSERT_BITS_LOW(0x000055FF, v0);
    TEST_ASSERT_BIT_HIGH(30, v0);
    TEST_ASSERT_BIT_LOW(5, v0);
}

685 686 687
void testNotEqualBitHigh(void)
{
    _UU32 v0 = 0x7F55AA00;
688

689 690 691 692 693 694 695 696
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_BIT_HIGH(31, v0);
    VERIFY_FAILS_END
}

void testNotEqualBitLow(void)
{
    _UU32 v0 = 0xFF55AA00;
697

698 699 700 701 702 703 704 705 706
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_BIT_LOW(30, v0);
    VERIFY_FAILS_END
}

void testNotEqualBitsHigh(void)
{
    _UU32 v0 = 0xFF55AA00;
    _UU32 v1 = 0x55550000;
707

708 709 710
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_BITS_HIGH(v0, v1);
    VERIFY_FAILS_END
711

712 713 714 715 716 717
}

void testNotEqualBitsLow(void)
{
    _UU32 v0 = 0xFF55AA00;
    _UU32 v1 = 0x55550000;
718

719 720 721 722 723
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_BITS_LOW(v0, v1);
    VERIFY_FAILS_END

}
G
greg-williams 已提交
724 725 726 727
void testEqualShorts(void)
{
    short v0, v1;
    short *p0, *p1;
728

G
greg-williams 已提交
729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747
    v0 = 19467;
    v1 = 19467;
    p0 = &v0;
    p1 = &v1;

    TEST_ASSERT_EQUAL_INT(1837, 1837);
    TEST_ASSERT_EQUAL_INT(-2987, -2987);
    TEST_ASSERT_EQUAL_INT(v0, v1);
    TEST_ASSERT_EQUAL_INT(19467, v1);
    TEST_ASSERT_EQUAL_INT(v0, 19467);
    TEST_ASSERT_EQUAL_INT(*p0, v1);
    TEST_ASSERT_EQUAL_INT(*p0, *p1);
    TEST_ASSERT_EQUAL_INT(*p0, 19467);
}

void testEqualUShorts(void)
{
    unsigned short v0, v1;
    unsigned short *p0, *p1;
748

G
greg-williams 已提交
749 750 751 752 753
    v0 = 19467;
    v1 = 19467;
    p0 = &v0;
    p1 = &v1;

754 755 756 757 758 759 760 761
    TEST_ASSERT_EQUAL_UINT(1837, 1837);
    TEST_ASSERT_EQUAL_UINT(2987, 2987);
    TEST_ASSERT_EQUAL_UINT(v0, v1);
    TEST_ASSERT_EQUAL_UINT(19467, v1);
    TEST_ASSERT_EQUAL_UINT(v0, 19467);
    TEST_ASSERT_EQUAL_UINT(*p0, v1);
    TEST_ASSERT_EQUAL_UINT(*p0, *p1);
    TEST_ASSERT_EQUAL_UINT(*p0, 19467);
G
greg-williams 已提交
762 763 764 765 766 767
}

void testEqualChars(void)
{
    signed char v0, v1;
    signed char *p0, *p1;
768

G
greg-williams 已提交
769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787
    v0 = 109;
    v1 = 109;
    p0 = &v0;
    p1 = &v1;

    TEST_ASSERT_EQUAL_INT(42, 42);
    TEST_ASSERT_EQUAL_INT(-116, -116);
    TEST_ASSERT_EQUAL_INT(v0, v1);
    TEST_ASSERT_EQUAL_INT(109, v1);
    TEST_ASSERT_EQUAL_INT(v0, 109);
    TEST_ASSERT_EQUAL_INT(*p0, v1);
    TEST_ASSERT_EQUAL_INT(*p0, *p1);
    TEST_ASSERT_EQUAL_INT(*p0, 109);
}

void testEqualUChars(void)
{
    unsigned char v0, v1;
    unsigned char *p0, *p1;
788

G
greg-williams 已提交
789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806
    v0 = 251;
    v1 = 251;
    p0 = &v0;
    p1 = &v1;

    TEST_ASSERT_EQUAL_INT(42, 42);
    TEST_ASSERT_EQUAL_INT(v0, v1);
    TEST_ASSERT_EQUAL_INT(251, v1);
    TEST_ASSERT_EQUAL_INT(v0, 251);
    TEST_ASSERT_EQUAL_INT(*p0, v1);
    TEST_ASSERT_EQUAL_INT(*p0, *p1);
    TEST_ASSERT_EQUAL_INT(*p0, 251);
}

void testEqualPointers(void)
{
    int v0, v1;
    int *p0, *p1, *p2;
807

G
greg-williams 已提交
808
    v0 = 19467;
809
    v1 = 18271;
G
greg-williams 已提交
810 811 812 813
    p0 = &v0;
    p1 = &v1;
    p2 = &v1;

M
mvandervoord 已提交
814 815 816 817
    TEST_ASSERT_EQUAL_PTR(p0, &v0);
    TEST_ASSERT_EQUAL_PTR(&v1, p1);
    TEST_ASSERT_EQUAL_PTR(p2, p1);
    TEST_ASSERT_EQUAL_PTR(&v0, &v0);
G
greg-williams 已提交
818 819
}

M
mvandervoord 已提交
820
void testNotEqualPointers(void)
821 822
{
    EXPECT_ABORT_BEGIN
M
mvandervoord 已提交
823
    TEST_ASSERT_EQUAL_PTR(0x12345678, 0x12345677);
824
    VERIFY_FAILS_END
M
mvandervoord 已提交
825 826
}

G
greg-williams 已提交
827 828 829 830 831 832
void testIntsWithinDelta(void)
{
    TEST_ASSERT_INT_WITHIN(1, 5000, 5001);
    TEST_ASSERT_INT_WITHIN(5, 5000, 4996);
    TEST_ASSERT_INT_WITHIN(5, 5000, 5005);
    TEST_ASSERT_INT_WITHIN(500, 50, -440);
833

M
mvandervoord 已提交
834
    TEST_ASSERT_INT_WITHIN(2, -1, -1);
M
mvandervoord 已提交
835 836
    TEST_ASSERT_INT_WITHIN(5, 1, -1);
    TEST_ASSERT_INT_WITHIN(5, -1, 1);
G
greg-williams 已提交
837 838
}

839 840 841 842 843 844
void testIntsWithinDeltaAndCustomMessage(void)
{
    TEST_ASSERT_INT_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message.");
    TEST_ASSERT_INT_WITHIN_MESSAGE(5, 5000, 4996, "Custom Message.");
    TEST_ASSERT_INT_WITHIN_MESSAGE(5, 5000, 5005, "Custom Message.");
    TEST_ASSERT_INT_WITHIN_MESSAGE(500, 50, -440, "Custom Message.");
845

846 847 848 849 850
    TEST_ASSERT_INT_WITHIN_MESSAGE(2, -1, -1, "Custom Message.");
    TEST_ASSERT_INT_WITHIN_MESSAGE(5, 1, -1, "Custom Message.");
    TEST_ASSERT_INT_WITHIN_MESSAGE(5, -1, 1, "Custom Message.");
}

G
greg-williams 已提交
851 852
void testIntsNotWithinDelta(void)
{
853 854
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_INT_WITHIN(5, 5000, 5006);
855
    VERIFY_FAILS_END
G
greg-williams 已提交
856 857
}

858 859 860 861 862 863 864
void testIntsNotWithinDeltaAndCustomMessage(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_INT_WITHIN_MESSAGE(5, 5000, 5006, "Custom Message.");
    VERIFY_FAILS_END
}

M
mvandervoord 已提交
865 866 867 868 869 870 871
void testUIntsWithinDelta(void)
{
    TEST_ASSERT_UINT_WITHIN(1, 5000, 5001);
    TEST_ASSERT_UINT_WITHIN(5, 5000, 4996);
    TEST_ASSERT_UINT_WITHIN(5, 5000, 5005);
}

872 873 874 875 876 877 878
void testUIntsWithinDeltaAndCustomMessage(void)
{
    TEST_ASSERT_UINT_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message.");
    TEST_ASSERT_UINT_WITHIN_MESSAGE(5, 5000, 4996, "Custom Message.");
    TEST_ASSERT_UINT_WITHIN_MESSAGE(5, 5000, 5005, "Custom Message.");
}

M
mvandervoord 已提交
879 880 881
void testUIntsNotWithinDelta(void)
{
    EXPECT_ABORT_BEGIN
882
    TEST_ASSERT_UINT_WITHIN(1, 2147483647u, 2147483649u);
883
    VERIFY_FAILS_END
M
mvandervoord 已提交
884 885
}

886 887 888 889 890 891 892
void testUIntsNotWithinDeltaAndCustomMessage(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_UINT_WITHIN_MESSAGE(1, 2147483647u, 2147483649u, "Custom Message.");
    VERIFY_FAILS_END
}

M
mvandervoord 已提交
893 894 895 896
void testUIntsNotWithinDeltaEvenThoughASignedIntWouldPassSmallFirst(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_UINT_WITHIN(5, 1, -1);
897
    VERIFY_FAILS_END
M
mvandervoord 已提交
898 899
}

900 901 902 903 904 905 906
void testUIntsNotWithinDeltaEvenThoughASignedIntWouldPassSmallFirstAndCustomMessage(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_UINT_WITHIN_MESSAGE(5, 1, -1, "Custom Message.");
    VERIFY_FAILS_END
}

M
mvandervoord 已提交
907 908 909 910
void testUIntsNotWithinDeltaEvenThoughASignedIntWouldPassBigFirst(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_UINT_WITHIN(5, -1, 1);
911
    VERIFY_FAILS_END
M
mvandervoord 已提交
912 913
}

914 915 916 917 918 919 920
void testUIntsNotWithinDeltaEvenThoughASignedIntWouldPassBigFirstAndCustomMessage(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_UINT_WITHIN_MESSAGE(5, -1, 1, "Custom Message.");
    VERIFY_FAILS_END
}

M
mvandervoord 已提交
921 922 923 924 925 926 927
void testHEX32sWithinDelta(void)
{
    TEST_ASSERT_HEX32_WITHIN(1, 5000, 5001);
    TEST_ASSERT_HEX32_WITHIN(5, 5000, 4996);
    TEST_ASSERT_HEX32_WITHIN(5, 5000, 5005);
}

928 929 930 931 932 933 934
void testHEX32sWithinDeltaAndCustomMessage(void)
{
    TEST_ASSERT_HEX32_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message.");
    TEST_ASSERT_HEX32_WITHIN_MESSAGE(5, 5000, 4996, "Custom Message.");
    TEST_ASSERT_HEX32_WITHIN_MESSAGE(5, 5000, 5005, "Custom Message.");
}

M
mvandervoord 已提交
935 936 937
void testHEX32sNotWithinDelta(void)
{
    EXPECT_ABORT_BEGIN
938
    TEST_ASSERT_HEX32_WITHIN(1, 2147483647u, 2147483649u);
939
    VERIFY_FAILS_END
M
mvandervoord 已提交
940 941
}

942 943 944 945 946 947 948
void testHEX32sNotWithinDeltaAndCustomMessage(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_HEX32_WITHIN_MESSAGE(1, 2147483647u, 2147483649u, "Custom Message.");
    VERIFY_FAILS_END
}

M
mvandervoord 已提交
949 950 951 952
void testHEX32sNotWithinDeltaEvenThoughASignedIntWouldPass(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_HEX32_WITHIN(5, 1, -1);
953
    VERIFY_FAILS_END
M
mvandervoord 已提交
954 955
}

956 957 958 959 960 961 962
void testHEX32sNotWithinDeltaEvenThoughASignedIntWouldPassAndCustomMessage(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_HEX32_WITHIN_MESSAGE(5, 1, -1, "Custom Message.");
    VERIFY_FAILS_END
}

M
mvandervoord 已提交
963 964 965 966 967 968 969
void testHEX16sWithinDelta(void)
{
    TEST_ASSERT_HEX16_WITHIN(1, 5000, 5001);
    TEST_ASSERT_HEX16_WITHIN(5, 5000, 4996);
    TEST_ASSERT_HEX16_WITHIN(5, 5000, 5005);
}

970 971 972 973 974 975 976
void testHEX16sWithinDeltaAndCustomMessage(void)
{
    TEST_ASSERT_HEX16_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message.");
    TEST_ASSERT_HEX16_WITHIN_MESSAGE(5, 5000, 4996, "Custom Message.");
    TEST_ASSERT_HEX16_WITHIN_MESSAGE(5, 5000, 5005, "Custom Message.");
}

977 978
void testHEX16sWithinDeltaWhenThereAreDifferenceOutsideOf16Bits(void)
{
979
    TEST_ASSERT_HEX16_WITHIN(5, 0x54321, 0x44321);
980 981
}

982 983
void testHEX16sWithinDeltaWhenThereAreDifferenceOutsideOf16BitsAndCustomMessage(void)
{
984
    TEST_ASSERT_HEX16_WITHIN_MESSAGE(5, 0x54321, 0x44321, "Custom Message.");
985 986
}

M
mvandervoord 已提交
987 988 989 990
void testHEX16sNotWithinDelta(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_HEX16_WITHIN(2, 65535, 0);
991
    VERIFY_FAILS_END
M
mvandervoord 已提交
992 993
}

994 995 996 997 998 999 1000
void testHEX16sNotWithinDeltaAndCustomMessage(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_HEX16_WITHIN_MESSAGE(2, 65535, 0, "Custom Message.");
    VERIFY_FAILS_END
}

M
mvandervoord 已提交
1001 1002 1003 1004 1005 1006 1007
void testHEX8sWithinDelta(void)
{
    TEST_ASSERT_HEX8_WITHIN(1, 254, 255);
    TEST_ASSERT_HEX8_WITHIN(5, 251, 255);
    TEST_ASSERT_HEX8_WITHIN(5, 1, 4);
}

1008 1009 1010 1011 1012 1013 1014
void testHEX8sWithinDeltaAndCustomMessage(void)
{
    TEST_ASSERT_HEX8_WITHIN_MESSAGE(1, 254, 255, "Custom Message.");
    TEST_ASSERT_HEX8_WITHIN_MESSAGE(5, 251, 255, "Custom Message.");
    TEST_ASSERT_HEX8_WITHIN_MESSAGE(5, 1, 4, "Custom Message.");
}

1015 1016
void testHEX8sWithinDeltaWhenThereAreDifferenceOutsideOf8Bits(void)
{
1017
    TEST_ASSERT_HEX8_WITHIN(5, 0x123, 0xF23);
1018 1019
}

1020 1021
void testHEX8sWithinDeltaWhenThereAreDifferenceOutsideOf8BitsAndCustomMessage(void)
{
1022
    TEST_ASSERT_HEX8_WITHIN_MESSAGE(5, 0x123, 0xF23, "Custom Message.");
1023 1024
}

M
mvandervoord 已提交
1025 1026 1027 1028
void testHEX8sNotWithinDelta(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_HEX8_WITHIN(2, 255, 0);
1029
    VERIFY_FAILS_END
M
mvandervoord 已提交
1030 1031
}

1032 1033 1034 1035 1036 1037 1038
void testHEX8sNotWithinDeltaAndCustomMessage(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_HEX8_WITHIN_MESSAGE(2, 255, 0, "Custom Message.");
    VERIFY_FAILS_END
}

1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256
//-----------------

void testUINT32sWithinDelta(void)
{
    TEST_ASSERT_UINT32_WITHIN(1, 5000, 5001);
    TEST_ASSERT_UINT32_WITHIN(5, 5000, 4996);
    TEST_ASSERT_UINT32_WITHIN(5, 5000, 5005);
}

void testUINT32sWithinDeltaAndCustomMessage(void)
{
    TEST_ASSERT_UINT32_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message.");
    TEST_ASSERT_UINT32_WITHIN_MESSAGE(5, 5000, 4996, "Custom Message.");
    TEST_ASSERT_UINT32_WITHIN_MESSAGE(5, 5000, 5005, "Custom Message.");
}

void testUINT32sNotWithinDelta(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_UINT32_WITHIN(1, 2147483647u, 2147483649u);
    VERIFY_FAILS_END
}

void testUINT32sNotWithinDeltaAndCustomMessage(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_UINT32_WITHIN_MESSAGE(1, 2147483647u, 2147483649u, "Custom Message.");
    VERIFY_FAILS_END
}

void testUINT32sNotWithinDeltaEvenThoughASignedIntWouldPass(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_UINT32_WITHIN(5, 1, -1);
    VERIFY_FAILS_END
}

void testUINT32sNotWithinDeltaEvenThoughASignedIntWouldPassAndCustomMessage(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_UINT32_WITHIN_MESSAGE(5, 1, -1, "Custom Message.");
    VERIFY_FAILS_END
}

void testUINT16sWithinDelta(void)
{
    TEST_ASSERT_UINT16_WITHIN(1, 5000, 5001);
    TEST_ASSERT_UINT16_WITHIN(5, 5000, 4996);
    TEST_ASSERT_UINT16_WITHIN(5, 5000, 5005);
}

void testUINT16sWithinDeltaAndCustomMessage(void)
{
    TEST_ASSERT_UINT16_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message.");
    TEST_ASSERT_UINT16_WITHIN_MESSAGE(5, 5000, 4996, "Custom Message.");
    TEST_ASSERT_UINT16_WITHIN_MESSAGE(5, 5000, 5005, "Custom Message.");
}

void testUINT16sWithinDeltaWhenThereAreDifferenceOutsideOf16Bits(void)
{
    TEST_ASSERT_UINT16_WITHIN(5, 0x54321, 0x44321);
}

void testUINT16sWithinDeltaWhenThereAreDifferenceOutsideOf16BitsAndCustomMessage(void)
{
    TEST_ASSERT_UINT16_WITHIN_MESSAGE(5, 0x54321, 0x44321, "Custom Message.");
}

void testUINT16sNotWithinDelta(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_UINT16_WITHIN(2, 65535, 0);
    VERIFY_FAILS_END
}

void testUINT16sNotWithinDeltaAndCustomMessage(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_UINT16_WITHIN_MESSAGE(2, 65535, 0, "Custom Message.");
    VERIFY_FAILS_END
}

void testUINT8sWithinDelta(void)
{
    TEST_ASSERT_UINT8_WITHIN(1, 254, 255);
    TEST_ASSERT_UINT8_WITHIN(5, 251, 255);
    TEST_ASSERT_UINT8_WITHIN(5, 1, 4);
}

void testUINT8sWithinDeltaAndCustomMessage(void)
{
    TEST_ASSERT_UINT8_WITHIN_MESSAGE(1, 254, 255, "Custom Message.");
    TEST_ASSERT_UINT8_WITHIN_MESSAGE(5, 251, 255, "Custom Message.");
    TEST_ASSERT_UINT8_WITHIN_MESSAGE(5, 1, 4, "Custom Message.");
}

void testUINT8sWithinDeltaWhenThereAreDifferenceOutsideOf8Bits(void)
{
    TEST_ASSERT_UINT8_WITHIN(5, 0x123, 0xF23);
}

void testUINT8sWithinDeltaWhenThereAreDifferenceOutsideOf8BitsAndCustomMessage(void)
{
    TEST_ASSERT_UINT8_WITHIN_MESSAGE(5, 0x123, 0xF23, "Custom Message.");
}

void testUINT8sNotWithinDelta(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_UINT8_WITHIN(2, 255, 0);
    VERIFY_FAILS_END
}

void testUINT8sNotWithinDeltaAndCustomMessage(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_UINT8_WITHIN_MESSAGE(2, 255, 0, "Custom Message.");
    VERIFY_FAILS_END
}

void testINT32sWithinDelta(void)
{
    TEST_ASSERT_INT32_WITHIN(1, 5000, 5001);
    TEST_ASSERT_INT32_WITHIN(5, 1, -2);
    TEST_ASSERT_INT32_WITHIN(5, -2, 1);
}

void testINT32sWithinDeltaAndCustomMessage(void)
{
    TEST_ASSERT_INT32_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message.");
}

void testINT32sNotWithinDelta(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_INT32_WITHIN(1, -3, 1);
    VERIFY_FAILS_END
}

void testINT32sNotWithinDeltaAndCustomMessage(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_INT32_WITHIN_MESSAGE(1, -2, 1, "Custom Message.");
    VERIFY_FAILS_END
}

void testINT16sWithinDelta(void)
{
    TEST_ASSERT_INT16_WITHIN(1, 5000, 5001);
    TEST_ASSERT_INT16_WITHIN(5, 2, -2);
    TEST_ASSERT_INT16_WITHIN(5, -2, 2);
}

void testINT16sWithinDeltaAndCustomMessage(void)
{
    TEST_ASSERT_INT16_WITHIN_MESSAGE(1, 5000, 5001, "Custom Message.");
}

void testINT16sWithinDeltaWhenThereAreDifferenceOutsideOf16Bits(void)
{
    TEST_ASSERT_INT16_WITHIN(5, 0x54321, 0x44321);
}

void testINT16sWithinDeltaWhenThereAreDifferenceOutsideOf16BitsAndCustomMessage(void)
{
    TEST_ASSERT_INT16_WITHIN_MESSAGE(5, 0x54321, 0x44321, "Custom Message.");
}

void testINT16sNotWithinDelta(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_INT16_WITHIN(2, 4, -2);
    VERIFY_FAILS_END
}

void testINT16sNotWithinDeltaAndCustomMessage(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_INT16_WITHIN_MESSAGE(2, 3, 0, "Custom Message.");
    VERIFY_FAILS_END
}

void testINT8sWithinDelta(void)
{
    TEST_ASSERT_INT8_WITHIN(1, 127, 126);
    TEST_ASSERT_INT8_WITHIN(5, -2, 2);
    TEST_ASSERT_INT8_WITHIN(5, 2, -2);
}

void testINT8sWithinDeltaAndCustomMessage(void)
{
    TEST_ASSERT_INT8_WITHIN_MESSAGE(5, 1, 4, "Custom Message.");
}

void testINT8sWithinDeltaWhenThereAreDifferenceOutsideOf8Bits(void)
{
    TEST_ASSERT_INT8_WITHIN(5, 0x123, 0xF23);
}

void testINT8sWithinDeltaWhenThereAreDifferenceOutsideOf8BitsAndCustomMessage(void)
{
    TEST_ASSERT_INT8_WITHIN_MESSAGE(5, 0x123, 0xF23, "Custom Message.");
}

void testINT8sNotWithinDelta(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_INT8_WITHIN(2, -3, 0);
    VERIFY_FAILS_END
}

void testINT8sNotWithinDeltaAndCustomMessage(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_INT8_WITHIN_MESSAGE(2, -4, 0, "Custom Message.");
    VERIFY_FAILS_END
}

G
greg-williams 已提交
1257 1258 1259 1260 1261 1262 1263 1264 1265
void testEqualStrings(void)
{
    const char *testString = "foo";

    TEST_ASSERT_EQUAL_STRING(testString, testString);
    TEST_ASSERT_EQUAL_STRING("foo", "foo");
    TEST_ASSERT_EQUAL_STRING("foo", testString);
    TEST_ASSERT_EQUAL_STRING(testString, "foo");
    TEST_ASSERT_EQUAL_STRING("", "");
M
mvandervoord 已提交
1266 1267
}

1268 1269 1270 1271 1272 1273 1274 1275 1276 1277
void testEqualStringsLen(void)
{
    const char *testString = "foobar";
    TEST_ASSERT_EQUAL_STRING_LEN(testString, testString, strlen(testString));
    TEST_ASSERT_EQUAL_STRING_LEN("foobar", "foobaz", 5);
    TEST_ASSERT_EQUAL_STRING_LEN("foo", testString, 3);
    TEST_ASSERT_EQUAL_STRING_LEN(testString, foo, 3);
    TEST_ASSERT_EQUAL_STRING_LEN("", "", 3);
}

M
mvandervoord 已提交
1278 1279 1280 1281 1282 1283 1284 1285 1286
void testEqualStringsWithCarriageReturnsAndLineFeeds(void)
{
    const char *testString = "foo\r\nbar";

    TEST_ASSERT_EQUAL_STRING(testString, testString);
    TEST_ASSERT_EQUAL_STRING("foo\r\nbar", "foo\r\nbar");
    TEST_ASSERT_EQUAL_STRING("foo\r\nbar", testString);
    TEST_ASSERT_EQUAL_STRING(testString, "foo\r\nbar");
    TEST_ASSERT_EQUAL_STRING("", "");
G
greg-williams 已提交
1287 1288 1289 1290
}

void testNotEqualString1(void)
{
1291 1292
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_STRING("foo", "bar");
1293
    VERIFY_FAILS_END
G
greg-williams 已提交
1294 1295
}

1296 1297 1298 1299 1300 1301 1302
void testNotEqualStringLen1(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_STRING_LEN("foobar", "foobaz", 6);
    VERIFY_FAILS_END
}

G
greg-williams 已提交
1303 1304
void testNotEqualString2(void)
{
1305 1306
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_STRING("foo", "");
1307
    VERIFY_FAILS_END
G
greg-williams 已提交
1308 1309
}

1310 1311 1312 1313 1314 1315 1316
void testNotEqualStringLen2(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_STRING_LEN("foo", "", 3);
    VERIFY_FAILS_END
}

G
greg-williams 已提交
1317 1318
void testNotEqualString3(void)
{
1319 1320
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_STRING("", "bar");
1321
    VERIFY_FAILS_END
G
greg-williams 已提交
1322 1323
}

1324 1325 1326 1327 1328 1329 1330
void testNotEqualStringLen3(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_STRING_LEN("", "bar", 3);
    VERIFY_FAILS_END
}

M
mvandervoord 已提交
1331 1332 1333 1334 1335 1336 1337
void testNotEqualString4(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_STRING("bar\r", "bar\n");
    VERIFY_FAILS_END
}

1338 1339 1340 1341 1342 1343 1344
void testNotEqualStringLen4(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_STRING_LEN("bar\r", "bar\n", 4);
    VERIFY_FAILS_END
}

M
mvandervoord 已提交
1345 1346 1347 1348 1349 1350 1351 1352 1353
void testNotEqualString5(void)
{
    const char str1[] = { 0x41, 0x42, 0x03, 0x00 };
    const char str2[] = { 0x41, 0x42, 0x04, 0x00 };
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_STRING(str1, str2);
    VERIFY_FAILS_END
}

G
greg-williams 已提交
1354 1355
void testNotEqualString_ExpectedStringIsNull(void)
{
1356 1357
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_STRING(NULL, "bar");
1358
    VERIFY_FAILS_END
G
greg-williams 已提交
1359 1360 1361 1362
}

void testNotEqualString_ActualStringIsNull(void)
{
1363 1364
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_STRING("foo", NULL);
1365
    VERIFY_FAILS_END
1366 1367
}

M
mvandervoord 已提交
1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385
void testEqualStringArrays(void)
{
    const char *testStrings[] = { "foo", "boo", "woo", "moo" };
    const char *expStrings[] = { "foo", "boo", "woo", "zoo" };

    TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, expStrings, 3);
    TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 3);
    TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 2);
    TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 1);
}

void testNotEqualStringArray1(void)
{
    const char *testStrings[] = { "foo", "boo", "woo", "moo" };
    const char *expStrings[] = { "foo", "boo", "woo", "zoo" };

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
1386
    VERIFY_FAILS_END
M
mvandervoord 已提交
1387 1388 1389 1390 1391 1392 1393 1394 1395
}

void testNotEqualStringArray2(void)
{
    const char *testStrings[] = { "zoo", "boo", "woo", "moo" };
    const char *expStrings[] = { "foo", "boo", "woo", "moo" };

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
1396
    VERIFY_FAILS_END
M
mvandervoord 已提交
1397 1398 1399 1400 1401 1402 1403 1404 1405
}

void testNotEqualStringArray3(void)
{
    const char *testStrings[] = { "foo", "boo", "woo", NULL };
    const char *expStrings[] = { "foo", "boo", "woo", "zoo" };

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
1406
    VERIFY_FAILS_END
M
mvandervoord 已提交
1407 1408 1409 1410 1411 1412 1413 1414 1415
}

void testNotEqualStringArray4(void)
{
    const char *testStrings[] = { "foo", "boo", "woo", "moo" };
    const char *expStrings[] = { "foo", NULL, "woo", "moo" };

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
1416
    VERIFY_FAILS_END
M
mvandervoord 已提交
1417 1418 1419 1420 1421 1422 1423 1424 1425
}

void testNotEqualStringArray5(void)
{
    const char **testStrings = NULL;
    const char *expStrings[] = { "foo", "boo", "woo", "zoo" };

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
1426 1427
    VERIFY_FAILS_END
}
M
mvandervoord 已提交
1428

1429 1430 1431 1432
void testNotEqualStringArray6(void)
{
    const char *testStrings[] = { "foo", "boo", "woo", "zoo" };
    const char **expStrings = NULL;
M
mvandervoord 已提交
1433

1434 1435 1436
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
    VERIFY_FAILS_END
M
mvandervoord 已提交
1437 1438 1439 1440 1441 1442 1443 1444 1445 1446
}

void testEqualStringArrayIfBothNulls(void)
{
    const char **testStrings = NULL;
    const char **expStrings = NULL;

    TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
}

1447 1448 1449
void testEqualMemory(void)
{
    const char *testString = "whatever";
1450

1451 1452 1453 1454
    TEST_ASSERT_EQUAL_MEMORY(testString, testString, 8);
    TEST_ASSERT_EQUAL_MEMORY("whatever", "whatever", 8);
    TEST_ASSERT_EQUAL_MEMORY("whatever", testString, 8);
    TEST_ASSERT_EQUAL_MEMORY(testString, "whatever", 8);
1455 1456
    TEST_ASSERT_EQUAL_MEMORY(testString, "whatever", 2);
    TEST_ASSERT_EQUAL_MEMORY(NULL, NULL, 1);
1457 1458 1459 1460 1461 1462
}

void testNotEqualMemory1(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_MEMORY("foo", "bar", 3);
1463
    VERIFY_FAILS_END
1464 1465 1466 1467 1468 1469
}

void testNotEqualMemory2(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_MEMORY("fool", "food", 4);
1470
    VERIFY_FAILS_END
1471 1472 1473 1474 1475 1476
}

void testNotEqualMemory3(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_MEMORY(NULL, "food", 4);
1477
    VERIFY_FAILS_END
1478 1479 1480 1481 1482 1483
}

void testNotEqualMemory4(void)
{
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_MEMORY("fool", NULL, 4);
1484
    VERIFY_FAILS_END
M
mvandervoord 已提交
1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500
}

void testEqualIntArrays(void)
{
    int p0[] = {1, 8, 987, -2};
    int p1[] = {1, 8, 987, -2};
    int p2[] = {1, 8, 987, 2};
    int p3[] = {1, 500, 600, 700};

    TEST_ASSERT_EQUAL_INT_ARRAY(p0, p0, 1);
    TEST_ASSERT_EQUAL_INT_ARRAY(p0, p0, 4);
    TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4);
    TEST_ASSERT_EQUAL_INT_ARRAY(p0, p2, 3);
    TEST_ASSERT_EQUAL_INT_ARRAY(p0, p3, 1);
}

1501
void testNotEqualIntArraysNullExpected(void)
M
mvandervoord 已提交
1502
{
1503
    int* p0 = NULL;
M
mvandervoord 已提交
1504 1505
    int p1[] = {1, 8, 987, 2};

1506 1507 1508 1509 1510 1511 1512 1513 1514
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
}

void testNotEqualIntArraysNullActual(void)
{
    int* p1 = NULL;
    int p0[] = {1, 8, 987, 2};
M
mvandervoord 已提交
1515 1516 1517

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4);
1518 1519
    VERIFY_FAILS_END
}
M
mvandervoord 已提交
1520

1521 1522 1523 1524
void testNotEqualIntArrays1(void)
{
    int p0[] = {1, 8, 987, -2};
    int p1[] = {1, 8, 987, 2};
M
mvandervoord 已提交
1525

1526 1527 1528
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
M
mvandervoord 已提交
1529 1530 1531 1532 1533 1534 1535 1536 1537
}

void testNotEqualIntArrays2(void)
{
    int p0[] = {1, 8, 987, -2};
    int p1[] = {2, 8, 987, -2};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4);
1538
    VERIFY_FAILS_END
M
mvandervoord 已提交
1539 1540 1541 1542 1543 1544 1545 1546 1547
}

void testNotEqualIntArrays3(void)
{
    int p0[] = {1, 8, 987, -2};
    int p1[] = {1, 8, 986, -2};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_INT_ARRAY(p0, p1, 4);
1548
    VERIFY_FAILS_END
M
mvandervoord 已提交
1549 1550
}

1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630
void testEqualPtrArrays(void)
{
    char A = 1;
    char B = 2;
    char C = 3;
    char* p0[] = {&A, &B, &C};
    char* p1[] = {&A, &B, &C, &A};
    char* p2[] = {&A, &B};
    char* p3[] = {&A};

    TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p0, 1);
    TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p0, 3);
    TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p1, 3);
    TEST_ASSERT_EQUAL_PTR_ARRAY(p1, p2, 2);
    TEST_ASSERT_EQUAL_PTR_ARRAY(p3, p0, 1);
}

void testNotEqualPtrArraysNullExpected(void)
{
    char A = 1;
    char B = 2;
    char** p0 = NULL;
    char* p1[] = {&A, &B};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p1, 2);
    VERIFY_FAILS_END
}

void testNotEqualPtrArraysNullActual(void)
{
    char A = 1;
    char B = 2;
    char** p0 = NULL;
    char* p1[] = {&A, &B};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_PTR_ARRAY(p1, p0, 2);
    VERIFY_FAILS_END
}

void testNotEqualPtrArrays1(void)
{
    char A = 1;
    char B = 2;
    char C = 3;
    char* p0[] = {&A, &B, &C, &B};
    char* p1[] = {&A, &B, &C, &A};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
}

void testNotEqualPtrArrays2(void)
{
    char A = 1;
    char B = 2;
    char C = 3;
    char* p0[] = {&B, &B, &C, &A};
    char* p1[] = {&A, &B, &C, &A};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
}

void testNotEqualPtrArrays3(void)
{
    char A = 1;
    char B = 2;
    char C = 3;
    char* p0[] = {&A, &B, &B, &A};
    char* p1[] = {&A, &B, &C, &A};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_PTR_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
}

1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646
void testEqualInt8Arrays(void)
{
    _US8 p0[] = {1, 8, 117, -2};
    _US8 p1[] = {1, 8, 117, -2};
    _US8 p2[] = {1, 8, 117, 2};
    _US8 p3[] = {1, 50, 60, 70};

    TEST_ASSERT_EQUAL_INT8_ARRAY(p0, p0, 1);
    TEST_ASSERT_EQUAL_INT8_ARRAY(p0, p0, 4);
    TEST_ASSERT_EQUAL_INT8_ARRAY(p0, p1, 4);
    TEST_ASSERT_EQUAL_INT8_ARRAY(p0, p2, 3);
    TEST_ASSERT_EQUAL_INT8_ARRAY(p0, p3, 1);
}

void testNotEqualInt8Arrays(void)
{
1647 1648
    _US8 p0[] = {1, 8, 36, -2};
    _US8 p1[] = {1, 8, 36, 2};
1649 1650 1651

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_INT8_ARRAY(p0, p1, 4);
1652
    VERIFY_FAILS_END
1653 1654
}

M
mvandervoord 已提交
1655 1656
void testEqualUIntArrays(void)
{
1657 1658
    unsigned int p0[] = {1, 8, 987, 65132u};
    unsigned int p1[] = {1, 8, 987, 65132u};
M
mvandervoord 已提交
1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670
    unsigned int p2[] = {1, 8, 987, 2};
    unsigned int p3[] = {1, 500, 600, 700};

    TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p0, 1);
    TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p0, 4);
    TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p1, 4);
    TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p2, 3);
    TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p3, 1);
}

void testNotEqualUIntArrays1(void)
{
1671 1672
    unsigned int p0[] = {1, 8, 987, 65132u};
    unsigned int p1[] = {1, 8, 987, 65131u};
M
mvandervoord 已提交
1673 1674 1675

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p1, 4);
1676
    VERIFY_FAILS_END
M
mvandervoord 已提交
1677 1678 1679 1680
}

void testNotEqualUIntArrays2(void)
{
1681 1682
    unsigned int p0[] = {1, 8, 987, 65132u};
    unsigned int p1[] = {2, 8, 987, 65132u};
M
mvandervoord 已提交
1683 1684 1685

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p1, 4);
1686
    VERIFY_FAILS_END
M
mvandervoord 已提交
1687 1688 1689 1690
}

void testNotEqualUIntArrays3(void)
{
1691 1692
    unsigned int p0[] = {1, 8, 987, 65132u};
    unsigned int p1[] = {1, 8, 986, 65132u};
M
mvandervoord 已提交
1693 1694 1695

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_UINT_ARRAY(p0, p1, 4);
1696
    VERIFY_FAILS_END
G
greg-williams 已提交
1697 1698
}

1699 1700
void testEqualInt16Arrays(void)
{
1701 1702 1703 1704
    _US16 p0[] = {1, 8, 117, 3};
    _US16 p1[] = {1, 8, 117, 3};
    _US16 p2[] = {1, 8, 117, 2};
    _US16 p3[] = {1, 50, 60, 70};
1705 1706 1707 1708 1709 1710 1711 1712 1713 1714

    TEST_ASSERT_EQUAL_INT16_ARRAY(p0, p0, 1);
    TEST_ASSERT_EQUAL_INT16_ARRAY(p0, p0, 4);
    TEST_ASSERT_EQUAL_INT16_ARRAY(p0, p1, 4);
    TEST_ASSERT_EQUAL_INT16_ARRAY(p0, p2, 3);
    TEST_ASSERT_EQUAL_INT16_ARRAY(p0, p3, 1);
}

void testNotEqualInt16Arrays(void)
{
1715 1716
    _US16 p0[] = {1, 8, 127, 3};
    _US16 p1[] = {1, 8, 127, 2};
1717 1718 1719

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_INT16_ARRAY(p0, p1, 4);
1720
    VERIFY_FAILS_END
1721 1722
}

1723 1724 1725 1726 1727 1728
void testEqualInt32Arrays(void)
{
    _US32 p0[] = {1, 8, 117, 3};
    _US32 p1[] = {1, 8, 117, 3};
    _US32 p2[] = {1, 8, 117, 2};
    _US32 p3[] = {1, 50, 60, 70};
1729

1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740
    TEST_ASSERT_EQUAL_INT32_ARRAY(p0, p0, 1);
    TEST_ASSERT_EQUAL_INT32_ARRAY(p0, p0, 4);
    TEST_ASSERT_EQUAL_INT32_ARRAY(p0, p1, 4);
    TEST_ASSERT_EQUAL_INT32_ARRAY(p0, p2, 3);
    TEST_ASSERT_EQUAL_INT32_ARRAY(p0, p3, 1);
}

void testNotEqualInt32Arrays(void)
{
    _US32 p0[] = {1, 8, 127, 3};
    _US32 p1[] = {1, 8, 127, 2};
1741

1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_INT32_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
}

void testEqualUINT8Arrays(void)
{
    _UU8 p0[] = {1, 8, 100, 127};
    _UU8 p1[] = {1, 8, 100, 127};
    _UU8 p2[] = {1, 8, 100, 2};
    _UU8 p3[] = {1, 50, 60, 70};
1753

1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764
    TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p0, 1);
    TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p0, 4);
    TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p1, 4);
    TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p2, 3);
    TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p3, 1);
}

void testNotEqualUINT8Arrays1(void)
{
    unsigned char p0[] = {1, 8, 100, 127u};
    unsigned char p1[] = {1, 8, 100, 255u};
1765

1766 1767 1768 1769 1770 1771 1772 1773 1774
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
}

void testNotEqualUINT8Arrays2(void)
{
    unsigned char p0[] = {1, 8, 100, 127u};
    unsigned char p1[] = {1, 8, 100, 255u};
1775

1776 1777 1778 1779 1780 1781 1782 1783 1784
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
}

void testNotEqualUINT8Arrays3(void)
{
    unsigned char p0[] = {1, 8, 100, 127u};
    unsigned char p1[] = {1, 8, 100, 255u};
1785

1786 1787 1788 1789 1790 1791
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_UINT8_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
}


1792 1793 1794 1795 1796 1797
void testEqualUINT16Arrays(void)
{
    unsigned short p0[] = {1, 8, 987, 65132u};
    unsigned short p1[] = {1, 8, 987, 65132u};
    unsigned short p2[] = {1, 8, 987, 2};
    unsigned short p3[] = {1, 500, 600, 700};
1798

1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809
    TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p0, 1);
    TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p0, 4);
    TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p1, 4);
    TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p2, 3);
    TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p3, 1);
}

void testNotEqualUINT16Arrays1(void)
{
    unsigned short p0[] = {1, 8, 987, 65132u};
    unsigned short p1[] = {1, 8, 987, 65131u};
1810

1811 1812 1813 1814 1815 1816 1817 1818 1819
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
}

void testNotEqualUINT16Arrays2(void)
{
    unsigned short p0[] = {1, 8, 987, 65132u};
    unsigned short p1[] = {2, 8, 987, 65132u};
1820

1821 1822 1823 1824 1825 1826 1827 1828 1829
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
}

void testNotEqualUINT16Arrays3(void)
{
    unsigned short p0[] = {1, 8, 987, 65132u};
    unsigned short p1[] = {1, 8, 986, 65132u};
1830

1831 1832 1833 1834 1835
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_UINT16_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
}

1836 1837 1838 1839 1840 1841
void testEqualUINT32Arrays(void)
{
    _UU32 p0[] = {1, 8, 987, 65132u};
    _UU32 p1[] = {1, 8, 987, 65132u};
    _UU32 p2[] = {1, 8, 987, 2};
    _UU32 p3[] = {1, 500, 600, 700};
1842

1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853
    TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p0, 1);
    TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p0, 4);
    TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p1, 4);
    TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p2, 3);
    TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p3, 1);
}

void testNotEqualUINT32Arrays1(void)
{
    _UU32 p0[] = {1, 8, 987, 65132u};
    _UU32 p1[] = {1, 8, 987, 65131u};
1854

1855 1856 1857 1858 1859 1860 1861 1862 1863
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
}

void testNotEqualUINT32Arrays2(void)
{
    _UU32 p0[] = {1, 8, 987, 65132u};
    _UU32 p1[] = {2, 8, 987, 65132u};
1864

1865 1866 1867 1868 1869 1870 1871 1872 1873
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
}

void testNotEqualUINT32Arrays3(void)
{
    _UU32 p0[] = {1, 8, 987, 65132u};
    _UU32 p1[] = {1, 8, 986, 65132u};
1874

1875 1876 1877 1878 1879
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_UINT32_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
}

M
mvandervoord 已提交
1880 1881
void testEqualHEXArrays(void)
{
1882 1883 1884 1885
    _UU32 p0[] = {1, 8, 987, 65132u};
    _UU32 p1[] = {1, 8, 987, 65132u};
    _UU32 p2[] = {1, 8, 987, 2};
    _UU32 p3[] = {1, 500, 600, 700};
M
mvandervoord 已提交
1886 1887 1888 1889 1890 1891 1892 1893 1894 1895

    TEST_ASSERT_EQUAL_HEX_ARRAY(p0, p0, 1);
    TEST_ASSERT_EQUAL_HEX_ARRAY(p0, p0, 4);
    TEST_ASSERT_EQUAL_HEX_ARRAY(p0, p1, 4);
    TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p2, 3);
    TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p3, 1);
}

void testNotEqualHEXArrays1(void)
{
1896 1897
    _UU32 p0[] = {1, 8, 987, 65132u};
    _UU32 p1[] = {1, 8, 987, 65131u};
M
mvandervoord 已提交
1898 1899 1900

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p1, 4);
1901
    VERIFY_FAILS_END
M
mvandervoord 已提交
1902 1903 1904 1905
}

void testNotEqualHEXArrays2(void)
{
1906 1907
    _UU32 p0[] = {1, 8, 987, 65132u};
    _UU32 p1[] = {2, 8, 987, 65132u};
M
mvandervoord 已提交
1908 1909 1910

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p1, 4);
1911
    VERIFY_FAILS_END
M
mvandervoord 已提交
1912 1913 1914 1915
}

void testNotEqualHEXArrays3(void)
{
1916 1917
    _UU32 p0[] = {1, 8, 987, 65132u};
    _UU32 p1[] = {1, 8, 986, 65132u};
M
mvandervoord 已提交
1918 1919 1920

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_HEX_ARRAY(p0, p1, 4);
1921
    VERIFY_FAILS_END
M
mvandervoord 已提交
1922 1923
}

1924 1925 1926 1927 1928 1929
void testEqualHEX32Arrays(void)
{
    _UU32 p0[] = {1, 8, 987, 65132u};
    _UU32 p1[] = {1, 8, 987, 65132u};
    _UU32 p2[] = {1, 8, 987, 2};
    _UU32 p3[] = {1, 500, 600, 700};
1930

1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941
    TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p0, 1);
    TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p0, 4);
    TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p1, 4);
    TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p2, 3);
    TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p3, 1);
}

void testNotEqualHEX32Arrays1(void)
{
    _UU32 p0[] = {1, 8, 987, 65132u};
    _UU32 p1[] = {1, 8, 987, 65131u};
1942

1943 1944 1945 1946 1947 1948 1949 1950 1951
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
}

void testNotEqualHEX32Arrays2(void)
{
    _UU32 p0[] = {1, 8, 987, 65132u};
    _UU32 p1[] = {2, 8, 987, 65132u};
1952

1953 1954 1955 1956 1957 1958 1959 1960 1961
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
}

void testNotEqualHEX32Arrays3(void)
{
    _UU32 p0[] = {1, 8, 987, 65132u};
    _UU32 p1[] = {1, 8, 986, 65132u};
1962

1963 1964 1965 1966 1967
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_HEX32_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
}

1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988
void testEqualHEX16Arrays(void)
{
    unsigned short p0[] = {1, 8, 987, 65132u};
    unsigned short p1[] = {1, 8, 987, 65132u};
    unsigned short p2[] = {1, 8, 987, 2};
    unsigned short p3[] = {1, 500, 600, 700};

    TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p0, 1);
    TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p0, 4);
    TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p1, 4);
    TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p2, 3);
    TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p3, 1);
}

void testNotEqualHEX16Arrays1(void)
{
    unsigned short p0[] = {1, 8, 987, 65132u};
    unsigned short p1[] = {1, 8, 987, 65131u};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p1, 4);
1989
    VERIFY_FAILS_END
1990 1991 1992 1993 1994 1995 1996 1997 1998
}

void testNotEqualHEX16Arrays2(void)
{
    unsigned short p0[] = {1, 8, 987, 65132u};
    unsigned short p1[] = {2, 8, 987, 65132u};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p1, 4);
1999
    VERIFY_FAILS_END
2000 2001 2002 2003 2004 2005 2006 2007 2008
}

void testNotEqualHEX16Arrays3(void)
{
    unsigned short p0[] = {1, 8, 987, 65132u};
    unsigned short p1[] = {1, 8, 986, 65132u};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_HEX16_ARRAY(p0, p1, 4);
2009
    VERIFY_FAILS_END
2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032
}

void testEqualHEX8Arrays(void)
{
    unsigned short p0[] = {1, 8, 254u, 123};
    unsigned short p1[] = {1, 8, 254u, 123};
    unsigned short p2[] = {1, 8, 254u, 2};
    unsigned short p3[] = {1, 23, 25, 26};

    TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p0, 1);
    TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p0, 4);
    TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p1, 4);
    TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p2, 3);
    TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p3, 1);
}

void testNotEqualHEX8Arrays1(void)
{
    unsigned char p0[] = {1, 8, 254u, 253u};
    unsigned char p1[] = {1, 8, 254u, 252u};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p1, 4);
2033
    VERIFY_FAILS_END
2034 2035 2036 2037 2038 2039 2040 2041 2042
}

void testNotEqualHEX8Arrays2(void)
{
    unsigned char p0[] = {1, 8, 254u, 253u};
    unsigned char p1[] = {2, 8, 254u, 253u};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p1, 4);
2043
    VERIFY_FAILS_END
2044 2045 2046 2047 2048 2049 2050 2051 2052
}

void testNotEqualHEX8Arrays3(void)
{
    unsigned char p0[] = {1, 8, 254u, 253u};
    unsigned char p1[] = {1, 8, 255u, 253u};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_HEX8_ARRAY(p0, p1, 4);
2053
    VERIFY_FAILS_END
2054 2055
}

M
mvandervoord 已提交
2056 2057 2058 2059 2060 2061 2062
void testEqualMemoryArrays(void)
{
    int p0[] = {1, 8, 987, -2};
    int p1[] = {1, 8, 987, -2};
    int p2[] = {1, 8, 987, 2};
    int p3[] = {1, 500, 600, 700};

2063 2064 2065 2066 2067
    TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p0, sizeof(int), 1);
    TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p0, sizeof(int), 4);
    TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p1, sizeof(int), 4);
    TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p2, sizeof(int), 3);
    TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p3, sizeof(int), 1);
M
mvandervoord 已提交
2068 2069 2070 2071 2072 2073 2074 2075
}

void testNotEqualMemoryArraysExpectedNull(void)
{
    int* p0 = NULL;
    int p1[] = {1, 8, 987, 2};

    EXPECT_ABORT_BEGIN
2076
    TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p1, sizeof(int), 4);
M
mvandervoord 已提交
2077 2078 2079 2080 2081 2082 2083 2084 2085
    VERIFY_FAILS_END
}

void testNotEqualMemoryArraysActualNull(void)
{
    int p0[] = {1, 8, 987, -2};
    int* p1 = NULL;

    EXPECT_ABORT_BEGIN
2086
    TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p1, sizeof(int), 4);
M
mvandervoord 已提交
2087 2088 2089 2090 2091 2092 2093 2094 2095
    VERIFY_FAILS_END
}

void testNotEqualMemoryArrays1(void)
{
    int p0[] = {1, 8, 987, -2};
    int p1[] = {1, 8, 987, 2};

    EXPECT_ABORT_BEGIN
2096
    TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p1, sizeof(int), 4);
M
mvandervoord 已提交
2097 2098 2099 2100 2101 2102 2103 2104 2105
    VERIFY_FAILS_END
}

void testNotEqualMemoryArrays2(void)
{
    int p0[] = {1, 8, 987, -2};
    int p1[] = {2, 8, 987, -2};

    EXPECT_ABORT_BEGIN
2106
    TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p1, sizeof(int), 4);
M
mvandervoord 已提交
2107 2108 2109 2110 2111 2112 2113 2114 2115
    VERIFY_FAILS_END
}

void testNotEqualMemoryArrays3(void)
{
    int p0[] = {1, 8, 987, -2};
    int p1[] = {1, 8, 986, -2};

    EXPECT_ABORT_BEGIN
2116
    TEST_ASSERT_EQUAL_MEMORY_ARRAY(p0, p1, sizeof(int), 4);
M
mvandervoord 已提交
2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147
    VERIFY_FAILS_END
}

void testProtection(void)
{
    volatile int mask = 0;

    if (TEST_PROTECT())
    {
        mask |= 1;
        TEST_ABORT();
    }
    else
    {
        Unity.CurrentTestFailed = 0;
        mask |= 2;
    }

    TEST_ASSERT_EQUAL(3, mask);
}

void testIgnoredAndThenFailInTearDown(void)
{
    SetToOneToFailInTearDown = 1;
    TEST_IGNORE();
}

// ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES 64 BIT SUPPORT ==================

void testEqualHex64s(void)
{
M
mvandervoord 已提交
2148 2149 2150
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
M
mvandervoord 已提交
2151 2152
    _UU64 v0, v1;
    _UU64 *p0, *p1;
2153

M
mvandervoord 已提交
2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165
    v0 = 0x9876543201234567;
    v1 = 0x9876543201234567;
    p0 = &v0;
    p1 = &v1;

    TEST_ASSERT_EQUAL_HEX64(0x9876543201234567, 0x9876543201234567);
    TEST_ASSERT_EQUAL_HEX64(v0, v1);
    TEST_ASSERT_EQUAL_HEX64(0x9876543201234567, v1);
    TEST_ASSERT_EQUAL_HEX64(v0, 0x9876543201234567);
    TEST_ASSERT_EQUAL_HEX64(*p0, v1);
    TEST_ASSERT_EQUAL_HEX64(*p0, *p1);
    TEST_ASSERT_EQUAL_HEX64(*p0, 0x9876543201234567);
M
mvandervoord 已提交
2166
#endif
M
mvandervoord 已提交
2167 2168
}

2169 2170 2171 2172 2173 2174 2175
void testEqualUint64s(void)
{
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
    _UU64 v0, v1;
    _UU64 *p0, *p1;
2176

2177 2178 2179 2180
    v0 = 0x9876543201234567;
    v1 = 0x9876543201234567;
    p0 = &v0;
    p1 = &v1;
2181

2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198
    TEST_ASSERT_EQUAL_UINT64(0x9876543201234567, 0x9876543201234567);
    TEST_ASSERT_EQUAL_UINT64(v0, v1);
    TEST_ASSERT_EQUAL_UINT64(0x9876543201234567, v1);
    TEST_ASSERT_EQUAL_UINT64(v0, 0x9876543201234567);
    TEST_ASSERT_EQUAL_UINT64(*p0, v1);
    TEST_ASSERT_EQUAL_UINT64(*p0, *p1);
    TEST_ASSERT_EQUAL_UINT64(*p0, 0x9876543201234567);
#endif
}

void testEqualInt64s(void)
{
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
    _US64 v0, v1;
    _US64 *p0, *p1;
2199 2200 2201

    v0 = (_US64)0x9876543201234567;
    v1 = (_US64)0x9876543201234567;
2202 2203
    p0 = &v0;
    p1 = &v1;
2204

2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215
    TEST_ASSERT_EQUAL_INT64(0x9876543201234567, 0x9876543201234567);
    TEST_ASSERT_EQUAL_INT64(v0, v1);
    TEST_ASSERT_EQUAL_INT64(0x9876543201234567, v1);
    TEST_ASSERT_EQUAL_INT64(v0, 0x9876543201234567);
    TEST_ASSERT_EQUAL_INT64(*p0, v1);
    TEST_ASSERT_EQUAL_INT64(*p0, *p1);
    TEST_ASSERT_EQUAL_INT64(*p0, 0x9876543201234567);
#endif
}


M
mvandervoord 已提交
2216 2217
void testNotEqualHex64s(void)
{
M
mvandervoord 已提交
2218 2219 2220
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
M
mvandervoord 已提交
2221
    _UU64 v0, v1;
2222

M
mvandervoord 已提交
2223 2224 2225 2226 2227 2228
    v0 = 9000000000;
    v1 = 9100000000;

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_HEX64(v0, v1);
    VERIFY_FAILS_END
M
mvandervoord 已提交
2229
#endif
M
mvandervoord 已提交
2230 2231
}

2232 2233 2234 2235 2236 2237
void testNotEqualUint64s(void)
{
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
    _UU64 v0, v1;
2238

2239 2240
    v0 = 9000000000;
    v1 = 9100000000;
2241

2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_UINT64(v0, v1);
    VERIFY_FAILS_END
#endif
}

void testNotEqualInt64s(void)
{
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
    _US64 v0, v1;
2254

2255 2256
    v0 = -9000000000;
    v1 = 9100000000;
2257

2258 2259 2260 2261 2262 2263
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_INT64(v0, v1);
    VERIFY_FAILS_END
#endif
}

M
mvandervoord 已提交
2264 2265
void testNotEqualHex64sIfSigned(void)
{
M
mvandervoord 已提交
2266 2267 2268
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
M
mvandervoord 已提交
2269
    _US64 v0, v1;
2270

M
mvandervoord 已提交
2271 2272 2273 2274 2275 2276
    v0 = -9000000000;
    v1 = 9000000000;

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_HEX64(v0, v1);
    VERIFY_FAILS_END
M
mvandervoord 已提交
2277
#endif
M
mvandervoord 已提交
2278 2279 2280 2281
}

void testHEX64sWithinDelta(void)
{
M
mvandervoord 已提交
2282 2283 2284
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
M
mvandervoord 已提交
2285 2286 2287
    TEST_ASSERT_HEX64_WITHIN(1, 0x7FFFFFFFFFFFFFFF,0x7FFFFFFFFFFFFFFE);
    TEST_ASSERT_HEX64_WITHIN(5, 5000, 4996);
    TEST_ASSERT_HEX64_WITHIN(5, 5000, 5005);
M
mvandervoord 已提交
2288
#endif
M
mvandervoord 已提交
2289 2290 2291 2292
}

void testHEX64sNotWithinDelta(void)
{
M
mvandervoord 已提交
2293 2294 2295
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
M
mvandervoord 已提交
2296 2297 2298
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_HEX64_WITHIN(1, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFC);
    VERIFY_FAILS_END
M
mvandervoord 已提交
2299
#endif
M
mvandervoord 已提交
2300 2301 2302 2303
}

void testHEX64sNotWithinDeltaEvenThoughASignedIntWouldPass(void)
{
M
mvandervoord 已提交
2304 2305 2306
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
M
mvandervoord 已提交
2307 2308 2309
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_HEX64_WITHIN(5, 1, -1);
    VERIFY_FAILS_END
M
mvandervoord 已提交
2310
#endif
M
mvandervoord 已提交
2311 2312
}

2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367
void testUINT64sWithinDelta(void)
{
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
    TEST_ASSERT_UINT64_WITHIN(1, 0x7FFFFFFFFFFFFFFF,0x7FFFFFFFFFFFFFFE);
    TEST_ASSERT_UINT64_WITHIN(5, 5000, 4996);
    TEST_ASSERT_UINT64_WITHIN(5, 5000, 5005);
#endif
}

void testUINT64sNotWithinDelta(void)
{
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_UINT64_WITHIN(1, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFC);
    VERIFY_FAILS_END
#endif
}

void testUINT64sNotWithinDeltaEvenThoughASignedIntWouldPass(void)
{
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_UINT64_WITHIN(5, 1, -1);
    VERIFY_FAILS_END
#endif
}

void testINT64sWithinDelta(void)
{
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
    TEST_ASSERT_INT64_WITHIN(1, 0x7FFFFFFFFFFFFFFF,0x7FFFFFFFFFFFFFFE);
    TEST_ASSERT_INT64_WITHIN(5, 5000, 4996);
    TEST_ASSERT_INT64_WITHIN(5, 5000, 5005);
#endif
}

void testINT64sNotWithinDelta(void)
{
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_INT64_WITHIN(1, 0x7FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFC);
    VERIFY_FAILS_END
#endif
}

M
mvandervoord 已提交
2368 2369
void testEqualHEX64Arrays(void)
{
M
mvandervoord 已提交
2370 2371 2372
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
M
mvandervoord 已提交
2373 2374 2375 2376 2377 2378 2379 2380 2381 2382
    _UU64 p0[] = {1, 8, 987, 65132u};
    _UU64 p1[] = {1, 8, 987, 65132u};
    _UU64 p2[] = {1, 8, 987, 2};
    _UU64 p3[] = {1, 500, 600, 700};

    TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p0, 1);
    TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p0, 4);
    TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p1, 4);
    TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p2, 3);
    TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p3, 1);
M
mvandervoord 已提交
2383
#endif
M
mvandervoord 已提交
2384 2385
}

2386 2387 2388 2389 2390 2391 2392 2393 2394
void testEqualUint64Arrays(void)
{
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
    _UU64 p0[] = {1, 8, 987, 65132u};
    _UU64 p1[] = {1, 8, 987, 65132u};
    _UU64 p2[] = {1, 8, 987, 2};
    _UU64 p3[] = {1, 500, 600, 700};
2395

2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412
    TEST_ASSERT_EQUAL_UINT64_ARRAY(p0, p0, 1);
    TEST_ASSERT_EQUAL_UINT64_ARRAY(p0, p0, 4);
    TEST_ASSERT_EQUAL_UINT64_ARRAY(p0, p1, 4);
    TEST_ASSERT_EQUAL_UINT64_ARRAY(p0, p2, 3);
    TEST_ASSERT_EQUAL_UINT64_ARRAY(p0, p3, 1);
#endif
}

void testEqualInt64Arrays(void)
{
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
    _US64 p0[] = {1, 8, 987, -65132};
    _US64 p1[] = {1, 8, 987, -65132};
    _US64 p2[] = {1, 8, 987, -2};
    _US64 p3[] = {1, 500, 600, 700};
2413

2414 2415 2416 2417 2418 2419 2420 2421 2422
    TEST_ASSERT_EQUAL_INT64_ARRAY(p0, p0, 1);
    TEST_ASSERT_EQUAL_INT64_ARRAY(p0, p0, 4);
    TEST_ASSERT_EQUAL_INT64_ARRAY(p0, p1, 4);
    TEST_ASSERT_EQUAL_INT64_ARRAY(p0, p2, 3);
    TEST_ASSERT_EQUAL_INT64_ARRAY(p0, p3, 1);
#endif
}


M
mvandervoord 已提交
2423 2424
void testNotEqualHEX64Arrays1(void)
{
M
mvandervoord 已提交
2425 2426 2427
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
M
mvandervoord 已提交
2428 2429 2430 2431 2432 2433
    _UU64 p0[] = {1, 8, 987, 65132u};
    _UU64 p1[] = {1, 8, 987, 65131u};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
M
mvandervoord 已提交
2434
#endif
M
mvandervoord 已提交
2435 2436 2437 2438
}

void testNotEqualHEX64Arrays2(void)
{
M
mvandervoord 已提交
2439 2440 2441
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
M
mvandervoord 已提交
2442 2443 2444 2445 2446 2447
    _UU64 p0[] = {1, 8, 987, 65132u};
    _UU64 p1[] = {2, 8, 987, 65132u};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_HEX64_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
M
mvandervoord 已提交
2448
#endif
M
mvandervoord 已提交
2449 2450
}

2451 2452 2453 2454 2455 2456 2457
void testNotEqualUint64Arrays(void)
{
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
    _UU64 p0[] = {1, 8, 987, 65132u};
    _UU64 p1[] = {1, 8, 987, 65131u};
2458

2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_UINT64_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
#endif
}

void testNotEqualInt64Arrays(void)
{
#ifndef UNITY_SUPPORT_64
    TEST_IGNORE();
#else
    _US64 p0[] = {1, 8, 987, -65132};
    _US64 p1[] = {1, 8, 987, -65131};
2472

2473 2474 2475 2476 2477
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_INT64_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
#endif
}
M
mvandervoord 已提交
2478 2479 2480 2481
// ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES FLOAT SUPPORT ==================

void testFloatsWithinDelta(void)
{
M
mvandervoord 已提交
2482 2483 2484
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
M
mvandervoord 已提交
2485 2486 2487 2488
    TEST_ASSERT_FLOAT_WITHIN(0.00003f, 187245.03485f, 187245.03488f);
    TEST_ASSERT_FLOAT_WITHIN(1.0f, 187245.0f, 187246.0f);
    TEST_ASSERT_FLOAT_WITHIN(0.05f, 9273.2549f, 9273.2049f);
    TEST_ASSERT_FLOAT_WITHIN(0.007f, -726.93724f, -726.94424f);
M
mvandervoord 已提交
2489
#endif
M
mvandervoord 已提交
2490 2491 2492 2493
}

void testFloatsNotWithinDelta(void)
{
M
mvandervoord 已提交
2494 2495 2496
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
M
mvandervoord 已提交
2497 2498 2499
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_FLOAT_WITHIN(0.05f, 9273.2649f, 9273.2049f);
    VERIFY_FAILS_END
M
mvandervoord 已提交
2500
#endif
M
mvandervoord 已提交
2501 2502 2503 2504
}

void testFloatsEqual(void)
{
M
mvandervoord 已提交
2505 2506 2507
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
M
mvandervoord 已提交
2508 2509 2510 2511
    TEST_ASSERT_EQUAL_FLOAT(187245.0f, 187246.0f);
    TEST_ASSERT_EQUAL_FLOAT(18724.5f, 18724.6f);
    TEST_ASSERT_EQUAL_FLOAT(9273.2549f, 9273.2599f);
    TEST_ASSERT_EQUAL_FLOAT(-726.93724f, -726.9374f);
M
mvandervoord 已提交
2512
#endif
M
mvandervoord 已提交
2513 2514 2515 2516
}

void testFloatsNotEqual(void)
{
M
mvandervoord 已提交
2517 2518 2519
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
M
mvandervoord 已提交
2520 2521 2522
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_FLOAT(9273.9649f, 9273.0049f);
    VERIFY_FAILS_END
M
mvandervoord 已提交
2523
#endif
M
mvandervoord 已提交
2524 2525 2526 2527
}

void testFloatsNotEqualNegative1(void)
{
M
mvandervoord 已提交
2528 2529 2530
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
M
mvandervoord 已提交
2531 2532 2533
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_FLOAT(-9273.9649f, -9273.0049f);
    VERIFY_FAILS_END
M
mvandervoord 已提交
2534
#endif
M
mvandervoord 已提交
2535 2536 2537 2538
}

void testFloatsNotEqualNegative2(void)
{
M
mvandervoord 已提交
2539 2540 2541
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
M
mvandervoord 已提交
2542 2543 2544
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_FLOAT(-9273.0049f, -9273.9649f);
    VERIFY_FAILS_END
M
mvandervoord 已提交
2545
#endif
M
mvandervoord 已提交
2546 2547
}

2548 2549 2550 2551 2552 2553
void testFloatsNotEqualActualNaN(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
2554
    TEST_ASSERT_EQUAL_FLOAT(85.963f, 0.0f / f_zero);
2555 2556 2557 2558
    VERIFY_FAILS_END
#endif
}

2559 2560 2561 2562 2563 2564
void testFloatsNotEqualExpectedNaN(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
2565
    TEST_ASSERT_EQUAL_FLOAT(0.0f / f_zero, 85.963f);
2566 2567 2568 2569 2570 2571 2572 2573 2574 2575
    VERIFY_FAILS_END
#endif
}

void testFloatsNotEqualBothNaN(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
2576
    TEST_ASSERT_EQUAL_FLOAT(0.0f / f_zero, 0.0f / f_zero);
2577 2578 2579 2580 2581 2582 2583 2584 2585 2586
    VERIFY_FAILS_END
#endif
}

void testFloatsNotEqualInfNaN(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
2587
    TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, 0.0f / f_zero);
2588 2589 2590 2591 2592 2593 2594 2595 2596 2597
    VERIFY_FAILS_END
#endif
}

void testFloatsNotEqualNaNInf(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
2598
    TEST_ASSERT_EQUAL_FLOAT(0.0f / f_zero, 1.0f / f_zero);
2599 2600 2601 2602
    VERIFY_FAILS_END
#endif
}

2603 2604 2605 2606 2607 2608
void testFloatsNotEqualActualInf(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
2609
    TEST_ASSERT_EQUAL_FLOAT(321.642f, 1.0f / f_zero);
2610 2611 2612 2613 2614 2615 2616 2617 2618 2619
    VERIFY_FAILS_END
#endif
}

void testFloatsNotEqualExpectedInf(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
2620
    TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, 321.642f);
2621 2622 2623 2624 2625 2626 2627 2628 2629 2630
    VERIFY_FAILS_END
#endif
}

void testFloatsNotEqualBothInf(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
2631
    TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, 1.0f / f_zero);
2632 2633 2634 2635 2636 2637 2638 2639 2640 2641
    VERIFY_FAILS_END
#endif
}

void testFloatsNotEqualPlusMinusInf(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
2642
    TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, -1.0f / f_zero);
2643 2644 2645 2646
    VERIFY_FAILS_END
#endif
}

2647
void testFloatIsPosInf1(void)
2648 2649 2650 2651
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
2652
    TEST_ASSERT_FLOAT_IS_INF(2.0f / f_zero);
2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671
#endif
}

void testFloatIsPosInf2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_FLOAT_IS_NOT_INF(2.0f / f_zero);
    VERIFY_FAILS_END
#endif
}

void testFloatIsNegInf1(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
2672
    TEST_ASSERT_FLOAT_IS_NEG_INF(-3.0f / f_zero);
2673 2674 2675
#endif
}

2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687
void testFloatIsNegInf2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(-3.0f / f_zero);
    VERIFY_FAILS_END
#endif
}

void testFloatIsNotPosInf1(void)
2688 2689 2690 2691 2692 2693 2694 2695 2696 2697
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_FLOAT_IS_INF(2.0f);
    VERIFY_FAILS_END
#endif
}

2698 2699 2700 2701 2702 2703 2704 2705 2706
void testFloatIsNotPosInf2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    TEST_ASSERT_FLOAT_IS_NOT_INF(2.0f);
#endif
}

2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717
void testFloatIsNotNegInf(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_FLOAT_IS_NEG_INF(-999.876f);
    VERIFY_FAILS_END
#endif
}

2718
void testFloatIsNan1(void)
2719 2720 2721 2722
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
2723
    TEST_ASSERT_FLOAT_IS_NAN(0.0f / f_zero);
2724 2725 2726
#endif
}

2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738
void testFloatIsNan2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_FLOAT_IS_NOT_NAN(0.0f / f_zero);
    VERIFY_FAILS_END
#endif
}

void testFloatIsNotNan1(void)
2739 2740 2741 2742 2743 2744 2745 2746 2747 2748
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_FLOAT_IS_NAN(234.9f);
    VERIFY_FAILS_END
#endif
}

2749 2750 2751 2752 2753 2754 2755 2756 2757
void testFloatIsNotNan2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    TEST_ASSERT_FLOAT_IS_NOT_NAN(234.9f);
#endif
}

2758 2759 2760 2761 2762 2763
void testFloatInfIsNotNan(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
2764
    TEST_ASSERT_FLOAT_IS_NAN(1.0f / f_zero);
2765 2766 2767 2768 2769 2770 2771 2772 2773 2774
    VERIFY_FAILS_END
#endif
}

void testFloatNanIsNotInf(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
2775
    TEST_ASSERT_FLOAT_IS_INF(0.0f / f_zero);
2776 2777 2778 2779
    VERIFY_FAILS_END
#endif
}

2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823
void testFloatIsDeterminate1(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    TEST_ASSERT_FLOAT_IS_DETERMINATE(0.0f);
    TEST_ASSERT_FLOAT_IS_DETERMINATE(123.3f);
    TEST_ASSERT_FLOAT_IS_DETERMINATE(-88.3f);
#endif
}

void testFloatIsDeterminate2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(-88.3f);
    VERIFY_FAILS_END
#endif
}

void testFloatIsNotDeterminate1(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(1.0f / f_zero);
    TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(-1.0f / f_zero);
    TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(0.0f / f_zero);
#endif
}

void testFloatIsNotDeterminate2(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_FLOAT_IS_DETERMINATE(-1.0f / f_zero);
    VERIFY_FAILS_END
#endif
}

2824 2825
void testEqualFloatArrays(void)
{
M
mvandervoord 已提交
2826 2827 2828
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
2829 2830 2831 2832
    float p0[] = {1.0f, -8.0f,  25.4f, -0.123f};
    float p1[] = {1.0f, -8.0f,  25.4f, -0.123f};
    float p2[] = {1.0f, -8.0f,  25.4f, -0.2f};
    float p3[] = {1.0f, -23.0f, 25.0f, -0.26f};
2833 2834 2835 2836 2837 2838

    TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p0, 1);
    TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p0, 4);
    TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
    TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p2, 3);
    TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p3, 1);
M
mvandervoord 已提交
2839
#endif
2840 2841
}

2842
void testNotEqualFloatArraysExpectedNull(void)
2843
{
M
mvandervoord 已提交
2844 2845 2846
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
2847
    float* p0 = NULL;
2848
    float p1[] = {1.0f, 8.0f, 25.4f, 0.252f};
2849

2850 2851 2852
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
M
mvandervoord 已提交
2853
#endif
2854 2855 2856 2857
}

void testNotEqualFloatArraysActualNull(void)
{
M
mvandervoord 已提交
2858 2859 2860
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
2861
    float p0[] = {1.0f, 8.0f, 25.4f, 0.253f};
2862
    float* p1 = NULL;
2863 2864 2865

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
2866
    VERIFY_FAILS_END
M
mvandervoord 已提交
2867
#endif
2868
}
2869

2870 2871
void testNotEqualFloatArrays1(void)
{
M
mvandervoord 已提交
2872 2873 2874
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
2875 2876
    float p0[] = {1.0f, 8.0f, 25.4f, 0.253f};
    float p1[] = {1.0f, 8.0f, 25.4f, 0.252f};
2877

2878 2879 2880
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
M
mvandervoord 已提交
2881
#endif
2882 2883 2884 2885
}

void testNotEqualFloatArrays2(void)
{
M
mvandervoord 已提交
2886 2887 2888
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
2889 2890
    float p0[] = {1.0f, 8.0f, 25.4f, 0.253f};
    float p1[] = {2.0f, 8.0f, 25.4f, 0.253f};
2891 2892 2893

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
2894
    VERIFY_FAILS_END
M
mvandervoord 已提交
2895
#endif
2896 2897 2898 2899
}

void testNotEqualFloatArrays3(void)
{
M
mvandervoord 已提交
2900 2901 2902
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
2903 2904
    float p0[] = {1.0f, 8.0f, 25.4f, 0.253f};
    float p1[] = {1.0f, 8.0f, 25.5f, 0.253f};
2905 2906 2907

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
2908
    VERIFY_FAILS_END
M
mvandervoord 已提交
2909
#endif
2910 2911
}

M
mvandervoord 已提交
2912 2913
void testNotEqualFloatArraysNegative1(void)
{
M
mvandervoord 已提交
2914 2915 2916
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
2917 2918
    float p0[] = {-1.0f, -8.0f, -25.4f, -0.253f};
    float p1[] = {-1.0f, -8.0f, -25.4f, -0.252f};
M
mvandervoord 已提交
2919 2920 2921

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
2922
    VERIFY_FAILS_END
M
mvandervoord 已提交
2923
#endif
M
mvandervoord 已提交
2924 2925 2926 2927
}

void testNotEqualFloatArraysNegative2(void)
{
M
mvandervoord 已提交
2928 2929 2930
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
2931 2932
    float p0[] = {-1.0f, -8.0f, -25.4f, -0.253f};
    float p1[] = {-2.0f, -8.0f, -25.4f, -0.253f};
M
mvandervoord 已提交
2933 2934 2935

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
2936
    VERIFY_FAILS_END
M
mvandervoord 已提交
2937
#endif
M
mvandervoord 已提交
2938 2939 2940 2941
}

void testNotEqualFloatArraysNegative3(void)
{
M
mvandervoord 已提交
2942 2943 2944
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
2945 2946
    float p0[] = {-1.0f, -8.0f, -25.4f, -0.253f};
    float p1[] = {-1.0f, -8.0f, -25.5f, -0.253f};
M
mvandervoord 已提交
2947 2948 2949

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
2950
    VERIFY_FAILS_END
M
mvandervoord 已提交
2951 2952 2953
#endif
}

2954 2955 2956 2957 2958
void testNotEqualFloatArraysNaN(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
2959 2960
    float p0[] = {1.0f, 0.0f / f_zero, 25.4f, 0.253f};
    float p1[] = {1.0f, 0.0f / f_zero, 25.4f, 0.253f};
2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
#endif
}

void testNotEqualFloatArraysInf(void)
{
#ifdef UNITY_EXCLUDE_FLOAT
    TEST_IGNORE();
#else
2973 2974
    float p0[] = {1.0f, 1.0f / f_zero, 25.4f, 0.253f};
    float p1[] = {1.0f, 1.0f / f_zero, 25.4f, 0.253f};
2975 2976 2977 2978 2979 2980 2981

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
#endif
}

M
mvandervoord 已提交
2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039
// ===================== THESE TEST WILL RUN IF YOUR CONFIG INCLUDES DOUBLE SUPPORT ==================

void testDoublesWithinDelta(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    TEST_ASSERT_DOUBLE_WITHIN(0.00003, 187245.03485, 187245.03488);
    TEST_ASSERT_DOUBLE_WITHIN(1.0, 187245.0, 187246.0);
    TEST_ASSERT_DOUBLE_WITHIN(0.05, 9273.2549, 9273.2049);
    TEST_ASSERT_DOUBLE_WITHIN(0.007, -726.93725, -726.94424);
#endif
}

void testDoublesNotWithinDelta(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_DOUBLE_WITHIN(0.05, 9273.2649, 9273.2049);
    VERIFY_FAILS_END
#endif
}


void testDoublesEqual(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    TEST_ASSERT_EQUAL_DOUBLE(187245123456.0, 187245123456.0);
    TEST_ASSERT_EQUAL_DOUBLE(187241234567.5, 187241234567.6);
    TEST_ASSERT_EQUAL_DOUBLE(9273.2512345649, 9273.25123455699);
    TEST_ASSERT_EQUAL_DOUBLE(-726.12345693724, -726.1234569374);
#endif
}

void testDoublesNotEqual(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_DOUBLE(9273.9649, 9273.0049);
    VERIFY_FAILS_END
#endif
}

void testDoublesNotEqualNegative1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_DOUBLE(-9273.9649, -9273.0049);
    VERIFY_FAILS_END
#endif
M
mvandervoord 已提交
3040 3041
}

M
mvandervoord 已提交
3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052
void testDoublesNotEqualNegative2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_DOUBLE(-9273.0049, -9273.9649);
    VERIFY_FAILS_END
#endif
}

3053 3054 3055 3056 3057 3058
void testDoublesNotEqualActualNaN(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
3059
    TEST_ASSERT_EQUAL_DOUBLE(85.963, 0.0 / d_zero);
3060 3061 3062 3063 3064 3065 3066 3067 3068 3069
    VERIFY_FAILS_END
#endif
}

void testDoublesNotEqualExpectedNaN(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
3070
    TEST_ASSERT_EQUAL_DOUBLE(0.0 / d_zero, 85.963);
3071 3072 3073 3074 3075 3076 3077 3078 3079 3080
    VERIFY_FAILS_END
#endif
}

void testDoublesNotEqualBothNaN(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
3081
    TEST_ASSERT_EQUAL_DOUBLE(0.0 / d_zero, 0.0 / d_zero);
3082 3083 3084 3085 3086 3087 3088 3089 3090 3091
    VERIFY_FAILS_END
#endif
}

void testDoublesNotEqualInfNaN(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
3092
    TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, 0.0 / d_zero);
3093 3094 3095 3096 3097 3098 3099 3100 3101 3102
    VERIFY_FAILS_END
#endif
}

void testDoublesNotEqualNaNInf(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
3103
    TEST_ASSERT_EQUAL_DOUBLE(0.0 / d_zero, 1.0 / d_zero);
3104 3105 3106 3107 3108 3109 3110 3111 3112 3113
    VERIFY_FAILS_END
#endif
}

void testDoublesNotEqualActualInf(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
3114
    TEST_ASSERT_EQUAL_DOUBLE(321.642, 1.0 / d_zero);
3115 3116 3117 3118 3119 3120 3121 3122 3123 3124
    VERIFY_FAILS_END
#endif
}

void testDoublesNotEqualExpectedInf(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
3125
    TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, 321.642);
3126 3127 3128 3129 3130 3131 3132 3133 3134 3135
    VERIFY_FAILS_END
#endif
}

void testDoublesNotEqualBothInf(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
3136
    TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, 1.0 / d_zero);
3137 3138 3139 3140 3141 3142 3143 3144 3145 3146
    VERIFY_FAILS_END
#endif
}

void testDoublesNotEqualPlusMinusInf(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
3147
    TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, -1.0 / d_zero);
3148 3149 3150 3151
    VERIFY_FAILS_END
#endif
}

3152
void testDoubleIsPosInf1(void)
3153 3154 3155 3156
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
3157
    TEST_ASSERT_DOUBLE_IS_INF(2.0 / d_zero);
3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176
#endif
}

void testDoubleIsPosInf2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_DOUBLE_IS_NOT_INF(2.0 / d_zero);
    VERIFY_FAILS_END
#endif
}

void testDoubleIsNegInf1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
3177
    TEST_ASSERT_DOUBLE_IS_NEG_INF(-3.0 / d_zero);
3178 3179 3180
#endif
}

3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192
void testDoubleIsNegInf2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(-3.0 / d_zero);
    VERIFY_FAILS_END
#endif
}

void testDoubleIsNotPosInf1(void)
3193 3194 3195 3196 3197
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
3198
    TEST_ASSERT_DOUBLE_IS_INF(2.0);
3199 3200 3201 3202
    VERIFY_FAILS_END
#endif
}

3203 3204 3205 3206 3207 3208 3209 3210 3211
void testDoubleIsNotPosInf2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    TEST_ASSERT_DOUBLE_IS_NOT_INF(2.0);
#endif
}

3212 3213 3214 3215 3216 3217
void testDoubleIsNotNegInf(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
3218
    TEST_ASSERT_DOUBLE_IS_NEG_INF(-999.876);
3219 3220 3221 3222
    VERIFY_FAILS_END
#endif
}

3223
void testDoubleIsNan1(void)
3224 3225 3226 3227
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
3228
    TEST_ASSERT_DOUBLE_IS_NAN(0.0 / d_zero);
3229 3230 3231
#endif
}

3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243
void testDoubleIsNan2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_DOUBLE_IS_NOT_NAN(0.0 / d_zero);
    VERIFY_FAILS_END
#endif
}

void testDoubleIsNotNan1(void)
3244 3245 3246 3247 3248
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
3249
    TEST_ASSERT_DOUBLE_IS_NAN(234.9);
3250 3251 3252 3253
    VERIFY_FAILS_END
#endif
}

3254 3255 3256 3257 3258 3259 3260 3261 3262
void testDoubleIsNotNan2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    TEST_ASSERT_DOUBLE_IS_NOT_NAN(234.9);
#endif
}

3263 3264 3265 3266 3267 3268
void testDoubleInfIsNotNan(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
3269
    TEST_ASSERT_DOUBLE_IS_NAN(1.0 / d_zero);
3270 3271 3272 3273 3274 3275 3276 3277 3278 3279
    VERIFY_FAILS_END
#endif
}

void testDoubleNanIsNotInf(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
3280
    TEST_ASSERT_DOUBLE_IS_INF(0.0 / d_zero);
3281 3282 3283 3284
    VERIFY_FAILS_END
#endif
}

3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328
void testDoubleIsDeterminate1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    TEST_ASSERT_DOUBLE_IS_DETERMINATE(0.0);
    TEST_ASSERT_DOUBLE_IS_DETERMINATE(123.3);
    TEST_ASSERT_DOUBLE_IS_DETERMINATE(-88.3);
#endif
}

void testDoubleIsDeterminate2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(-88.3);
    VERIFY_FAILS_END
#endif
}

void testDoubleIsNotDeterminate1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(1.0 / d_zero);
    TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(-1.0 / d_zero);
    TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(0.0 / d_zero);
#endif
}

void testDoubleIsNotDeterminate2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    EXPECT_ABORT_BEGIN
    TEST_ASSERT_DOUBLE_IS_DETERMINATE(-1.0 / d_zero);
    VERIFY_FAILS_END
#endif
}

M
mvandervoord 已提交
3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457
void testEqualDoubleArrays(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    double p0[] = {1.0, -8.0,  25.4, -0.123};
    double p1[] = {1.0, -8.0,  25.4, -0.123};
    double p2[] = {1.0, -8.0,  25.4, -0.2};
    double p3[] = {1.0, -23.0, 25.0, -0.26};

    TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p0, 1);
    TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p0, 4);
    TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
    TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p2, 3);
    TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p3, 1);
#endif
}

void testNotEqualDoubleArraysExpectedNull(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    double* p0 = NULL;
    double p1[] = {1.0, 8.0, 25.4, 0.252};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
#endif
}

void testNotEqualDoubleArraysActualNull(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    double p0[] = {1.0, 8.0, 25.4, 0.253};
    double* p1 = NULL;

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
#endif
}

void testNotEqualDoubleArrays1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    double p0[] = {1.0, 8.0, 25.4, 0.25666666667};
    double p1[] = {1.0, 8.0, 25.4, 0.25666666666};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
#endif
}

void testNotEqualDoubleArrays2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    double p0[] = {1.0, 8.0, 25.4, 0.253};
    double p1[] = {2.0, 8.0, 25.4, 0.253};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
#endif
}

void testNotEqualDoubleArrays3(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    double p0[] = {1.0, 8.0, 25.4, 0.253};
    double p1[] = {1.0, 8.0, 25.5, 0.253};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
#endif
}

void testNotEqualDoubleArraysNegative1(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    double p0[] = {-1.0, -8.0, -25.4, -0.2566666667};
    double p1[] = {-1.0, -8.0, -25.4, -0.2566666666};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
#endif
}

void testNotEqualDoubleArraysNegative2(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    double p0[] = {-1.0, -8.0, -25.4, -0.253};
    double p1[] = {-2.0, -8.0, -25.4, -0.253};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
#endif
}

void testNotEqualDoubleArraysNegative3(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
    double p0[] = {-1.0, -8.0, -25.4, -0.253};
    double p1[] = {-1.0, -8.0, -25.5, -0.253};

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
#endif
}
3458

3459 3460 3461 3462 3463
void testNotEqualDoubleArraysNaN(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
3464 3465
    double p0[] = {1.0, 0.0 / d_zero, 25.4, 0.253};
    double p1[] = {1.0, 0.0 / d_zero, 25.4, 0.253};
3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
#endif
}

void testNotEqualDoubleArraysInf(void)
{
#ifdef UNITY_EXCLUDE_DOUBLE
    TEST_IGNORE();
#else
3478 3479
    double p0[] = {1.0, 1.0 / d_zero, 25.4, 0.253};
    double p1[] = {1.0, 1.0 / d_zero, 25.4, 0.253};
3480 3481 3482 3483 3484

    EXPECT_ABORT_BEGIN
    TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
    VERIFY_FAILS_END
#endif
3485
}