OLD | NEW |
---|---|
(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') | |
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
| |
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( | |
40 u'a\xac\u1234\u20ac\U00008000', 'act', 'exp.txt', 'act.txt') | |
OLD | NEW |