Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add U::String#new tests

  • Loading branch information...
commit af1aa285a2c602983336f1f4956deb622ca16039 1 parent 0d45c7a
Nikolai Weibull authored
Showing with 11 additions and 2 deletions.
  1. +11 −2 test/unit/u/string.rb
View
13 test/unit/u/string.rb
@@ -1,6 +1,15 @@
# -*- coding: utf-8 -*-
Expectations do
+ expect ''.u do U::String.new end
+ expect ''.u do U::String.new(nil) end
+ expect '' do U::String.new(nil).to_str end
+ expect 'äbc' do U::String.new('äbc').to_str end
+ if defined? Encoding
+ expect 'äbc' do U::String.new('äbc'.encode(Encoding::ISO8859_1)).to_str end
+ expect Encoding::UndefinedConversionError do U::String.new('äbc'.encode(Encoding::ASCII_8BIT)) end
+ end
+
expect true do 'äbc'.u.valid_encoding? end
expect true do "äbc\0def".u.valid_encoding? end
expect false do "\xc3bc".u.valid_encoding? end
@@ -1361,12 +1370,12 @@
expect String do ''.u.to_str end
expect '' do ''.u.to_str end
- if defined? ::Encoding
+ if defined? Encoding
expect Encoding::UTF_8 do ''.u.to_str.encoding end
expect Encoding::UTF_8 do ''.encode(Encoding::ASCII).u.to_str.encoding end
end
- if defined? ::Encoding
+ if defined? Encoding
expect Encoding::ASCII_8BIT do ''.u.b.encoding end
end
Please sign in to comment.
Something went wrong with that request. Please try again.