def test_add_empty_text(self): lines = ['diff --git a/text-zero.txt b/text-zero.txt', 'new file mode 100644', 'index 0000000..e69de29'] diff, remaining_lines = DiffFile.parse(lines) self.assertIsNotNone(diff) self.assertEquals(remaining_lines, []) self._assert_file_status(diff, 'A')
def test_remove_zero_byte_text(self): lines = ['diff --git a/text-zero.txt b/text-zero.txt', 'deleted file mode 100644', 'index e69de29..0000000'] diff, remaining_lines = DiffFile.parse(lines) self.assertIsNotNone(diff) self.assertEquals(remaining_lines, []) self._assert_file_status(diff, 'D')
def test_emptify_binary(self): lines = [ 'diff --git a/binary-to-zero.png b/binary-to-zero.png', 'index 9b56f1c6942441578b0585d8b9688fdfcb2aa3fd..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644', 'GIT binary patch', 'literal 0', 'HcmV?d00001', '', 'literal 6', 'NcmZSh&&2%iKL7{~0|Ed5', '' ] diff, remaining_lines = DiffFile.parse(lines) self.assertIsNotNone(diff) self.assertEquals(remaining_lines, []) self._assert_file_status(diff, 'M')
def test_remove_text(self): lines = [ 'diff --git a/text-to-be-removed.txt b/text-to-be-removed.txt', 'deleted file mode 100644', 'index 2262de0..0000000', '--- a/text-to-be-removed.txt', '+++ /dev/null', '@@ -1 +0,0 @@', '-hoge' ] diff, remaining_lines = DiffFile.parse(lines) self.assertIsNotNone(diff) self.assertEquals(remaining_lines, []) self._assert_file_status(diff, 'D')
def test_emptify_text(self): lines = ['diff --git a/third_party/blink/text-to-zero.txt b/third_party/blink/text-to-zero.txt', 'index 2262de0..e69de29 100644', '--- a/third_party/blink/text-to-zero.txt', '+++ b/third_party/blink/text-to-zero.txt', '@@ -1 +0,0 @@', '-hoge'] diff, remaining_lines = DiffFile.parse(lines) self.assertIsNotNone(diff) self.assertEquals(remaining_lines, []) self._assert_file_status(diff, 'M')
def test_100percent_similarity(self): # crrev.com/c576df77d72abe47154ff2489bb035aa20892f7f lines = ['diff --git a/platform/modules/offscreencanvas/OWNERS b/platform/modules/frame_sinks/OWNERS', 'similarity index 100%', 'rename from platform/modules/offscreencanvas/OWNERS', 'rename to platform/modules/frame_sinks/OWNERS', 'diff --git a/platform/modules/frame_sinks/embedded_frame_sink.mojom ' + 'b/platform/modules/frame_sinks/embedded_frame_sink.mojom'] diff, remaining_lines = DiffFile.parse(lines) self.assertIsNotNone(diff) self.assertEquals(remaining_lines[0], lines[4])
def test_remove_binary(self): lines = [ 'diff --git a/binary-to-be-removed.png b/binary-to-be-removed.png', 'deleted file mode 100644', 'index 9b56f1c6942441578b0585d8b9688fdfcb2aa3fd..0000000000000000000000000000000000000000', 'GIT binary patch', 'literal 0', 'HcmV?d00001', '', 'literal 6', 'NcmZSh&&2%iKL7{~0|Ed5', '' ] diff, remaining_lines = DiffFile.parse(lines) self.assertIsNotNone(diff) self.assertEquals(remaining_lines, []) self._assert_file_status(diff, 'D')
def test_empty_input(self): lines = [] diff, remaining_lines = DiffFile.parse(lines) self.assertIsNone(diff) self.assertEquals(remaining_lines, [])