| 1 |
require 'spec_helper' |
| 2 |
|
| 3 |
include TeX::Hyphen |
| 4 |
|
| 5 |
describe Converter do |
| 6 |
describe '.scan_line' do |
| 7 |
it "scans the line" do |
| 8 |
eightbits, usv = Converter.scan_line "0xDF\tU+042F" |
| 9 |
expect(eightbits).to eq 223 |
| 10 |
expect(usv).to eq 'Я' |
| 11 |
end |
| 12 |
|
| 13 |
it "can read an optional name" do |
| 14 |
eightbits, usv, bool, name = Converter.scan_line "0x2E\tU+002E\t\tperiod" |
| 15 |
expect(eightbits).to eq 46 |
| 16 |
expect(usv).to eq '.' |
| 17 |
expect(bool).to eq 0 |
| 18 |
expect(name).to eq 'period' |
| 19 |
end |
| 20 |
|
| 21 |
it "doesn’t crash if there is no match" do |
| 22 |
expect { Converter.scan_line "" }.not_to raise_exception |
| 23 |
end |
| 24 |
|
| 25 |
it "returns nil if there are no matches" do |
| 26 |
b = Converter.scan_line "0x2F" |
| 27 |
expect(b).to be_nil |
| 28 |
end |
| 29 |
|
| 30 |
it "can also have a useless strange entry" do |
| 31 |
eightbits, usv, bool, name = Converter.scan_line "0x19\tU+0131\t1\tdotlessi" |
| 32 |
expect(eightbits).to eq 25 |
| 33 |
expect(usv).to eq 'ı' |
| 34 |
expect(bool).to eq 1 |
| 35 |
expect(name).to eq 'dotlessi' |
| 36 |
end |
| 37 |
end |
| 38 |
end |