Last active
July 30, 2017 14:05
-
-
Save OPhamster/b7b68092eec8b1d37bfff8f3296d7633 to your computer and use it in GitHub Desktop.
Code to test check_positive.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "check_positive.h" | |
| #include "gtest/gtest.h" | |
| // Test to see if this function succeeds with positive integers | |
| // TEST is a macro to define and name a test function - and they do not return values | |
| // You can include and C++ code here along with GoogleTest assertions that you want to make | |
| // --- Signature ---- // | |
| // TEST(test_case_name,test_name){ | |
| // test body | |
| // } | |
| // --- Signature End ---- // | |
| // The first test we make is for positive integers where this function should return a bool true | |
| TEST(FunctionTest,PositiveInt){ | |
| // here we pass values to the function and test for what we EXPECT (non-fatal test) | |
| // or ASSERT (fatal) values | |
| ASSERT_TRUE(check_if_positive(1)); | |
| ASSERT_TRUE(check_if_positive(450)); | |
| ASSERT_TRUE(check_if_positive(521)); | |
| } | |
| // The second test we make is for zero where this function should return a bool false | |
| TEST(FunctionTest,Zero){ | |
| // here we pass values to the function and test for what we EXPECT (non-fatal test) | |
| // or ASSERT (fatal) values | |
| ASSERT_FALSE(check_if_positive(0)); | |
| } | |
| // The third test we make is for zero where this function should return a bool false | |
| TEST(FunctionTest,NegativeInt){ | |
| // here we pass values to the function and test for what we EXPECT (non-fatal test) | |
| // or ASSERT (fatal) values | |
| ASSERT_FALSE(check_if_positive(-1)); | |
| ASSERT_FALSE(check_if_positive(-951)); | |
| ASSERT_FALSE(check_if_positive(-51)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment