Assert.sol
1 //SPDX-License-Identifier: MIT 2 // This file taken from here: https://raw.githubusercontent.com/smartcontractproduction/sol-unit/master/contracts/src/Assertions.sol 3 // It was renamed to Assert.sol by Tim Coulter. Refactored for solidity 0.5.0 by Cruz Molina. 4 5 pragma solidity >= 0.4.15 < 0.9.0; 6 7 import "./AssertString.sol"; 8 import "./AssertBytes32.sol"; 9 import "./AssertAddress.sol"; 10 import "./AssertBool.sol"; 11 import "./AssertUint.sol"; 12 import "./AssertInt.sol"; 13 import "./AssertUintArray.sol"; 14 import "./AssertIntArray.sol"; 15 import "./AssertAddressArray.sol"; 16 // import "AssertAddressPayableArray.sol"; 17 // ^would require an oldAssert.sol (0.4.0) & a newAssert.sol (0.5.0) 18 import "./AssertBytes32Array.sol"; 19 import "./AssertBalance.sol"; 20 import "./AssertGeneral.sol"; 21 22 /* 23 File: Assertions.slb 24 25 Author: Andreas Olofsson (androlo1980@gmail.com) 26 27 Library: Assertions 28 29 Assertions for unit testing contracts. Tests are run with the 30 <solUnit at https://github.com/smartcontractproduction/sol-unit> 31 unit-testing framework. 32 33 (start code) 34 contract ModAdder { 35 36 function addMod(uint a, uint b, uint modulus) constant returns (uint sum) { 37 if (modulus == 0) 38 throw; 39 return addmod(a, b, modulus); 40 } 41 42 } 43 44 contract SomeTest { 45 using Assertions for uint; 46 47 function testAdd() { 48 var adder = new ModAdder(); 49 adder.addMod(50, 66, 30).equal(26, "addition returned the wrong sum"); 50 } 51 } 52 (end) 53 54 It is also possible to extend <Test>, to have all bindings (using) properly set up. 55 56 (start code) 57 58 contract SomeTest is Test { 59 60 function testAdd() { 61 var adder = new ModAdder(); 62 adder.addMod(50, 66, 30).equal(26, "addition returned the wrong sum"); 63 } 64 } 65 (end) 66 */ 67 68 library Assert { 69 70 // ************************************** general ************************************** 71 72 /* 73 Function: fail() 74 75 Mark the test as failed. 76 77 Params: 78 message (string) - A message associated with the failure. 79 80 Returns: 81 result (bool) - false. 82 */ 83 function fail(string memory message) internal returns (bool result) { 84 return AssertGeneral.fail(message); 85 } 86 87 // ************************************** strings ************************************** 88 89 /* 90 Function: equal(string) 91 92 Assert that two strings are equal. 93 94 : _stringsEqual(A, B) == true 95 96 Params: 97 A (string) - The first string. 98 B (string) - The second string. 99 message (string) - A message that is sent if the assertion fails. 100 101 Returns: 102 result (bool) - The result. 103 */ 104 function equal(string memory a, string memory b, string memory message) internal returns (bool result) { 105 return AssertString.equal(a, b, message); 106 } 107 108 /* 109 Function: notEqual(string) 110 111 Assert that two strings are not equal. 112 113 : _stringsEqual(A, B) == false 114 115 Params: 116 A (string) - The first string. 117 B (string) - The second string. 118 message (string) - A message that is sent if the assertion fails. 119 120 Returns: 121 result (bool) - The result. 122 */ 123 function notEqual(string memory a, string memory b, string memory message) internal returns (bool result) { 124 return AssertString.notEqual(a, b, message); 125 } 126 127 /* 128 Function: isEmpty(string) 129 130 Assert that a string is empty. 131 132 : _stringsEqual(str, STRING_NULL) == true 133 134 Params: 135 str (string) - The string. 136 message (string) - A message that is sent if the assertion fails. 137 138 Returns: 139 result (bool) - The result. 140 */ 141 function isEmpty(string memory str, string memory message) internal returns (bool result) { 142 return AssertString.isEmpty(str, message); 143 } 144 145 /* 146 Function: isNotEmpty(string) 147 148 Assert that a string is not empty. 149 150 : _stringsEqual(str, STRING_NULL) == false 151 152 Params: 153 str (string) - The string. 154 message (string) - A message that is sent if the assertion fails. 155 156 Returns: 157 result (bool) - The result. 158 */ 159 function isNotEmpty(string memory str, string memory message) internal returns (bool result) { 160 return AssertString.isNotEmpty(str, message); 161 } 162 163 // ************************************** bytes32 ************************************** 164 165 /* 166 Function: equal(bytes32) 167 168 Assert that two 'bytes32' are equal. 169 170 : A == B 171 172 Params: 173 A (bytes32) - The first 'bytes32'. 174 B (bytes32) - The second 'bytes32'. 175 message (string) - A message that is sent if the assertion fails. 176 177 Returns: 178 result (bool) - The result. 179 */ 180 function equal(bytes32 a, bytes32 b, string memory message) internal returns (bool result) { 181 return AssertBytes32.equal(a, b, message); 182 } 183 184 /* 185 Function: notEqual(bytes32) 186 187 Assert that two 'bytes32' are not equal. 188 189 : A != B 190 191 Params: 192 A (bytes32) - The first 'bytes32'. 193 B (bytes32) - The second 'bytes32'. 194 message (string) - A message that is sent if the assertion fails. 195 196 Returns: 197 result (bool) - The result. 198 */ 199 function notEqual(bytes32 a, bytes32 b, string memory message) internal returns (bool result) { 200 return AssertBytes32.notEqual(a, b, message); 201 } 202 203 /* 204 Function: isZero(bytes32) 205 206 Assert that a 'bytes32' is zero. 207 208 : bts == BYTES32_NULL 209 210 Params: 211 bts (bytes32) - The 'bytes32'. 212 message (string) - A message that is sent if the assertion fails. 213 214 Returns: 215 result (bool) - The result. 216 */ 217 function isZero(bytes32 bts, string memory message) internal returns (bool result) { 218 return AssertBytes32.isZero(bts, message); 219 } 220 221 /* 222 Function: isNotZero(bytes32) 223 224 Assert that a 'bytes32' is not zero. 225 226 : bts != BYTES32_NULL 227 228 Params: 229 bts (bytes32) - The 'bytes32'. 230 message (string) - A message that is sent if the assertion fails. 231 232 Returns: 233 result (bool) - The result. 234 */ 235 function isNotZero(bytes32 bts, string memory message) internal returns (bool result) { 236 return AssertBytes32.isNotZero(bts, message); 237 } 238 239 // ************************************** address ************************************** 240 241 /* 242 Function: equal(address) 243 244 Assert that two addresses are equal. 245 246 : A == B 247 248 Params: 249 A (address) - The first address. 250 B (address) - The second address. 251 message (string) - A message that is sent if the assertion fails. 252 253 Returns: 254 result (bool) - The result. 255 */ 256 function equal(address a, address b, string memory message) internal returns (bool result) { 257 return AssertAddress.equal(a, b, message); 258 } 259 /* 260 Function: notEqual(address) 261 262 Assert that two addresses are not equal. 263 264 : A != B 265 266 Params: 267 A (address) - The first address. 268 B (address) - The second address. 269 message (string) - A message that is sent if the assertion fails. 270 271 Returns: 272 result (bool) - The result. 273 */ 274 function notEqual(address a, address b, string memory message) internal returns (bool result) { 275 return AssertAddress.notEqual(a, b, message); 276 } 277 278 /* 279 Function: isZero(address) 280 281 Assert that an address is zero. 282 283 : addr == ADDRESS_NULL 284 285 Params: 286 addr (address) - The address. 287 message (string) - A message that is sent if the assertion fails. 288 289 Returns: 290 result (bool) - The result. 291 */ 292 function isZero(address addr, string memory message) internal returns (bool result) { 293 return AssertAddress.isZero(addr, message); 294 } 295 296 /* 297 Function: isNotZero(address) 298 299 Assert that an address is not zero. 300 301 : addr != ADDRESS_NULL 302 303 Params: 304 addr (address) - The address. 305 message (string) - A message that is sent if the assertion fails. 306 307 Returns: 308 result (bool) - The result. 309 */ 310 function isNotZero(address addr, string memory message) internal returns (bool result) { 311 return AssertAddress.isNotZero(addr, message); 312 313 } 314 315 // ************************************** bool ************************************** 316 317 /* 318 Function: isTrue 319 320 Assert that a boolean is 'true'. 321 322 : b == true 323 324 Params: 325 b (bool) - The boolean. 326 message (string) - A message that is sent if the assertion fails. 327 328 Returns: 329 result (bool) - The result. 330 */ 331 function isTrue(bool b, string memory message) internal returns (bool result) { 332 return AssertBool.isTrue(b, message); 333 } 334 335 /* 336 Function: isFalse 337 338 Assert that a boolean is 'false'. 339 340 : b == false 341 342 Params: 343 b (bool) - The boolean. 344 message (string) - A message that is sent if the assertion fails. 345 346 Returns: 347 result (bool) - The result. 348 */ 349 function isFalse(bool b, string memory message) internal returns (bool result) { 350 return AssertBool.isFalse(b, message); 351 } 352 353 /* 354 Function: equal(bool) 355 356 Assert that two booleans are equal. 357 358 : A == B 359 360 Params: 361 A (bool) - The first boolean. 362 B (bool) - The second boolean. 363 message (string) - A message that is sent if the assertion fails. 364 365 Returns: 366 result (bool) - The result. 367 */ 368 function equal(bool a, bool b, string memory message) internal returns (bool result) { 369 return AssertBool.equal(a, b, message); 370 } 371 372 /* 373 Function: notEqual(bool) 374 375 Assert that two booleans are not equal. 376 377 : A != B 378 379 Params: 380 A (bool) - The first boolean. 381 B (bool) - The second boolean. 382 message (string) - A message that is sent if the assertion fails. 383 384 Returns: 385 result (bool) - The result. 386 */ 387 function notEqual(bool a, bool b, string memory message) internal returns (bool result) { 388 return AssertBool.notEqual(a, b, message); 389 } 390 391 // ************************************** uint ************************************** 392 393 /* 394 Function: equal(uint) 395 396 Assert that two (256 bit) unsigned integers are equal. 397 398 : A == B 399 400 Params: 401 A (uint) - The first uint. 402 B (uint) - The second uint. 403 message (string) - A message that is sent if the assertion fails. 404 405 Returns: 406 result (bool) - The result. 407 */ 408 function equal(uint a, uint b, string memory message) internal returns (bool result) { 409 return AssertUint.equal(a, b, message); 410 } 411 412 /* 413 Function: notEqual(uint) 414 415 Assert that two (256 bit) unsigned integers are not equal. 416 417 : A != B 418 419 Params: 420 A (uint) - The first uint. 421 B (uint) - The second uint. 422 message (string) - A message that is sent if the assertion fails. 423 424 Returns: 425 result (bool) - The result. 426 */ 427 function notEqual(uint a, uint b, string memory message) internal returns (bool result) { 428 return AssertUint.notEqual(a, b, message); 429 } 430 431 /* 432 Function: isAbove(uint) 433 434 Assert that the uint 'A' is greater than the uint 'B'. 435 436 : A > B 437 438 Params: 439 A (uint) - The first uint. 440 B (uint) - The second uint. 441 message (string) - A message that is sent if the assertion fails. 442 443 Returns: 444 result (bool) - The result. 445 */ 446 function isAbove(uint a, uint b, string memory message) internal returns (bool result) { 447 return AssertUint.isAbove(a, b, message); 448 } 449 450 /* 451 Function: isAtLeast(uint) 452 453 Assert that the uint 'A' is greater than or equal to the uint 'B'. 454 455 : A >= B 456 457 Params: 458 A (uint) - The first uint. 459 B (uint) - The second uint. 460 message (string) - A message that is sent if the assertion fails. 461 462 Returns: 463 result (bool) - The result. 464 */ 465 function isAtLeast(uint a, uint b, string memory message) internal returns (bool result) { 466 return AssertUint.isAtLeast(a, b, message); 467 } 468 469 /* 470 Function: isBelow(uint) 471 472 Assert that the uint 'A' is lesser than the uint 'B'. 473 474 : A < B 475 476 Params: 477 A (uint) - The first uint. 478 B (uint) - The second uint. 479 message (string) - A message that is sent if the assertion fails. 480 481 Returns: 482 result (bool) - The result. 483 */ 484 function isBelow(uint a, uint b, string memory message) internal returns (bool result) { 485 return AssertUint.isBelow(a, b, message); 486 } 487 488 /* 489 Function: isAtMost(uint) 490 491 Assert that the uint 'A' is lesser than or equal to the uint 'B'. 492 493 : A <= B 494 495 Params: 496 A (uint) - The first uint. 497 B (uint) - The second uint. 498 message (string) - A message that is sent if the assertion fails. 499 500 Returns: 501 result (bool) - The result. 502 */ 503 function isAtMost(uint a, uint b, string memory message) internal returns (bool result) { 504 return AssertUint.isAtMost(a, b, message); 505 } 506 507 /* 508 Function: isZero(uint) 509 510 Assert that a (256 bit) unsigned integer is 0. 511 512 : number == 0 513 514 Params: 515 number (uint) - The uint. 516 message (string) - A message that is sent if the assertion fails. 517 518 Returns: 519 result (bool) - The result. 520 */ 521 function isZero(uint number, string memory message) internal returns (bool result) { 522 return AssertUint.isZero(number, message); 523 } 524 525 /* 526 Function: isNotZero(uint) 527 528 Assert that a (256 bit) unsigned integer is not 0. 529 530 : number != 0 531 532 Params: 533 number (uint) - The uint. 534 message (string) - A message that is sent if the assertion fails. 535 536 Returns: 537 result (bool) - The result. 538 */ 539 function isNotZero(uint number, string memory message) internal returns (bool result) { 540 return AssertUint.isNotZero(number, message); 541 } 542 543 // ************************************** int ************************************** 544 545 /* 546 Function: equal(int) 547 548 Assert that two (256 bit) signed integers are equal. 549 550 : A == B 551 552 Params: 553 A (int) - The first int. 554 B (int) - The second int. 555 message (string) - A message that is sent if the assertion fails. 556 557 Returns: 558 result (bool) - The result. 559 */ 560 function equal(int a, int b, string memory message) internal returns (bool result) { 561 return AssertInt.equal(a, b, message); 562 } 563 564 /* 565 Function: notEqual(int) 566 567 Assert that two (256 bit) signed integers are not equal. 568 569 : A != B 570 571 Params: 572 A (int) - The first int. 573 B (int) - The second int. 574 message (string) - A message that is sent if the assertion fails. 575 576 Returns: 577 result (bool) - The result. 578 */ 579 function notEqual(int a, int b, string memory message) internal returns (bool result) { 580 return AssertInt.notEqual(a, b, message); 581 } 582 583 /* 584 Function: isAbove(int) 585 586 Assert that the int 'A' is greater than the int 'B'. 587 588 : A > B 589 590 Params: 591 A (int) - The first int. 592 B (int) - The second int. 593 message (string) - A message that is sent if the assertion fails. 594 595 Returns: 596 result (bool) - The result. 597 */ 598 function isAbove(int a, int b, string memory message) internal returns (bool result) { 599 return AssertInt.isAbove(a, b, message); 600 } 601 602 /* 603 Function: isAtLeast(int) 604 605 Assert that the int 'A' is greater than or equal to the int 'B'. 606 607 : A >= B 608 609 Params: 610 A (int) - The first int. 611 B (int) - The second int. 612 message (string) - A message that is sent if the assertion fails. 613 614 Returns: 615 result (bool) - The result. 616 */ 617 function isAtLeast(int a, int b, string memory message) internal returns (bool result) { 618 return AssertInt.isAtLeast(a, b, message); 619 } 620 621 /* 622 Function: isBelow(int) 623 624 Assert that the int 'A' is lesser than the int 'B'. 625 626 : A < B 627 628 Params: 629 A (int) - The first int. 630 B (int) - The second int. 631 message (string) - A message that is sent if the assertion fails. 632 633 Returns: 634 result (bool) - The result. 635 */ 636 function isBelow(int a, int b, string memory message) internal returns (bool result) { 637 return AssertInt.isBelow(a, b, message); 638 } 639 640 /* 641 Function: isAtMost(int) 642 643 Assert that the int 'A' is lesser than or equal to the int 'B'. 644 645 : A <= B 646 647 Params: 648 A (int) - The first int. 649 B (int) - The second int. 650 message (string) - A message that is sent if the assertion fails. 651 652 Returns: 653 result (bool) - The result. 654 */ 655 function isAtMost(int a, int b, string memory message) internal returns (bool result) { 656 return AssertInt.isAtMost(a, b, message); 657 } 658 659 /* 660 Function: isZero(int) 661 662 Assert that a (256 bit) signed integer is 0. 663 664 : number == 0 665 666 Params: 667 number (int) - The int. 668 message (string) - A message that is sent if the assertion fails. 669 670 Returns: 671 result (bool) - The result. 672 */ 673 function isZero(int number, string memory message) internal returns (bool result) { 674 return AssertInt.isZero(number, message); 675 } 676 677 /* 678 Function: isNotZero(int) 679 680 Assert that a (256 bit) signed integer is not 0. 681 682 : number != 0 683 684 Params: 685 number (int) - The int. 686 message (string) - A message that is sent if the assertion fails. 687 688 Returns: 689 result (bool) - The result. 690 */ 691 function isNotZero(int number, string memory message) internal returns (bool result) { 692 return AssertInt.isNotZero(number, message); 693 } 694 695 // ************************************** uint[] ************************************** 696 697 /* 698 Function: equal(uint[]) 699 700 Assert that two 'uint[ ]' are equal. 701 702 : arrA.length == arrB.length 703 704 and, for all valid indices 'i' 705 706 : arrA[i] == arrB[i] 707 708 Params: 709 A (uint[]) - The first array. 710 B (uint[]) - The second array. 711 message (string) - A message that is sent if the assertion fails. 712 713 Returns: 714 result (bool) - The result. 715 */ 716 function equal(uint[] memory arrA, uint[] memory arrB, string memory message) internal returns (bool result) { 717 return AssertUintArray.equal(arrA, arrB, message); 718 } 719 720 /* 721 Function: notEqual(uint[]) 722 723 Assert that two 'uint[]' are not equal. 724 725 : arrA.length != arrB.length 726 727 or, for some valid index 'i' 728 729 : arrA[i] != arrB[i] 730 731 Params: 732 A (uint[]) - The first string. 733 B (uint[]) - The second string. 734 message (string) - A message that is sent if the assertion fails. 735 736 Returns: 737 result (bool) - The result. 738 */ 739 function notEqual(uint[] memory arrA, uint[] memory arrB, string memory message) internal returns (bool result) { 740 return AssertUintArray.notEqual(arrA, arrB, message); 741 } 742 743 /* 744 Function: lengthEqual(uint[]) 745 746 Assert that the length of a 'uint[]' is equal to a given value. 747 748 : arr.length == length 749 750 Params: 751 arr (uint[]) - The array. 752 length (uint) - The length. 753 message (string) - A message that is sent if the assertion fails. 754 755 Returns: 756 result (bool) - The result. 757 */ 758 function lengthEqual(uint[] memory arr, uint length, string memory message) internal returns (bool result) { 759 return AssertUintArray.lengthEqual(arr, length, message); 760 } 761 762 /* 763 Function: lengthNotEqual(uint[]) 764 765 Assert that the length of a 'uint[]' is not equal to a given value. 766 767 : arr.length != length 768 769 Params: 770 arr (uint[]) - The array. 771 length (uint) - The length. 772 message (string) - A message that is sent if the assertion fails. 773 774 Returns: 775 result (bool) - The result. 776 */ 777 function lengthNotEqual(uint[] memory arr, uint length, string memory message) internal returns (bool result) { 778 return AssertUintArray.lengthNotEqual(arr, length, message); 779 } 780 781 // ************************************** int[] ************************************** 782 783 /* 784 Function: equal(int[]) 785 786 Assert that two 'int[]' are equal. 787 788 : arrA.length == arrB.length 789 790 and, for all valid indices 'i' 791 792 : arrA[i] == arrB[i] 793 794 Params: 795 A (int[]) - The first array. 796 B (int[]) - The second array. 797 message (string) - A message that is sent if the assertion fails. 798 799 Returns: 800 result (bool) - The result. 801 */ 802 function equal(int[] memory arrA, int[] memory arrB, string memory message) internal returns (bool result) { 803 return AssertIntArray.equal(arrA, arrB, message); 804 } 805 806 /* 807 Function: notEqual(int[]) 808 809 Assert that two 'int[]' are not equal. 810 811 : arrA.length != arrB.length 812 813 or, for some valid index 'i' 814 815 : arrA[i] != arrB[i] 816 817 Params: 818 A (int[]) - The first string. 819 B (int[]) - The second string. 820 message (string) - A message that is sent if the assertion fails. 821 822 Returns: 823 result (bool) - The result. 824 */ 825 function notEqual(int[] memory arrA, int[] memory arrB, string memory message) internal returns (bool result) { 826 return AssertIntArray.notEqual(arrA, arrB, message); 827 } 828 829 /* 830 Function: lengthEqual(int[]) 831 832 Assert that the length of an 'int[]' is equal to a given value. 833 834 : arr.length == length 835 836 Params: 837 arr (int[]) - The array. 838 length (uint) - The length. 839 message (string) - A message that is sent if the assertion fails. 840 841 Returns: 842 result (bool) - The result. 843 */ 844 function lengthEqual(int[] memory arr, uint length, string memory message) internal returns (bool result) { 845 return AssertIntArray.lengthEqual(arr, length, message); 846 } 847 848 /* 849 Function: lengthNotEqual(int[]) 850 851 Assert that the length of an 'int[]' is not equal to a given value. 852 853 : arr.length != length 854 855 Params: 856 arr (int[]) - The array. 857 length (uint) - The length. 858 message (string) - A message that is sent if the assertion fails. 859 860 Returns: 861 result (bool) - The result. 862 */ 863 function lengthNotEqual(int[] memory arr, uint length, string memory message) internal returns (bool result) { 864 return AssertIntArray.lengthNotEqual(arr, length, message); 865 } 866 867 // ************************************** address[] ************************************** 868 869 /* 870 Function: equal(address[]) 871 872 Assert that two 'address[]' are equal. 873 874 : arrA.length == arrB.length 875 876 and, for all valid indices 'i' 877 878 : arrA[i] == arrB[i] 879 880 Params: 881 A (address[]) - The first array. 882 B (address[]) - The second array. 883 message (string) - A message that is sent if the assertion fails. 884 885 Returns: 886 result (bool) - The result. 887 */ 888 function equal(address[] memory arrA, address[] memory arrB, string memory message) internal returns (bool result) { 889 return AssertAddressArray.equal(arrA, arrB, message); 890 } 891 892 /* 893 Function: notEqual(address[]) 894 895 Assert that two 'address[]' are not equal. 896 897 : arrA.length != arrB.length 898 899 or, for some valid index 'i' 900 901 : arrA[i] != arrB[i] 902 903 Params: 904 A (address[]) - The first string. 905 B (address[]) - The second string. 906 message (string) - A message that is sent if the assertion fails. 907 908 Returns: 909 result (bool) - The result. 910 */ 911 function notEqual(address[] memory arrA, address[] memory arrB, string memory message) internal returns (bool result) { 912 return AssertAddressArray.notEqual(arrA, arrB, message); 913 } 914 915 /* 916 Function: lengthEqual(address[]) 917 918 Assert that the length of an 'address[]' is equal to a given value. 919 920 : arr.length == length 921 922 Params: 923 arr (address[]) - The array. 924 length (uint) - The length. 925 message (string) - A message that is sent if the assertion fails. 926 927 Returns: 928 result (bool) - The result. 929 */ 930 function lengthEqual(address[] memory arr, uint length, string memory message) internal returns (bool result) { 931 return AssertAddressArray.lengthEqual(arr, length, message); 932 } 933 934 /* 935 Function: lengthNotEqual(address[]) 936 937 Assert that the length of an 'address[]' is not equal to a given value. 938 939 : arr.length != length 940 941 Params: 942 arr (address[]) - The array. 943 length (uint) - The length. 944 message (string) - A message that is sent if the assertion fails. 945 946 Returns: 947 result (bool) - The result. 948 */ 949 function lengthNotEqual(address[] memory arr, uint length, string memory message) internal returns (bool result) { 950 return AssertAddressArray.lengthNotEqual(arr, length, message); 951 } 952 953 // ************************************** address payable[] ************************************** 954 955 /* 956 Function: equal(address payable[]) 957 958 Assert that two 'address payable[]' are equal. 959 960 : arrA.length == arrB.length 961 962 and, for all valid indices 'i' 963 964 : arrA[i] == arrB[i] 965 966 Params: 967 A (address payable[]) - The first array. 968 B (address payable[]) - The second array. 969 message (string) - A message that is sent if the assertion fails. 970 971 Returns: 972 result (bool) - The result. 973 */ 974 // function equal(address payable[] memory arrA, address payable[] memory arrB, string memory message) internal returns (bool result) { 975 // return AssertAddressPayableArray.equal(arrA, arrB, message); 976 // } 977 978 /* 979 Function: notEqual(address payable[]) 980 981 Assert that two 'address payable[]' are not equal. 982 983 : arrA.length != arrB.length 984 985 or, for some valid index 'i' 986 987 : arrA[i] != arrB[i] 988 989 Params: 990 A (address payable[]) - The first string. 991 B (address payable[]) - The second string. 992 message (string) - A message that is sent if the assertion fails. 993 994 Returns: 995 result (bool) - The result. 996 */ 997 // function notEqual(address payable[] memory arrA, address payable[] memory arrB, string memory message) internal returns (bool result) { 998 // return AssertAddressPayableArray.notEqual(arrA, arrB, message); 999 // } 1000 1001 /* 1002 Function: lengthEqual(address payable[]) 1003 1004 Assert that the length of an 'address payable[]' is equal to a given value. 1005 1006 : arr.length == length 1007 1008 Params: 1009 arr (address payable[]) - The array. 1010 length (uint) - The length. 1011 message (string) - A message that is sent if the assertion fails. 1012 1013 Returns: 1014 result (bool) - The result. 1015 */ 1016 // function lengthEqual(address payable[] memory arr, uint length, string memory message) internal returns (bool result) { 1017 // return AssertAddressPayableArray.lengthEqual(arr, length, message); 1018 // } 1019 1020 /* 1021 Function: lengthNotEqual(address payable[]) 1022 1023 Assert that the length of an 'address payable[]' is not equal to a given value. 1024 1025 : arr.length != length 1026 1027 Params: 1028 arr (address payable[]) - The array. 1029 length (uint) - The length. 1030 message (string) - A message that is sent if the assertion fails. 1031 1032 Returns: 1033 result (bool) - The result. 1034 */ 1035 // function lengthNotEqual(address payable[] memory arr, uint length, string memory message) internal returns (bool result) { 1036 // return AssertAddressPayableArray.lengthNotEqual(arr, length, message); 1037 // } 1038 1039 // ************************************** bytes32[] ************************************** 1040 1041 /* 1042 Function: equal(bytes32[]) 1043 1044 Assert that two 'bytes32[]' are equal. 1045 1046 : arrA.length == arrB.length 1047 1048 and, for all valid indices 'i' 1049 1050 : arrA[i] == arrB[i] 1051 1052 Params: 1053 A (bytes32[]) - The first array. 1054 B (bytes32[]) - The second array. 1055 message (string) - A message that is sent if the assertion fails. 1056 1057 Returns: 1058 result (bool) - The result. 1059 */ 1060 function equal(bytes32[] memory arrA, bytes32[] memory arrB, string memory message) internal returns (bool result) { 1061 return AssertBytes32Array.equal(arrA, arrB, message); 1062 } 1063 1064 /* 1065 Function: notEqual(bytes32[]) 1066 1067 Assert that two 'bytes32[]' are not equal. 1068 1069 : arrA.length != arrB.length 1070 1071 or, for some valid index 'i' 1072 1073 : arrA[i] != arrB[i] 1074 1075 Params: 1076 A (bytes32[]) - The first string. 1077 B (bytes32[]) - The second string. 1078 message (string) - A message that is sent if the assertion fails. 1079 1080 Returns: 1081 result (bool) - The result. 1082 */ 1083 function notEqual(bytes32[] memory arrA, bytes32[] memory arrB, string memory message) internal returns (bool result) { 1084 return AssertBytes32Array.notEqual(arrA, arrB, message); 1085 } 1086 1087 /* 1088 Function: lengthEqual(bytes32[]) 1089 1090 Assert that the length of an 'bytes32[]' is equal to a given value. 1091 1092 : arr.length == length 1093 1094 Params: 1095 arr (bytes32[]) - The array. 1096 length (uint) - The length. 1097 message (string) - A message that is sent if the assertion fails. 1098 1099 Returns: 1100 result (bool) - The result. 1101 */ 1102 function lengthEqual(bytes32[] memory arr, uint length, string memory message) internal returns (bool result) { 1103 return AssertBytes32Array.lengthEqual(arr, length, message); 1104 } 1105 1106 /* 1107 Function: lengthNotEqual(bytes32[]) 1108 1109 Assert that the length of an 'bytes32[]' is not equal to a given value. 1110 1111 : arr.length != length 1112 1113 Params: 1114 arr (bytes32[]) - The array. 1115 length (uint) - The length. 1116 message (string) - A message that is sent if the assertion fails. 1117 1118 Returns: 1119 result (bool) - The result. 1120 */ 1121 function lengthNotEqual(bytes32[] memory arr, uint length, string memory message) internal returns (bool result) { 1122 return AssertBytes32Array.lengthNotEqual(arr, length, message); 1123 } 1124 1125 // ************************************** balances ************************************** 1126 1127 /* 1128 Function: balanceEqual 1129 1130 Assert that the balance of an account 'A' is equal to a given number 'b'. 1131 1132 : A.balance = b 1133 1134 Params: 1135 A (address) - The first address. 1136 b (uint) - The balance. 1137 message (string) - A message that is sent if the assertion fails. 1138 1139 Returns: 1140 result (bool) - The result. 1141 */ 1142 function balanceEqual(address a, uint b, string memory message) internal returns (bool result) { 1143 return AssertBalance.balanceEqual(a, b, message); 1144 } 1145 1146 /* 1147 Function: balanceNotEqual 1148 1149 Assert that the balance of an account 'A' is not equal to a given number 'b'. 1150 1151 : A.balance != b 1152 1153 Params: 1154 A (address) - The first address. 1155 b (uint) - The balance. 1156 message (string) - A message that is sent if the assertion fails. 1157 1158 Returns: 1159 result (bool) - The result. 1160 */ 1161 function balanceNotEqual(address a, uint b, string memory message) internal returns (bool result) { 1162 return AssertBalance.balanceNotEqual(a, b, message); 1163 } 1164 1165 /* 1166 Function: balanceIsZero 1167 1168 Assert that the balance of an account 'A' is zero. 1169 1170 : A.balance == 0 1171 1172 Params: 1173 A (address) - The first address. 1174 message (string) - A message that is sent if the assertion fails. 1175 1176 Returns: 1177 result (bool) - The result. 1178 */ 1179 function balanceIsZero(address a, string memory message) internal returns (bool result) { 1180 return AssertBalance.balanceIsZero(a, message); 1181 } 1182 1183 /* 1184 Function: balanceIsNotZero 1185 1186 Assert that the balance of an account 'A' is not zero. 1187 1188 : A.balance != 0 1189 1190 Params: 1191 A (address) - The first address. 1192 message (string) - A message that is sent if the assertion fails. 1193 1194 Returns: 1195 result (bool) - The result. 1196 */ 1197 function balanceIsNotZero(address a, string memory message) internal returns (bool result) { 1198 return AssertBalance.balanceIsNotZero(a, message); 1199 } 1200 }