X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=googletest%2Fsamples%2Fsample5_unittest.cc;fp=samples%2Fsample5_unittest.cc;h=0a21dd2157707fb32c459248b0c5341609ec0614;hb=e7b4c00007893a03bd18ec50f004b1031e3d635b;hp=43d8e5777583ec4be01089c99795b90b73ef4f4c;hpb=13373a8d7eeda1773ad1a2a28daf0a608b3830cf;p=platform%2Fupstream%2Fgtest.git diff --git a/samples/sample5_unittest.cc b/googletest/samples/sample5_unittest.cc old mode 100755 new mode 100644 similarity index 95% rename from samples/sample5_unittest.cc rename to googletest/samples/sample5_unittest.cc index 43d8e57..0a21dd2 --- a/samples/sample5_unittest.cc +++ b/googletest/samples/sample5_unittest.cc @@ -26,8 +26,7 @@ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Author: wan@google.com (Zhanyong Wan) + // This sample teaches how to reuse a test fixture in multiple test // cases by deriving sub-fixtures from it. @@ -46,10 +45,10 @@ #include #include -#include "sample3-inl.h" #include "gtest/gtest.h" #include "sample1.h" - +#include "sample3-inl.h" +namespace { // In this sample, we want to ensure that every test finishes within // ~5 seconds. If a test takes longer to run, we consider it a // failure. @@ -64,15 +63,13 @@ class QuickTest : public testing::Test { protected: // Remember that SetUp() is run immediately before a test starts. // This is a good place to record the start time. - virtual void SetUp() { - start_time_ = time(NULL); - } + void SetUp() override { start_time_ = time(nullptr); } // TearDown() is invoked immediately after a test finishes. Here we // check if the test was too slow. - virtual void TearDown() { + void TearDown() override { // Gets the time when the test finishes - const time_t end_time = time(NULL); + const time_t end_time = time(nullptr); // Asserts that the test took no more than ~5 seconds. Did you // know that you can use assertions in SetUp() and TearDown() as @@ -143,7 +140,7 @@ TEST_F(IntegerFunctionTest, IsPrime) { // stuff inside the body of the test fixture, as usual. class QueueTest : public QuickTest { protected: - virtual void SetUp() { + void SetUp() override { // First, we need to set up the super fixture (QuickTest). QuickTest::SetUp(); @@ -177,21 +174,21 @@ TEST_F(QueueTest, DefaultConstructor) { // Tests Dequeue(). TEST_F(QueueTest, Dequeue) { int* n = q0_.Dequeue(); - EXPECT_TRUE(n == NULL); + EXPECT_TRUE(n == nullptr); n = q1_.Dequeue(); - EXPECT_TRUE(n != NULL); + EXPECT_TRUE(n != nullptr); EXPECT_EQ(1, *n); EXPECT_EQ(0u, q1_.Size()); delete n; n = q2_.Dequeue(); - EXPECT_TRUE(n != NULL); + EXPECT_TRUE(n != nullptr); EXPECT_EQ(2, *n); EXPECT_EQ(1u, q2_.Size()); delete n; } - +} // namespace // If necessary, you can derive further test fixtures from a derived // fixture itself. For example, you can derive another fixture from // QueueTest. Google Test imposes no limit on how deep the hierarchy