Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 86
- Log:
Initial import of I2, an Instiki clone.
- Author:
- adh
- Date:
- Mon Oct 16 10:40:36 +0100 2006
- Size:
- 2479 Bytes
1 | require File.join(File.dirname(__FILE__), 'test_helper') |
2 | |
3 | class DiffTest < Test::Unit::TestCase |
4 | def test_init |
5 | assert_nothing_raised { |
6 | s = SequenceMatcher.new('private Thread currentThread;', |
7 | 'private volatile Thread currentThread;') { |x| x == ' ' } |
8 | } |
9 | end |
10 | |
11 | def test_matching_blocks |
12 | s = SequenceMatcher.new 'abxcd', 'abcd' |
13 | assert_equal [[0, 0, 2], [3, 2, 2], [5, 4, 0]], s.get_matching_blocks |
14 | end |
15 | |
16 | def test_ratio |
17 | s = SequenceMatcher.new 'abcd', 'bcde' |
18 | assert_equal 0.75, s.ratio, 0.001 |
19 | assert_equal 0.75, s.quick_ratio, 0.001 |
20 | assert_equal 1.0, s.real_quick_ratio, 0.001 |
21 | end |
22 | |
23 | def test_longest_match |
24 | s = SequenceMatcher.new(' abcd', 'abcd abcd') |
25 | assert_equal [0, 4, 5], s.find_longest_match(0, 5, 0, 9) |
26 | end |
27 | |
28 | def test_opcodes |
29 | s = SequenceMatcher.new('qabxcd', 'abycdf') |
30 | assert_equal( |
31 | [ |
32 | [:delete, 0, 1, 0, 0], |
33 | [:equal, 1, 3, 0, 2], |
34 | [:replace, 3, 4, 2, 3], |
35 | [:equal, 4, 6, 3, 5], |
36 | [:insert, 6, 6, 5, 6] |
37 | ], |
38 | s.get_opcodes) |
39 | end |
40 | |
41 | |
42 | def test_count_leading |
43 | assert_equal 3, Diff.count_leading(' abc', ' ') |
44 | end |
45 | |
46 | def test_html2list |
47 | a = "here is the original text" |
48 | assert_equal( |
49 | ['here ', 'is ', 'the ', 'original ', 'text'], |
50 | HTMLDiff.html2list(a)) |
51 | end |
52 | |
53 | def test_html_diff |
54 | a = 'this was the original string' |
55 | b = 'this is the super string' |
56 | assert_equal('this <del class="diffmod">was </del>' + |
57 | '<ins class="diffmod">is </ins>the ' + |
58 | '<del class="diffmod">original </del>' + |
59 | '<ins class="diffmod">super </ins>string', |
60 | HTMLDiff.diff(a, b)) |
61 | end |
62 | |
63 | def test_html_diff_with_multiple_paragraphs |
64 | a = "<p>this was the original string</p>" |
65 | b = "<p>this is</p>\r\n<p>the super string</p>\r\n<p>around the world</p>" |
66 | |
67 | assert_equal( |
68 | "<p>this <del class=\"diffmod\">was </del>" + |
69 | "<ins class=\"diffmod\">is</ins></p>\r\n<p>the " + |
70 | "<del class=\"diffmod\">original </del>" + |
71 | "<ins class=\"diffmod\">super </ins>string</p>\r\n" + |
72 | "<p><ins class=\"diffins\">around the world</ins></p>", |
73 | HTMLDiff.diff(a, b) |
74 | ) |
75 | end |
76 | |
77 | # FIXME this test fails (ticket #67, http://dev.instiki.org/ticket/67) |
78 | def test_html_diff_preserves_endlines_in_pre |
79 | a = "<pre>\na\nb\nc\n</pre>" |
80 | b = '' |
81 | |
82 | assert_equal( |
83 | "<pre>\n<del class=\"diffdel\">a\nb\nc\n</del></pre>", |
84 | HTMLDiff.diff(a, b)) |
85 | end |
86 | |
87 | end |