Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1.  
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. #define TEST(NOMBRE, CUERPO) \
  7. void NOMBRE() { \
  8. string test = #NOMBRE; \
  9. cout << "[ TEST ] " << test << endl; \
  10. { CUERPO } \
  11. cout << "[ OK ] " << test << endl; \
  12. }
  13.  
  14. #define ASSERT_EQ(EXPR, EXPECTED) { \
  15. __typeof__(EXPECTED) expected = (EXPECTED); \
  16. __typeof__(EXPR) obtained = (EXPR); \
  17. if (expected != obtained) { \
  18. cout << "[ MAL ] " << test << endl; \
  19. cout << endl; \
  20. cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; \
  21. cout << "FALLA EL TEST \"" << test << "\"" << endl; \
  22. cout << "Al evaluar:" << endl; \
  23. cout << " " << #EXPR << endl; \
  24. cout << "Se esperaba obtener el valor:" << endl; \
  25. cout << " " << expected << endl; \
  26. cout << "Pero se obtuvo:" << endl; \
  27. cout << " " << obtained << endl; \
  28. cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; \
  29. exit(1); \
  30. } \
  31. }
  32.  
  33. int f() {
  34. return 42;
  35. }
  36.  
  37. TEST(testF, {
  38. ASSERT_EQ(f(), 42);
  39. });
  40.  
  41. int main() {
  42. testF();
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement