spec/string_spec.rb in utf8-0.1.3 vs spec/string_spec.rb in utf8-0.1.4

- old
+ new

@@ -48,10 +48,16 @@ it "should wrap all returned strings to be utf8-aware" do @utf8[0].class.should eql(String::UTF8) @utf8.chars.to_a[0].class.should eql(String::UTF8) end + it "clean should replace invalid utf8 chars with '?'" do + orig = "provided by Cristian Rodr\355guez." + clean = "provided by Cristian Rodr?guez." + orig.as_utf8.clean.should eql(clean) + end + context "#length and #size" do it "should be utf8-aware" do @utf8.length.should eql(@utf8_len) @utf8.size.should eql(@utf8_len) end @@ -183,9 +189,11 @@ utf8.force_encoding('utf-8') if utf8.respond_to?(:force_encoding) utf8 = utf8.as_utf8 utf8.valid?.should be_false @utf8.valid?.should be_true + + "provided by Cristian Rodr\355guez.".as_utf8.should_not be_valid end it "should test validity using a maximum codepoint" do highest_codepoint = @utf8.codepoints.to_a.max \ No newline at end of file