Advertisement
193030

01. Google test Framework

Dec 14th, 2021
1,164
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None
  1. // Assert gives fatal error
  2. // Expect doesn't give fatal error, the program continues
  3. #include "pch.h"
  4. #include <math.h>
  5. #include "gtest/gtest.h"
  6. float a = 50.3321;
  7. double squareRoot(const double a)
  8. {
  9.     return sqrt(a);
  10. }
  11.  
  12. TEST(TestName, Subset1) {
  13.     EXPECT_EQ(18.0, squareRoot(324.0));
  14.     EXPECT_EQ(25.4, squareRoot(645.16));
  15.     //EXPECT_DOUBLE_EQ(50.3321, a); // if false the program continues  
  16.     ASSERT_EQ(18.0, squareRoot(324.0));
  17. }
  18.  
  19. TEST(TestName2, Subset2)
  20. {
  21.     EXPECT_GT(10, 2);
  22.     ASSERT_GT(10, 22);
  23.     EXPECT_LT(2, 10);
  24. }
  25.  
  26. TEST(SquareRootTest, ZeroAndNegativeNos) {
  27.     ASSERT_EQ(0.0, squareRoot(0.0));
  28. }
Advertisement
RAW Paste Data Copied
Advertisement