diff options
author | Jon Rowe <hello@jonrowe.co.uk> | 2013-03-15 10:53:32 +1100 |
---|---|---|
committer | Jon Rowe <hello@jonrowe.co.uk> | 2013-03-15 10:53:32 +1100 |
commit | 511c37fa4ef8a4ea653b9b6c99beec390fde9c78 (patch) | |
tree | 85613d9623d905f82bb2f83aab72a666b12edb1f /spec | |
parent | ef3e16459ed3408f947ca95418998a0dd54a20e4 (diff) | |
download | diff-lcs-511c37fa4ef8a4ea653b9b6c99beec390fde9c78.tar.gz |
fix issues with encoding caused by using literals
Diffstat (limited to 'spec')
-rw-r--r-- | spec/hunk_spec.rb | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/spec/hunk_spec.rb b/spec/hunk_spec.rb new file mode 100644 index 0000000..a7da631 --- /dev/null +++ b/spec/hunk_spec.rb @@ -0,0 +1,57 @@ +# -*- ruby encoding: utf-8 -*- + +require 'spec_helper' + +describe "Diff::LCS::Hunk" do + + let(:old_data) { ["Tu avec carté {count} itém has".encode('UTF-16LE')] } + let(:new_data) { ["Tu avec carte {count} item has".encode('UTF-16LE')] } + let(:peices) { Diff::LCS.diff old_data, new_data } + let(:hunk) { Diff::LCS::Hunk.new(old_data, new_data, peices[0], 3, 0) } + + it 'should be able to produce a unified diff from the two peices' do + expected = +(<<-EOD.encode('UTF-16LE').chomp) +@@ -1,2 +1,2 @@ +Tu avec carté {count} itém has ++Tu avec carte {count} item has +EOD + expect(hunk.diff(:unified).to_s == expected).to eql true + end + + it 'should be able to produce a context diff from the two peices' do + expected = +(<<-EOD.encode('UTF-16LE').chomp) +*************** +*** 1,2 **** +Tu avec carté {count} itém has +--- 1,2 ---- +Tu avec carte {count} item has +EOD + expect(hunk.diff(:context).to_s == expected).to eql true + end + + it 'should be able to produce an old diff from the two peices' do + expected = +(<<-EOD.encode('UTF-16LE').chomp) +1,2c1,2 +< Tu avec carté {count} itém has +--- +> Tu avec carte {count} item has + +EOD + expect(hunk.diff(:old).to_s == expected).to eql true + end + + it 'should be able to produce a reverse ed diff from the two peices' do + expected = +(<<-EOD.encode('UTF-16LE').chomp) +c1,2 +Tu avec carte {count} item has +. + +EOD + expect(hunk.diff(:reverse_ed).to_s == expected).to eql true + end + +end |