pabloliva87

Ej1C++

Mar 20th, 2012
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cstdlib>
  2. #include <iostream>
  3.  
  4. #include "gtest/gtest.h"
  5. #include "gmock/gmock.h"
  6.  
  7. using namespace std;
  8.  
  9. void inc (int& val);
  10.  
  11. int main (int argc, char** argv)
  12. {
  13.    
  14.     int i;
  15.    
  16.     i = 0;
  17.    
  18.     cout << "Antes: " << i << endl;
  19.    
  20.     inc(i);
  21.    
  22.     cout << "Despues: " << i << endl;
  23.    
  24.     /* We run the tests defined below */
  25.     ::testing::InitGoogleTest(&argc, argv);
  26.     return RUN_ALL_TESTS();
  27. }
  28.  
  29. void inc (int& val)
  30. {
  31.     ++val;
  32. }
  33.  
  34. /* Tests */
  35.  
  36. // Tests that inc works correctly
  37. TEST(IncTest, WorksCorrectly)
  38. {
  39.     int i = 0;
  40.     inc(i);
  41.     EXPECT_EQ(1, i);
  42.     inc(i);
  43.     EXPECT_EQ(2, i);
  44.     inc(i);
  45.     EXPECT_FALSE((10) == (i));
  46. }
Add Comment
Please, Sign In to add comment