aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 14:48:54 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 16:20:41 +0000
commit9f3df893fd9f9cd52995b2f2d7a430eb912a4361 (patch)
treec047fa1ce89ea2553a6c6720a510de803e6eb0b6
parentdee89676dae34819b82faebf2553460bd76260da (diff)
downloadpaludis-9f3df893fd9f9cd52995b2f2d7a430eb912a4361.tar.gz
paludis-9f3df893fd9f9cd52995b2f2d7a430eb912a4361.tar.xz
gtest more
-rw-r--r--paludis/util/files.m42
-rw-r--r--paludis/util/save_TEST.cc72
2 files changed, 30 insertions, 44 deletions
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 47cd2a1..43baca6 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -71,7 +71,7 @@ add(`return_literal_function', `hh', `cc', `fwd', `test')
add(`rmd160', `hh', `cc', `test')
add(`safe_ifstream', `hh', `cc', `fwd', `test', `testscript')
add(`safe_ofstream', `hh', `cc', `test', `testscript')
-add(`save', `hh', `test')
+add(`save', `hh', `gtest')
add(`sequence', `hh', `fwd', `impl', `cc')
add(`set', `hh', `fwd', `impl', `cc')
add(`sha1', `hh', `cc', `gtest')
diff --git a/paludis/util/save_TEST.cc b/paludis/util/save_TEST.cc
index d63bed6..7e4e03d 100644
--- a/paludis/util/save_TEST.cc
+++ b/paludis/util/save_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2011 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -18,56 +18,42 @@
*/
#include <paludis/util/save.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-using namespace test;
+#include <gtest/gtest.h>
+
using namespace paludis;
-namespace test_cases
+TEST(Save, Works)
{
- struct SaveTest : TestCase
+ std::string s("one");
+ EXPECT_EQ("one", s);
{
- SaveTest() : TestCase("save") { }
-
- void run()
+ Save<std::string> save_s(&s);
+ EXPECT_EQ("one", s);
+ s = "two";
+ EXPECT_EQ("two", s);
+ }
+ EXPECT_EQ("one", s);
+ {
+ Save<std::string> save_s(&s, "three");
+ EXPECT_EQ("three", s);
{
- std::string s("one");
- TEST_CHECK_EQUAL(s, "one");
- {
- Save<std::string> save_s(&s);
- TEST_CHECK_EQUAL(s, "one");
- s = "two";
- TEST_CHECK_EQUAL(s, "two");
- }
- TEST_CHECK_EQUAL(s, "one");
- {
- Save<std::string> save_s(&s, "three");
- TEST_CHECK_EQUAL(s, "three");
- {
- Save<std::string> save_s_2(&s, "four");
- TEST_CHECK_EQUAL(s, "four");
- }
- TEST_CHECK_EQUAL(s, "three");
- }
- TEST_CHECK_EQUAL(s, "one");
+ Save<std::string> save_s_2(&s, "four");
+ EXPECT_EQ("four", s);
}
- } test_save;
+ EXPECT_EQ("three", s);
+ }
+ EXPECT_EQ("one", s);
+}
- struct RunOnDestructionTest : TestCase
+TEST(RunOnDestruction, Works)
+{
+ std::string s("one");
+ EXPECT_EQ("one", s);
{
- RunOnDestructionTest() : TestCase("run on destruction") { }
-
- void run()
- {
- std::string s("one");
- TEST_CHECK_EQUAL(s, "one");
- {
- RunOnDestruction save_s(std::bind(&std::string::clear, &s));
- TEST_CHECK_EQUAL(s, "one");
- }
- TEST_CHECK_EQUAL(s, "");
- }
- } test_run_on_destruction;
+ RunOnDestruction save_s(std::bind(&std::string::clear, &s));
+ EXPECT_EQ("one", s);
+ }
+ EXPECT_EQ("", s);
}