PageRenderTime 60ms CodeModel.GetById 10ms app.highlight 10ms RepoModel.GetById 38ms app.codeStats 0ms

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