aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 19:48:13 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-20 19:48:13 +0000
commit6c450b30438db98c1dea5cdfb1ac6b17c6af67f5 (patch)
tree5322187fc3c6668af21cb89711fd4ef0c6770e64
parenteb6364b998f77682c5ec09fcdb5c788ca399a1e9 (diff)
downloadpaludis-6c450b30438db98c1dea5cdfb1ac6b17c6af67f5.tar.gz
paludis-6c450b30438db98c1dea5cdfb1ac6b17c6af67f5.tar.xz
gtest more
-rw-r--r--paludis/util/damerau_levenshtein_TEST.cc56
-rw-r--r--paludis/util/files.m42
2 files changed, 22 insertions, 36 deletions
diff --git a/paludis/util/damerau_levenshtein_TEST.cc b/paludis/util/damerau_levenshtein_TEST.cc
index fc67b18..608d084 100644
--- a/paludis/util/damerau_levenshtein_TEST.cc
+++ b/paludis/util/damerau_levenshtein_TEST.cc
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2007 Fernando J. Pereda
+ * Copyright (c) 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,43 +19,28 @@
*/
#include <paludis/util/damerau_levenshtein.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-using namespace paludis;
-using namespace test;
+#include <gtest/gtest.h>
-/** \file
- * Test cases for damerau_levenshtein.hh
- */
+using namespace paludis;
-namespace test_cases
+TEST(DamerauLevenshtein, Distance)
{
- /**
- * \test Test DamerauLevenshtain methods
- */
- struct DamerauLevenshteinTest : TestCase
- {
- DamerauLevenshteinTest() : TestCase("Damerau-Levenshtein distance") {}
-
- void run()
- {
- DamerauLevenshtein dl("foo");
-
- TEST_CHECK_EQUAL(dl.distance_with("foo"), 0u);
- TEST_CHECK_EQUAL(dl.distance_with("foo1"), 1u);
- TEST_CHECK_EQUAL(dl.distance_with("fo"), 1u);
- TEST_CHECK_EQUAL(dl.distance_with("fao"), 1u);
- TEST_CHECK_EQUAL(dl.distance_with("ofo"), 1u);
- TEST_CHECK_EQUAL(dl.distance_with("fie"), 2u);
- TEST_CHECK_EQUAL(dl.distance_with("ife"), 3u);
- TEST_CHECK_EQUAL(dl.distance_with("bar"), 3u);
- TEST_CHECK_EQUAL(dl.distance_with(""), 3u);
-
- DamerauLevenshtein de("");
-
- TEST_CHECK_EQUAL(de.distance_with("foo"), 3u);
- TEST_CHECK_EQUAL(de.distance_with(""), 0u);
- }
- } test_damerau_levenshtein_test;
+ DamerauLevenshtein dl("foo");
+
+ EXPECT_EQ(0u, dl.distance_with("foo"));
+ EXPECT_EQ(1u, dl.distance_with("foo1"));
+ EXPECT_EQ(1u, dl.distance_with("fo"));
+ EXPECT_EQ(1u, dl.distance_with("fao"));
+ EXPECT_EQ(1u, dl.distance_with("ofo"));
+ EXPECT_EQ(2u, dl.distance_with("fie"));
+ EXPECT_EQ(3u, dl.distance_with("ife"));
+ EXPECT_EQ(3u, dl.distance_with("bar"));
+ EXPECT_EQ(3u, dl.distance_with(""));
+
+ DamerauLevenshtein de("");
+
+ EXPECT_EQ(3u, de.distance_with("foo"));
+ EXPECT_EQ(0u, de.distance_with(""));
}
+
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 6152149..c5b8c3f 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -21,7 +21,7 @@ add(`config_file', `hh', `cc', `fwd', `se', `test', `tests
add(`condition_variable', `hh', `cc', `test')
add(`cookie', `hh', `cc')
add(`create_iterator', `hh', `fwd', `impl', `test')
-add(`damerau_levenshtein', `hh', `cc', `test')
+add(`damerau_levenshtein', `hh', `cc', `gtest')
add(`destringify', `hh', `cc', `gtest')
add(`deferred_construction_ptr', `hh', `cc', `fwd', `gtest')
add(`discard_output_stream', `hh', `cc')