Module: String::Etest
- Defined in:
- lib/vex/boot/string.rb,
lib/vex/base/string/iconvert.rb
Instance Method Summary collapse
- #test_constantize ⇒ Object
- #test_ends_with ⇒ Object
- #test_iconvert ⇒ Object
- #test_starts_with ⇒ Object
Instance Method Details
#test_constantize ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/vex/boot/string.rb', line 51 def test_constantize assert_equal String, "String".constantize assert_raise(NameError) { "I::Dont::Know::This".constantize } assert_raise(ArgumentError) { "".constantize } end |
#test_ends_with ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/vex/boot/string.rb', line 39 def test_ends_with assert "abcde".ends_with?("") assert "abcde".ends_with?("e") assert "abcde".ends_with?("de") assert "abcde".ends_with?("cde") assert "abcde".ends_with?("bcde") assert "abcde".ends_with?("abcde") assert !("abcde".ends_with?("abcdef")) assert !("abcde".ends_with?("xy")) end |
#test_iconvert ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/vex/base/string/iconvert.rb', line 79 def test_iconvert assert_equal "s", "s".iconv(:utf8) assert_equal "s", "s".iconv("US-ASCII" => "UTF8") # # convert from "latin1" to "utf8" assert_equal "s", "s".iconv(:latin1 => "UTF8") assert_raises(Iconv::InvalidEncoding) do assert_equal "s", "s".iconv(:utf9 => :utf12) end assert_raises(Iconv::InvalidEncoding) do assert_equal "s", "s".iconv(:ascii => :utf12) end end |
#test_starts_with ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/vex/boot/string.rb', line 27 def test_starts_with assert "abcde".starts_with?("") assert "abcde".starts_with?("a") assert "abcde".starts_with?("ab") assert "abcde".starts_with?("abc") assert "abcde".starts_with?("abcd") assert "abcde".starts_with?("abcde") assert !("abcde".starts_with?("abcdef")) assert !("abcde".starts_with?("xy")) end |