spec/characteristics_spec.rb in characteristics-0.2.0 vs spec/characteristics_spec.rb in characteristics-0.3.0

- old
+ new

@@ -16,10 +16,14 @@ def blank?(char) Characteristics.create(char.force_encoding(encoding)).blank? end + def format?(char) + Characteristics.create(char.force_encoding(encoding)).format? + end + describe UnicodeCharacteristics do describe "UTF-*" do let(:encoding) { "UTF-8" } it "is valid or not" do @@ -41,10 +45,15 @@ it "is blank or not" do assert blank? "\x20" refute blank? "\x21" end + + it "is format or not" do + assert format? "\uFFF9" + refute format? "\x21" + end end end describe BinaryCharacteristics do describe "ASCII-8BIT" do @@ -66,10 +75,14 @@ it "is blank or not" do assert blank? "\x20" refute blank? "\x21" end + + it "is never format" do + refute format? "\x21" + end end end describe AsciiCharacteristics do describe "US-ASCII" do @@ -92,10 +105,14 @@ it "is blank or not" do assert blank? "\x20" refute blank? "\x21" end + + it "is never format" do + refute format? "\x21" + end end end describe ByteCharacteristics do describe "ISO-8859-*" do @@ -120,10 +137,14 @@ it "is blank or not" do assert blank? "\x20" refute blank? "\x21" end + + it "is never format" do + refute format? "\x21" + end end # TODO # describe "ISO-8859-2" do @@ -140,11 +161,11 @@ # describe "ISO-8859-14" do # describe "ISO-8859-15" do # describe "ISO-8859-16" do end - describe "Windows-*" do + describe "Windows-125*" do describe "Windows-1252" do let(:encoding) { "Windows-1252" } it "is always valid" do assert valid? "\x80" @@ -162,10 +183,14 @@ it "is blank or not" do assert blank? "\x20" refute blank? "\x21" end + + it "is never format" do + refute format? "\x21" + end end # TODO # describe "Windows-1250" do @@ -174,8 +199,202 @@ # describe "Windows-1254" do # describe "Windows-1255" do # describe "Windows-1256" do # describe "Windows-1257" do # describe "Windows-1258" do + end + + describe "IBM*, CP85*" do + describe "IBM869" do + let(:encoding) { "IBM869" } + + it "is always valid" do + assert valid? "\x80" + end + + it "is assigned or not" do + assert assigned? "\x21" + refute assigned? "\x80" + end + + it "is control or not" do + assert control? "\x1E" + refute control? "\x67" + end + + it "is blank or not" do + assert blank? "\x20" + refute blank? "\x21" + end + + it "is never format" do + refute format? "\x21" + end + end + + # describe "IBM437" do + # describe "IBM737" do + # describe "IBM775" do + # describe "CP850" do + # describe "IBM852" do + # describe "CP852" do + # describe "IBM855" do + # describe "CP855" do + # describe "IBM857" do + # describe "IBM860" do + # describe "IBM861" do + # describe "IBM862" do + # describe "IBM863" do + # describe "IBM864" do + # describe "IBM865" do + # describe "IBM866" do + end + + describe "mac*" do + describe "macRoman" do + let(:encoding) { "macRoman" } + + it "is always valid" do + assert valid? "\x80" + end + + it "is always assigned" do + assert assigned? "\x21" + end + + it "is control or not" do + assert control? "\x1E" + refute control? "\x67" + end + + it "is blank or not" do + assert blank? "\x20" + refute blank? "\x21" + end + + it "is never format" do + refute format? "\x21" + end + end + + # describe "macCentEuro" do + # describe "macCroatian" do + # describe "macCyrillic" do + # describe "macGreek" do + # describe "macIceland" do + # describe "macRomania" do + # describe "macThai" do + # describe "macTurkish" do + # describe "macUkraine" do + end + + describe "TIS-620/Windows-874" do + describe "TIS-620" do + let(:encoding) { "TIS-620" } + + it "is always valid" do + assert valid? "\x80" + end + + it "is assigned or not" do + assert assigned? "\x21" + refute assigned? "\xA0" + end + + it "is control or not" do + assert control? "\x1E" + refute control? "\x67" + end + + it "is blank or not" do + assert blank? "\x20" + refute blank? "\x21" + end + + it "is never format" do + refute format? "\x21" + end + end + + describe "Windows-874" do + let(:encoding) { "Windows-874" } + + it "is always valid" do + assert valid? "\x80" + end + + it "is assigned or not" do + assert assigned? "\xA0" + refute assigned? "\x99" + end + + it "is control or not" do + assert control? "\x1E" + refute control? "\x67" + end + + it "is blank or not" do + assert blank? "\x20" + refute blank? "\x21" + end + + it "is never format" do + refute format? "\x21" + end + end + end + + describe "KOI8-*" do + describe "KOI8-R" do + let(:encoding) { "KOI8-R" } + + it "is always valid" do + assert valid? "\x80" + end + + it "is always assigned" do + assert assigned? "\x21" + end + + it "is control or not" do + assert control? "\x1E" + refute control? "\x67" + end + + it "is blank or not" do + assert blank? "\x20" + refute blank? "\x21" + end + + it "is never format" do + refute format? "\x21" + end + end + + describe "KOI8-U" do + let(:encoding) { "KOI8-U" } + + it "is always valid" do + assert valid? "\x80" + end + + it "is always assigned" do + assert assigned? "\x21" + end + + it "is control or not" do + assert control? "\x1E" + refute control? "\x67" + end + + it "is blank or not" do + assert blank? "\x20" + refute blank? "\x21" + end + + it "is never format" do + refute format? "\x21" + end + end end end end