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

Side by Side 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: Change indentation Created 3 years, 11 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import unittest
6
7 from webkitpy.common.unified_diff import unified_diff
8
9
10 class TestUnifiedDiff(unittest.TestCase):
11
12 def test_unified_diff(self):
13 self.assertEqual(
14 unified_diff('foo\n', 'bar\n', 'exp.txt', 'act.txt'),
15 '--- exp.txt\n+++ act.txt\n@@ -1 +1 @@\n-foo\n+bar\n')
16
17 def test_unified_diff_missing_newline(self):
18 self.assertEqual(
19 unified_diff('Hello\n\nWorld', 'Hello\n\nWorld\n\n\n', 'exp.txt', 'a ct.txt'),
20 '--- 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')
21
22 def test_unified_diff_handles_unicode_file_names(self):
23 # Make sure that we don't run into decoding exceptions when the
24 # filenames are unicode, with regular or malformed input (expected or
25 # actual input is always raw bytes, not unicode).
26 unified_diff('exp', 'act', 'exp.txt', 'act.txt')
27 unified_diff('exp', 'act', u'exp.txt', 'act.txt')
28 unified_diff('exp', 'act', u'a\xac\u1234\u20ac\U00008000', 'act.txt')
29
30 def test_unified_diff_handles_non_ascii_chars(self):
31 unified_diff('exp' + chr(255), 'act', 'exp.txt', 'act.txt')
32 unified_diff('exp' + chr(255), 'act', u'exp.txt', 'act.txt')
33
34 def test_unified_diff_handles_unicode_inputs(self):
35 # Though expected and actual files should always be read in with no
36 # encoding (and be stored as str objects), test unicode inputs just to
37 # be safe.
38 unified_diff(u'exp', 'act', 'exp.txt', 'act.txt')
39 unified_diff(u'a\xac\u1234\u20ac\U00008000', 'act', 'exp.txt', 'act.txt' )
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698