@@ -102,7 +102,7 @@ group
102102 }
103103}
104104
105- func TestUnifiedDiff ( t * testing. T ) {
105+ func ExampleGetUnifiedDiffString ( ) {
106106 a := `one
107107two
108108three
@@ -120,27 +120,20 @@ four`
120120 ToDate : "2010-04-02 10:20:52" ,
121121 Context : 3 ,
122122 }
123- result , err := GetUnifiedDiffString (diff )
124- if err != nil {
125- t .Errorf ("unified diff failed: %s" , err )
126- }
127- expected := `--- Original\t2005-01-26 23:30:50
128- +++ Current\t2010-04-02 10:20:52
129- @@ -1,4 +1,4 @@
130- +zero
131- one
132- -two
133- three
134- four
135- `
136- // TABs are a pain to preserve through editors
137- expected = strings .Replace (expected , "\\ t" , "\t " , - 1 )
138- if expected != result {
139- t .Errorf ("unexpected diff result:\n %s" , result )
140- }
123+ result , _ := GetUnifiedDiffString (diff )
124+ fmt .Printf (strings .Replace (result , "\t " , " " , - 1 ))
125+ // Output:
126+ // --- Original 2005-01-26 23:30:50
127+ // +++ Current 2010-04-02 10:20:52
128+ // @@ -1,4 +1,4 @@
129+ // +zero
130+ // one
131+ // -two
132+ // three
133+ // four
141134}
142135
143- func TestContextDiff ( t * testing. T ) {
136+ func ExampleGetContextDiffString ( ) {
144137 a := `one
145138two
146139three
@@ -157,27 +150,22 @@ four`
157150 Context : 3 ,
158151 Eol : "\n " ,
159152 }
160- result , err := GetContextDiffString (diff )
161- assertEqual (t , err , nil )
162- expected := `*** Original
163- --- Current
164- ***************
165- *** 1,4 ****
166- one
167- ! two
168- ! three
169- four
170- --- 1,4 ----
171- + zero
172- one
173- ! tree
174- four
175- `
176- // TABs are a pain to preserve through editors
177- expected = strings .Replace (expected , "\\ t" , "\t " , - 1 )
178- if expected != result {
179- t .Errorf ("unexpected diff result:\n %s" , result )
180- }
153+ result , _ := GetContextDiffString (diff )
154+ fmt .Printf (strings .Replace (result , "\t " , " " , - 1 ))
155+ // Output:
156+ // *** Original
157+ // --- Current
158+ // ***************
159+ // *** 1,4 ****
160+ // one
161+ // ! two
162+ // ! three
163+ // four
164+ // --- 1,4 ----
165+ // + zero
166+ // one
167+ // ! tree
168+ // four
181169}
182170
183171func rep (s string , count int ) string {
0 commit comments