I'm testing the equality of two rather large strings. They look the
same to me, but doing
assert_equal "big ass long string", "big ass long string"
says that they're different. And they look very similar to me. I
know that they're different though, as doing "big ass long string".sum
gives a different checksum than the other one.
Any ideas on how I can easily view the differences between two long strings?
I'm testing the equality of two rather large strings. They look the
same to me, but doing
assert_equal "big ass long string", "big ass long string"
says that they're different. And they look very similar to me. I
know that they're different though, as doing "big ass long string".sum
gives a different checksum than the other one.
Any ideas on how I can easily view the differences between two long strings?
--
Eric Hodel - drbrain@segment7.net - http://segment7.net
This implementation is HODEL-HASH-9600 compliant
def sdiff a, b
a = a.split //
b = b.split //
a.zip(b).each_with_index{|cc,idx| printf "%d: %s\n", idx, cc.inspect unless cc.uniq.size == 1}
end
sdiff a, b
harp:~ > ruby a.rb
5: ["r", "z"]
or just dump them to two files using 'od -c' and then use 'diff -u'.
regards.
-a
···
On Thu, 12 Jan 2006, Joe Van Dyk wrote:
Hi,
I'm testing the equality of two rather large strings. They look the
same to me, but doing
assert_equal "big ass long string", "big ass long string"
says that they're different. And they look very similar to me. I
know that they're different though, as doing "big ass long string".sum
gives a different checksum than the other one.
Any ideas on how I can easily view the differences between two long strings?
--
strong and healthy, who thinks of sickness until it strikes like lightning?
preoccupied with the world, who thinks of death, until it arrives like
thunder? -- milarepa
Thanks, I ended up doing something similar. I thought I recalled
reading a post here (or maybe on the Rails mailing list) about some
guy who was comparing large hashes and was having difficulties seeing
the differences between the two in the unit test output. This is sort
of a related problem, I guess.
···
On 1/12/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:
On Thu, 12 Jan 2006, Joe Van Dyk wrote:
> Hi,
>
> I'm testing the equality of two rather large strings. They look the
> same to me, but doing
>
> assert_equal "big ass long string", "big ass long string"
>
> says that they're different. And they look very similar to me. I
> know that they're different though, as doing "big ass long string".sum
> gives a different checksum than the other one.
>
> Any ideas on how I can easily view the differences between two long strings?
stupid - but works:
harp:~ > cat a.rb
a = "foobar"
b = "foobaz"
def sdiff a, b
a = a.split //
b = b.split //
a.zip(b).each_with_index{|cc,idx| printf "%d: %s\n", idx, cc.inspect unless cc.uniq.size == 1}
end
sdiff a, b
harp:~ > ruby a.rb
5: ["r", "z"]
or just dump them to two files using 'od -c' and then use 'diff -u'.
On 1/12/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:
On Thu, 12 Jan 2006, Joe Van Dyk wrote:
Hi,
I'm testing the equality of two rather large strings. They look the
same to me, but doing
assert_equal "big ass long string", "big ass long string"
says that they're different. And they look very similar to me. I
know that they're different though, as doing "big ass long string".sum
gives a different checksum than the other one.
Any ideas on how I can easily view the differences between two long strings?
stupid - but works:
harp:~ > cat a.rb
a = "foobar"
b = "foobaz"
def sdiff a, b
a = a.split //
b = b.split //
a.zip(b).each_with_index{|cc,idx| printf "%d: %s\n", idx, cc.inspect unless cc.uniq.size == 1}
end
sdiff a, b
harp:~ > ruby a.rb
5: ["r", "z"]
or just dump them to two files using 'od -c' and then use 'diff -u'.
Thanks, I ended up doing something similar. I thought I recalled
reading a post here (or maybe on the Rails mailing list) about some
guy who was comparing large hashes and was having difficulties seeing
the differences between the two in the unit test output. This is sort
of a related problem, I guess.
--
Eric Hodel - drbrain@segment7.net - http://segment7.net
This implementation is HODEL-HASH-9600 compliant