IonutCava

Unit testing

Apr 12th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. The test:
  2.  const stringImpl input1("2");
  3.  const stringImpl input2("b");
  4.  CHECK_TRUE(Util::IsNumber(input1));
  5.  CHECK_FALSE(Util::IsNumber(input2));
  6.  
  7. The "new macros" (quick hack):
  8.     #define CHECK_TRUE(exp) if (!(exp)) return Error("( " #exp " ) == true")
  9.     #define CHECK_FALSE(exp) if (exp) return Error("( " #exp " ) == false")
  10.     #define CHECK_EQUAL(exp, value) if (exp != value) return Error("( " #exp " ) == ( " #value " )")
  11.     #define CHECK_NOT_EQUAL(exp, value) if (exp == value) return Error("( " #exp " ) != ( " #value " )")
  12.  
  13. The new Error() :
  14.     I32 Error(const char* errString) {
  15.         printf("Error: %s\n", errString);
  16.         return GENERAL_ERROR;
  17.     }
  18.  
  19. Now I can actually see what test actually failed by searching for the expression as a simple string search
Advertisement
Add Comment
Please, Sign In to add comment