"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "googletest/samples/sample1_unittest.cc" between
googletest-release-1.11.0.tar.gz and googletest-release-1.12.0.tar.gz

About: GoogleTest is Google's (unit) testing and mocking framework for C++ tests.

sample1_unittest.cc  (googletest-release-1.11.0):sample1_unittest.cc  (googletest-release-1.12.0)
skipping to change at line 42 skipping to change at line 42
// This sample shows how to write a simple unit test for a function, // This sample shows how to write a simple unit test for a function,
// using Google C++ testing framework. // using Google C++ testing framework.
// //
// Writing a unit test using Google C++ testing framework is easy as 1-2-3: // Writing a unit test using Google C++ testing framework is easy as 1-2-3:
// Step 1. Include necessary header files such that the stuff your // Step 1. Include necessary header files such that the stuff your
// test logic needs is declared. // test logic needs is declared.
// //
// Don't forget gtest.h, which declares the testing framework. // Don't forget gtest.h, which declares the testing framework.
#include <limits.h>
#include "sample1.h" #include "sample1.h"
#include <limits.h>
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace { namespace {
// Step 2. Use the TEST macro to define your tests. // Step 2. Use the TEST macro to define your tests.
// //
// TEST has two parameters: the test case name and the test name. // TEST has two parameters: the test case name and the test name.
// After using the macro, you should define your test logic between a // After using the macro, you should define your test logic between a
// pair of braces. You can use a bunch of macros to indicate the // pair of braces. You can use a bunch of macros to indicate the
// success or failure of a test. EXPECT_TRUE and EXPECT_EQ are // success or failure of a test. EXPECT_TRUE and EXPECT_EQ are
// examples of such macros. For a complete list, see gtest.h. // examples of such macros. For a complete list, see gtest.h.
skipping to change at line 98 skipping to change at line 100
// value when the assertion fails. This is very helpful for // value when the assertion fails. This is very helpful for
// debugging. Therefore in this case EXPECT_EQ is preferred. // debugging. Therefore in this case EXPECT_EQ is preferred.
// //
// On the other hand, EXPECT_TRUE accepts any Boolean expression, // On the other hand, EXPECT_TRUE accepts any Boolean expression,
// and is thus more general. // and is thus more general.
// //
// </TechnicalDetails> // </TechnicalDetails>
} }
// Tests factorial of 0. // Tests factorial of 0.
TEST(FactorialTest, Zero) { TEST(FactorialTest, Zero) { EXPECT_EQ(1, Factorial(0)); }
EXPECT_EQ(1, Factorial(0));
}
// Tests factorial of positive numbers. // Tests factorial of positive numbers.
TEST(FactorialTest, Positive) { TEST(FactorialTest, Positive) {
EXPECT_EQ(1, Factorial(1)); EXPECT_EQ(1, Factorial(1));
EXPECT_EQ(2, Factorial(2)); EXPECT_EQ(2, Factorial(2));
EXPECT_EQ(6, Factorial(3)); EXPECT_EQ(6, Factorial(3));
EXPECT_EQ(40320, Factorial(8)); EXPECT_EQ(40320, Factorial(8));
} }
// Tests IsPrime() // Tests IsPrime()
 End of changes. 3 change blocks. 
4 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)