Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(652)

Unified Diff: third_party/courgette/difference_estimator_unittest.cc

Issue 113009: Move Courgette from internal depot to third_party. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/courgette/difference_estimator.cc ('k') | third_party/courgette/disassembler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/courgette/difference_estimator_unittest.cc
===================================================================
--- third_party/courgette/difference_estimator_unittest.cc (revision 0)
+++ third_party/courgette/difference_estimator_unittest.cc (revision 0)
@@ -0,0 +1,58 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "third_party/courgette/difference_estimator.h"
+
+#include <string>
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/courgette/region.h"
+
+using courgette::DifferenceEstimator;
+using courgette::Region;
+
+TEST(DifferenceEstimatorTest, TestSame) {
+ static const char kString1[] = "Hello world";
+ // kString2 is stack allocated to prevent string sharing.
+ const char kString2[] = "Hello world";
+ DifferenceEstimator difference_estimator;
+ DifferenceEstimator::Base* base =
+ difference_estimator.MakeBase(Region(kString1, sizeof(kString1)));
+ DifferenceEstimator::Subject* subject =
+ difference_estimator.MakeSubject(Region(kString2, sizeof(kString2)));
+ EXPECT_EQ(0, difference_estimator.Measure(base, subject));
+}
+
+TEST(DifferenceEstimatorTest, TestDifferent) {
+ static const char kString1[] = "Hello world";
+ static const char kString2[] = "Hello universe";
+ DifferenceEstimator difference_estimator;
+ DifferenceEstimator::Base* base =
+ difference_estimator.MakeBase(Region(kString1, sizeof(kString1)));
+ DifferenceEstimator::Subject* subject =
+ difference_estimator.MakeSubject(Region(kString2, sizeof(kString2)));
+ EXPECT_EQ(10, difference_estimator.Measure(base, subject));
+}
+
+TEST(DifferenceEstimatorTest, TestDifferentSuperstring) {
+ static const char kString1[] = "abcdabcdabcd";
+ static const char kString2[] = "abcdabcdabcdabcd";
+ DifferenceEstimator difference_estimator;
+ DifferenceEstimator::Base* base =
+ difference_estimator.MakeBase(Region(kString1, sizeof(kString1)-1));
+ DifferenceEstimator::Subject* subject =
+ difference_estimator.MakeSubject(Region(kString2, sizeof(kString2)-1));
+ EXPECT_EQ(1, difference_estimator.Measure(base, subject));
+}
+
+TEST(DifferenceEstimatorTest, TestDifferentSubstring) {
+ static const char kString1[] = "abcdabcdabcdabcd";
+ static const char kString2[] = "abcdabcdabcd";
+ DifferenceEstimator difference_estimator;
+ DifferenceEstimator::Base* base =
+ difference_estimator.MakeBase(Region(kString1, sizeof(kString1)-1));
+ DifferenceEstimator::Subject* subject =
+ difference_estimator.MakeSubject(Region(kString2, sizeof(kString2)-1));
+ EXPECT_EQ(1, difference_estimator.Measure(base, subject));
+}
« no previous file with comments | « third_party/courgette/difference_estimator.cc ('k') | third_party/courgette/disassembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698