gdiff 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/CHANGELOG +7 -0
  2. data/COPYING.suffix_array +278 -0
  3. data/LICENSE.suffix_array +17 -0
  4. data/README +40 -0
  5. data/README.suffix_array +274 -0
  6. data/bin/gdiff +25 -0
  7. data/bin/gpatch +25 -0
  8. data/doc/classes/Diff.html +117 -0
  9. data/doc/classes/Diff/GDiff.html +120 -0
  10. data/doc/classes/Diff/GDiff/EGdiffError.html +111 -0
  11. data/doc/classes/Diff/GDiff/ENoGdiffStream.html +113 -0
  12. data/doc/classes/Diff/GDiff/EPrematureEndOfStream.html +113 -0
  13. data/doc/classes/Diff/GDiff/Operations.html +156 -0
  14. data/doc/classes/Diff/GDiff/Operations/Copy.html +246 -0
  15. data/doc/classes/Diff/GDiff/Operations/Copy.src/M000014.html +19 -0
  16. data/doc/classes/Diff/GDiff/Operations/Copy.src/M000015.html +39 -0
  17. data/doc/classes/Diff/GDiff/Operations/Copy.src/M000016.html +25 -0
  18. data/doc/classes/Diff/GDiff/Operations/Copy.src/M000017.html +18 -0
  19. data/doc/classes/Diff/GDiff/Operations/Data.html +246 -0
  20. data/doc/classes/Diff/GDiff/Operations/Data.src/M000009.html +18 -0
  21. data/doc/classes/Diff/GDiff/Operations/Data.src/M000010.html +18 -0
  22. data/doc/classes/Diff/GDiff/Operations/Data.src/M000011.html +35 -0
  23. data/doc/classes/Diff/GDiff/Operations/Data.src/M000012.html +29 -0
  24. data/doc/classes/Diff/GDiff/Operations/Data.src/M000013.html +19 -0
  25. data/doc/classes/SAError.html +111 -0
  26. data/doc/classes/SuffixArray.html +342 -0
  27. data/doc/classes/SuffixArray.src/M000001.html +97 -0
  28. data/doc/classes/SuffixArray.src/M000002.html +73 -0
  29. data/doc/classes/SuffixArray.src/M000003.html +102 -0
  30. data/doc/classes/SuffixArray.src/M000004.html +47 -0
  31. data/doc/classes/SuffixArray.src/M000005.html +44 -0
  32. data/doc/classes/SuffixArray.src/M000006.html +33 -0
  33. data/doc/classes/SuffixArray.src/M000007.html +24 -0
  34. data/doc/classes/SuffixArray.src/M000008.html +46 -0
  35. data/doc/created.rid +1 -0
  36. data/doc/files/ext/gdiff/suffix_array/extconf_rb.html +108 -0
  37. data/doc/files/ext/gdiff/suffix_array/lcp_c.html +101 -0
  38. data/doc/files/ext/gdiff/suffix_array/sarray_c.html +101 -0
  39. data/doc/files/ext/gdiff/suffix_array/suffix_array_c.html +101 -0
  40. data/doc/files/lib/gdiff_rb.html +108 -0
  41. data/doc/fr_class_index.html +36 -0
  42. data/doc/fr_file_index.html +31 -0
  43. data/doc/fr_method_index.html +43 -0
  44. data/doc/index.html +24 -0
  45. data/doc/rdoc-style.css +208 -0
  46. data/ext/gdiff/COPYING +278 -0
  47. data/ext/gdiff/LICENSE +17 -0
  48. data/ext/gdiff/README +274 -0
  49. data/ext/gdiff/extconf.rb +3 -0
  50. data/ext/gdiff/lcp.c +97 -0
  51. data/ext/gdiff/sarray.3 +145 -0
  52. data/ext/gdiff/sarray.c +372 -0
  53. data/ext/gdiff/sarray.h +13 -0
  54. data/ext/gdiff/suffix_array.c +510 -0
  55. data/lib/gdiff.rb +255 -0
  56. data/setup.rb +1551 -0
  57. data/test/tc_gdiff.rb +66 -0
  58. metadata +119 -0
@@ -0,0 +1,66 @@
1
+ require "gdiff"
2
+ require "test/unit"
3
+
4
+ class TC_GDiff < Test::Unit::TestCase
5
+ def test_random
6
+ sizes = Array.new(10) { | i | (i ** 3 * 99) }
7
+ sizes.each do | size |
8
+ size_difference = rand(size / 2)
9
+ a = Array.new(size ) { rand(0xFF) }.pack("C*")
10
+ b = Array.new(size + size_difference) { rand(0xFF) }.pack("C*")
11
+ diff = Diff::GDiff.diff(a, b)
12
+ assert_equal(b, diff.apply_to(a))
13
+ diff = Diff::GDiff.diff(b, a)
14
+ assert_equal(a, diff.apply_to(b))
15
+ end
16
+ end
17
+
18
+ def test_big
19
+ a = ""
20
+ b = ""
21
+ (2**16).times do
22
+ a << "aaaa"
23
+ b << "aaaa"
24
+ end
25
+ b << "a" * 1024
26
+ diff = Diff::GDiff.diff(a, b)
27
+ assert_equal(diff.to_s, Diff::GDiff.unpack(diff.pack).to_s)
28
+ end
29
+
30
+ def test_pack_unpack
31
+ [[("a" * 2 ** 10) + ("b" * 2**10 * 2**10) + ("c" * 2**10),
32
+ ("b" * (2**10-99)) + ("c" * (2**10+20)) + ("a" * (2 ** 10-15)) + "X"],
33
+ [ "er sagt bananen und google googlet googilionen " * 10,
34
+ "google googlet googilionen und bananen, sagt er " * 10]].each do | (a, b) |
35
+ diff = Diff::GDiff.diff(a, b)
36
+ assert_equal(diff.to_s, Diff::GDiff.unpack(diff.pack).to_s)
37
+ assert_equal(diff.pack, Diff::GDiff.unpack(diff.pack).pack)
38
+ end
39
+ end
40
+
41
+ def test_delete
42
+ a = "ABCDEFGHIJK"
43
+ b = "ACDFGHIJ"
44
+ assert_equal(b, Diff::GDiff.diff(a, b).apply_to(a))
45
+ b = ""
46
+ assert_equal(b, Diff::GDiff.diff(a, b).apply_to(a))
47
+ end
48
+
49
+ def test_insert
50
+ a = "ACDFGHIJ"
51
+ b = "ABCDEFGHIJK"
52
+ assert_equal(b, Diff::GDiff.diff(a, b).apply_to(a))
53
+ a = ""
54
+ assert_equal(b, Diff::GDiff.diff(a, b).apply_to(a))
55
+ end
56
+
57
+ def test_empty
58
+ b = a = ""
59
+ assert_equal(b, Diff::GDiff.diff(a, b).apply_to(a))
60
+ end
61
+
62
+ def test_equal
63
+ b = a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
64
+ assert_equal(b, Diff::GDiff.diff(a, b).apply_to(a))
65
+ end
66
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: gdiff
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.0.1
7
+ date: 2005-10-31 00:00:00 +01:00
8
+ summary: An implementation of the gdiff protocol
9
+ require_paths:
10
+ - lib
11
+ - lib
12
+ - ext
13
+ email: gdiff@brian-schroeder.de
14
+ homepage: http://ruby.brian-schroeder.de/gdiff/
15
+ rubyforge_project:
16
+ description: An implementation of the gdiff protocol. [Protocol description](http://www.w3.org/TR/NOTE-gdiff-19970901)
17
+ autorequire: gdiff.rb
18
+ default_executable:
19
+ bindir: bin
20
+ has_rdoc: true
21
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
22
+ requirements:
23
+ -
24
+ - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.0
27
+ version:
28
+ platform: ruby
29
+ signing_key:
30
+ cert_chain:
31
+ authors:
32
+ - Brian Schroeder
33
+ files:
34
+ - COPYING.suffix_array
35
+ - README.suffix_array
36
+ - README
37
+ - LICENSE.suffix_array
38
+ - CHANGELOG
39
+ - setup.rb
40
+ - bin
41
+ - doc
42
+ - ext
43
+ - lib
44
+ - test
45
+ - bin/gdiff
46
+ - bin/gpatch
47
+ - doc/index.html
48
+ - doc/rdoc-style.css
49
+ - doc/fr_method_index.html
50
+ - doc/fr_class_index.html
51
+ - doc/fr_file_index.html
52
+ - doc/created.rid
53
+ - doc/files
54
+ - doc/classes
55
+ - doc/files/ext
56
+ - doc/files/lib
57
+ - doc/files/ext/gdiff
58
+ - doc/files/ext/gdiff/suffix_array
59
+ - doc/files/ext/gdiff/suffix_array/sarray_c.html
60
+ - doc/files/ext/gdiff/suffix_array/suffix_array_c.html
61
+ - doc/files/ext/gdiff/suffix_array/extconf_rb.html
62
+ - doc/files/ext/gdiff/suffix_array/lcp_c.html
63
+ - doc/files/lib/gdiff_rb.html
64
+ - doc/classes/SuffixArray.html
65
+ - doc/classes/SAError.html
66
+ - doc/classes/Diff.html
67
+ - doc/classes/Diff
68
+ - doc/classes/SuffixArray.src
69
+ - doc/classes/Diff/GDiff.html
70
+ - doc/classes/Diff/GDiff
71
+ - doc/classes/Diff/GDiff/EPrematureEndOfStream.html
72
+ - doc/classes/Diff/GDiff/ENoGdiffStream.html
73
+ - doc/classes/Diff/GDiff/EGdiffError.html
74
+ - doc/classes/Diff/GDiff/Operations.html
75
+ - doc/classes/Diff/GDiff/Operations
76
+ - doc/classes/Diff/GDiff/Operations/Copy.html
77
+ - doc/classes/Diff/GDiff/Operations/Data.html
78
+ - doc/classes/Diff/GDiff/Operations/Copy.src
79
+ - doc/classes/Diff/GDiff/Operations/Data.src
80
+ - doc/classes/Diff/GDiff/Operations/Copy.src/M000014.html
81
+ - doc/classes/Diff/GDiff/Operations/Copy.src/M000015.html
82
+ - doc/classes/Diff/GDiff/Operations/Copy.src/M000016.html
83
+ - doc/classes/Diff/GDiff/Operations/Copy.src/M000017.html
84
+ - doc/classes/Diff/GDiff/Operations/Data.src/M000009.html
85
+ - doc/classes/Diff/GDiff/Operations/Data.src/M000010.html
86
+ - doc/classes/Diff/GDiff/Operations/Data.src/M000011.html
87
+ - doc/classes/Diff/GDiff/Operations/Data.src/M000012.html
88
+ - doc/classes/Diff/GDiff/Operations/Data.src/M000013.html
89
+ - doc/classes/SuffixArray.src/M000008.html
90
+ - doc/classes/SuffixArray.src/M000001.html
91
+ - doc/classes/SuffixArray.src/M000002.html
92
+ - doc/classes/SuffixArray.src/M000003.html
93
+ - doc/classes/SuffixArray.src/M000004.html
94
+ - doc/classes/SuffixArray.src/M000005.html
95
+ - doc/classes/SuffixArray.src/M000006.html
96
+ - doc/classes/SuffixArray.src/M000007.html
97
+ - ext/gdiff
98
+ - ext/gdiff/COPYING
99
+ - ext/gdiff/LICENSE
100
+ - ext/gdiff/README
101
+ - ext/gdiff/extconf.rb
102
+ - ext/gdiff/lcp.c
103
+ - ext/gdiff/sarray.3
104
+ - ext/gdiff/sarray.c
105
+ - ext/gdiff/sarray.h
106
+ - ext/gdiff/suffix_array.c
107
+ - lib/gdiff.rb
108
+ - test/tc_gdiff.rb
109
+ test_files:
110
+ - test/tc_gdiff.rb
111
+ rdoc_options: []
112
+ extra_rdoc_files: []
113
+ executables:
114
+ - gpatch
115
+ - gdiff
116
+ extensions:
117
+ - ext/gdiff/extconf.rb
118
+ requirements: []
119
+ dependencies: []