/spec/hamming_spec.rb

https://github.com/gthole/rubyfish · Ruby · 29 lines · 23 code · 5 blank · 1 comment · 1 complexity · 53db6767ed70efb19565ce2b50da01bb MD5 · raw file

  1. #encoding: utf-8
  2. require 'spec_helper'
  3. describe RubyFish::Hamming do
  4. it "should calculate distance" do
  5. subject.should match_cases([
  6. ["", "", 0],
  7. ["", "abc", 3],
  8. ["abc", "abc", 0],
  9. ["acc", "abc", 1],
  10. ["abcd", "abc", 1],
  11. ["abc", "abcd", 1],
  12. ["testing", "this is a test", 13],
  13. ["toned", "roses", 3],
  14. ["toned2", "roses", 4],
  15. ["toned2", "roses2", 3],
  16. ["1011101", "1001001", 2],
  17. ["2173896", "2233796", 3],
  18. ["привет", "привед", 1]
  19. ])
  20. end
  21. it "should work with nils" do
  22. subject.distance(nil, nil).should == 0
  23. end
  24. end