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

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/unified_diff_unittest.py

Issue 2595983002: Extract diff_text function out of the Port class. (Closed)
Patch Set: Rebased Created 4 years 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
Index: third_party/WebKit/Tools/Scripts/webkitpy/common/unified_diff_unittest.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/common/unified_diff_unittest.py b/third_party/WebKit/Tools/Scripts/webkitpy/common/unified_diff_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..48e00bcccbb3ae85be94de114e52db0365f15e5a
--- /dev/null
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/common/unified_diff_unittest.py
@@ -0,0 +1,40 @@
+# Copyright 2016 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.
+
+import unittest
+
+from webkitpy.common.unified_diff import unified_diff
+
+
+class TestUnifiedDiff(unittest.TestCase):
+
+ def test_unified_diff(self):
+ self.assertEqual(
+ unified_diff('foo\n', 'bar\n', 'exp.txt', 'act.txt'),
+ '--- exp.txt\n+++ act.txt\n@@ -1 +1 @@\n-foo\n+bar\n')
+
+ def test_unified_diff_missing_newline(self):
+ self.assertEqual(
+ unified_diff('Hello\n\nWorld', 'Hello\n\nWorld\n\n\n', 'exp.txt', 'act.txt'),
+ '--- exp.txt\n+++ act.txt\n@@ -1,3 +1,5 @@\n Hello\n \n-World\n\\ No newline at end of file\n+World\n+\n+\n')
jeffcarp 2017/01/11 21:46:49 This indentation format looks inconsistent to line
qyearsley 2017/01/11 22:24:02 Hm, yeah. In both cases there's a 4-space indent a
+
+ def test_unified_diff_handles_unicode_file_names(self):
+ # Make sure that we don't run into decoding exceptions when the
+ # filenames are unicode, with regular or malformed input (expected or
+ # actual input is always raw bytes, not unicode).
+ unified_diff('exp', 'act', 'exp.txt', 'act.txt')
+ unified_diff('exp', 'act', u'exp.txt', 'act.txt')
+ unified_diff('exp', 'act', u'a\xac\u1234\u20ac\U00008000', 'act.txt')
+
+ def test_unified_diff_handles_non_ascii_chars(self):
+ unified_diff('exp' + chr(255), 'act', 'exp.txt', 'act.txt')
+ unified_diff('exp' + chr(255), 'act', u'exp.txt', 'act.txt')
+
+ def test_unified_diff_handles_unicode_inputs(self):
+ # Though expected and actual files should always be read in with no
+ # encoding (and be stored as str objects), test unicode inputs just to
+ # be safe.
+ unified_diff(u'exp', 'act', 'exp.txt', 'act.txt')
+ unified_diff(
+ u'a\xac\u1234\u20ac\U00008000', 'act', 'exp.txt', 'act.txt')

Powered by Google App Engine
This is Rietveld 408576698