Methods
- S
- T
-
- test_acts_like_string,
- test_capitalize_should_work_on_ascii_characters,
- test_center_should_count_characters_instead_of_bytes,
- test_center_should_raise_argument_errors_on_bad_arguments,
- test_downcase_should_downcase_ascii_characters,
- test_identity,
- test_include_raises_when_nil_is_passed,
- test_index_should_return_character_offset,
- test_indexed_insert_should_raise_on_index_overflow,
- test_indexed_insert_should_raise_on_range_overflow,
- test_indexed_insert_should_take_character_offsets,
- test_insert_should_be_destructive,
- test_insert_throws_index_error,
- test_ljust_should_count_characters_instead_of_bytes,
- test_ljust_should_raise_argument_errors_on_bad_arguments,
- test_lstrip_strips_whitespace_from_the_left_of_the_string,
- test_method_works_for_proxyed_methods,
- test_ord_should_return_unicode_value_for_first_character,
- test_respond_to_knows_which_methods_the_proxy_responds_to,
- test_reverse_reverses_characters,
- test_reverse_should_work_with_normalized_strings,
- test_rindex_should_return_character_offset,
- test_rjust_should_count_characters_instead_of_bytes,
- test_rjust_should_raise_argument_errors_on_bad_arguments,
- test_rstrip_strips_whitespace_from_the_right_of_the_string,
- test_should_be_equal_to_the_wrapped_string,
- test_should_know_if_one_includes_the_other,
- test_should_not_be_equal_to_an_other_string,
- test_should_return_character_offset_for_regexp_matches,
- test_should_use_character_offsets_for_insert_offsets,
- test_size_returns_characters_instead_of_bytes,
- test_slice_bang_removes_the_slice_from_the_receiver,
- test_slice_bang_returns_nil_and_does_not_modify_receiver_if_out_of_bounds,
- test_slice_bang_returns_nil_on_out_of_bound_arguments,
- test_slice_bang_returns_sliced_out_substring,
- test_slice_should_take_character_offsets,
- test_slice_should_throw_exceptions_on_invalid_arguments,
- test_sortability,
- test_split_should_return_an_array_of_chars_instances,
- test_string_methods_are_chainable,
- test_strip_strips_whitespace,
- test_stripping_whitespace_leaves_whitespace_within_the_string_intact,
- test_swapcase_should_swap_ascii_characters,
- test_tidy_bytes_bang_should_change_wrapped_string,
- test_tidy_bytes_bang_should_return_self,
- test_titleize_should_work_on_ascii_characters,
- test_unicode_string_should_have_utf8_encoding,
- test_upcase_should_upcase_ascii_characters
Included Modules
Instance Public methods
setup()
Link
test_acts_like_string()
Link
test_capitalize_should_work_on_ascii_characters()
Link
test_center_should_count_characters_instead_of_bytes()
Link
# File activesupport/test/multibyte_chars_test.rb, line 325 def test_center_should_count_characters_instead_of_bytes assert_equal UNICODE_STRING, @chars.center(-3) assert_equal UNICODE_STRING, @chars.center(0) assert_equal UNICODE_STRING, @chars.center(4) assert_equal "#{UNICODE_STRING} ", @chars.center(5) assert_equal " #{UNICODE_STRING} ", @chars.center(6) assert_equal " #{UNICODE_STRING} ", @chars.center(7) assert_equal "--#{UNICODE_STRING}--", @chars.center(8, '-') assert_equal "--#{UNICODE_STRING}---", @chars.center(9, '-') assert_equal "αα#{UNICODE_STRING}αα", @chars.center(8, 'α') assert_equal "αα#{UNICODE_STRING}ααα", @chars.center(9, 'α') assert_equal "a#{UNICODE_STRING}ab", @chars.center(7, 'ab') assert_equal "ab#{UNICODE_STRING}ab", @chars.center(8, 'ab') assert_equal "abab#{UNICODE_STRING}abab", @chars.center(12, 'ab') assert_equal "α#{UNICODE_STRING}αη", @chars.center(7, 'αη') assert_equal "αη#{UNICODE_STRING}αη", @chars.center(8, 'αη') end
test_center_should_raise_argument_errors_on_bad_arguments()
Link
test_downcase_should_downcase_ascii_characters()
Link
test_identity()
Link
test_include_raises_when_nil_is_passed()
Link
test_index_should_return_character_offset()
Link
# File activesupport/test/multibyte_chars_test.rb, line 229 def test_index_should_return_character_offset assert_nil @chars.index('u') assert_equal 0, @chars.index('こに') assert_equal 2, @chars.index('ち') assert_equal 2, @chars.index('ち', -2) assert_equal nil, @chars.index('ち', -1) assert_equal 3, @chars.index('わ') assert_equal 5, 'ééxééx'.mb_chars.index('x', 4) end
test_indexed_insert_should_raise_on_index_overflow()
Link
# File activesupport/test/multibyte_chars_test.rb, line 269 def test_indexed_insert_should_raise_on_index_overflow before = @chars.to_s assert_raise(IndexError) { @chars[10] = 'a' } assert_raise(IndexError) { @chars[10, 4] = 'a' } assert_raise(IndexError) { @chars[/ii/] = 'a' } assert_raise(IndexError) { @chars[/()/, 10] = 'a' } assert_equal before, @chars end
test_indexed_insert_should_raise_on_range_overflow()
Link
test_indexed_insert_should_take_character_offsets()
Link
# File activesupport/test/multibyte_chars_test.rb, line 248 def test_indexed_insert_should_take_character_offsets @chars[2] = 'a' assert_equal 'こにaわ', @chars @chars[2] = 'ηη' assert_equal 'こにηηわ', @chars @chars[3, 2] = 'λλλ' assert_equal 'こにηλλλ', @chars @chars[1, 0] = "λ" assert_equal 'こλにηλλλ', @chars @chars[4..6] = "ηη" assert_equal 'こλにηηη', @chars @chars[/ηη/] = "λλλ" assert_equal 'こλにλλλη', @chars @chars[/(λλ)(.)/, 2] = "α" assert_equal 'こλにλλαη', @chars @chars["α"] = "¢" assert_equal 'こλにλλ¢η', @chars @chars["λλ"] = "ααα" assert_equal 'こλにααα¢η', @chars end
test_insert_should_be_destructive()
Link
test_insert_throws_index_error()
Link
test_ljust_should_count_characters_instead_of_bytes()
Link
# File activesupport/test/multibyte_chars_test.rb, line 307 def test_ljust_should_count_characters_instead_of_bytes assert_equal UNICODE_STRING, @chars.ljust(-3) assert_equal UNICODE_STRING, @chars.ljust(0) assert_equal UNICODE_STRING, @chars.ljust(4) assert_equal "#{UNICODE_STRING} ", @chars.ljust(5) assert_equal "#{UNICODE_STRING} ", @chars.ljust(7) assert_equal "#{UNICODE_STRING}---", @chars.ljust(7, '-') assert_equal "#{UNICODE_STRING}ααα", @chars.ljust(7, 'α') assert_equal "#{UNICODE_STRING}aba", @chars.ljust(7, 'ab') assert_equal "#{UNICODE_STRING}αηα", @chars.ljust(7, 'αη') assert_equal "#{UNICODE_STRING}αηαη", @chars.ljust(8, 'αη') end
test_ljust_should_raise_argument_errors_on_bad_arguments()
Link
test_lstrip_strips_whitespace_from_the_left_of_the_string()
Link
# File activesupport/test/multibyte_chars_test.rb, line 343 def test_lstrip_strips_whitespace_from_the_left_of_the_string assert_equal UNICODE_STRING, UNICODE_STRING.mb_chars.lstrip assert_equal UNICODE_STRING, (@whitespace + UNICODE_STRING).mb_chars.lstrip assert_equal UNICODE_STRING + @whitespace, (@whitespace + UNICODE_STRING + @whitespace).mb_chars.lstrip end
test_method_works_for_proxyed_methods()
Link
# File activesupport/test/multibyte_chars_test.rb, line 476 def test_method_works_for_proxyed_methods assert_equal 'll', 'hello'.mb_chars.method(:slice).call(2..3) # Defined on Chars chars = 'hello'.mb_chars assert_equal 'Hello', chars.method(:capitalize!).call # Defined on Chars assert_equal 'Hello', chars assert_equal 'jello', 'hello'.mb_chars.method(:gsub).call(/h/, 'j') # Defined on String assert_raise(NameError){ ''.mb_chars.method(:undefined_method) } # Not defined end
test_ord_should_return_unicode_value_for_first_character()
Link
test_respond_to_knows_which_methods_the_proxy_responds_to()
Link
# File activesupport/test/multibyte_chars_test.rb, line 469 def test_respond_to_knows_which_methods_the_proxy_responds_to assert ''.mb_chars.respond_to?(:slice) # Defined on Chars assert ''.mb_chars.respond_to?(:capitalize!) # Defined on Chars assert ''.mb_chars.respond_to?(:gsub) # Defined on String assert !''.mb_chars.respond_to?(:undefined_method) # Not defined end
test_reverse_reverses_characters()
Link
test_reverse_should_work_with_normalized_strings()
Link
# File activesupport/test/multibyte_chars_test.rb, line 381 def test_reverse_should_work_with_normalized_strings str = 'bös' reversed_str = 'söb' assert_equal chars(reversed_str).normalize(:kc), chars(str).normalize(:kc).reverse assert_equal chars(reversed_str).normalize(:c), chars(str).normalize(:c).reverse assert_equal chars(reversed_str).normalize(:d), chars(str).normalize(:d).reverse assert_equal chars(reversed_str).normalize(:kd), chars(str).normalize(:kd).reverse assert_equal chars(reversed_str).decompose, chars(str).decompose.reverse assert_equal chars(reversed_str).compose, chars(str).compose.reverse end
test_rindex_should_return_character_offset()
Link
# File activesupport/test/multibyte_chars_test.rb, line 239 def test_rindex_should_return_character_offset assert_nil @chars.rindex('u') assert_equal 1, @chars.rindex('に') assert_equal 2, @chars.rindex('ち', -2) assert_nil @chars.rindex('ち', -3) assert_equal 6, 'Café périferôl'.mb_chars.rindex('é') assert_equal 13, 'Café périferôl'.mb_chars.rindex(/\w/u) end
test_rjust_should_count_characters_instead_of_bytes()
Link
# File activesupport/test/multibyte_chars_test.rb, line 289 def test_rjust_should_count_characters_instead_of_bytes assert_equal UNICODE_STRING, @chars.rjust(-3) assert_equal UNICODE_STRING, @chars.rjust(0) assert_equal UNICODE_STRING, @chars.rjust(4) assert_equal " #{UNICODE_STRING}", @chars.rjust(5) assert_equal " #{UNICODE_STRING}", @chars.rjust(7) assert_equal "---#{UNICODE_STRING}", @chars.rjust(7, '-') assert_equal "ααα#{UNICODE_STRING}", @chars.rjust(7, 'α') assert_equal "aba#{UNICODE_STRING}", @chars.rjust(7, 'ab') assert_equal "αηα#{UNICODE_STRING}", @chars.rjust(7, 'αη') assert_equal "αηαη#{UNICODE_STRING}", @chars.rjust(8, 'αη') end
test_rjust_should_raise_argument_errors_on_bad_arguments()
Link
test_rstrip_strips_whitespace_from_the_right_of_the_string()
Link
# File activesupport/test/multibyte_chars_test.rb, line 349 def test_rstrip_strips_whitespace_from_the_right_of_the_string assert_equal UNICODE_STRING, UNICODE_STRING.mb_chars.rstrip assert_equal UNICODE_STRING, (UNICODE_STRING + @whitespace).mb_chars.rstrip assert_equal @whitespace + UNICODE_STRING, (@whitespace + UNICODE_STRING + @whitespace).mb_chars.rstrip end
test_should_be_equal_to_the_wrapped_string()
Link
test_should_know_if_one_includes_the_other()
Link
test_should_not_be_equal_to_an_other_string()
Link
test_should_return_character_offset_for_regexp_matches()
Link
# File activesupport/test/multibyte_chars_test.rb, line 188 def test_should_return_character_offset_for_regexp_matches assert_nil(@chars =~ /wrong/u) assert_equal 0, (@chars =~ /こ/u) assert_equal 0, (@chars =~ /こに/u) assert_equal 1, (@chars =~ /に/u) assert_equal 2, (@chars =~ /ち/u) assert_equal 3, (@chars =~ /わ/u) end
test_should_use_character_offsets_for_insert_offsets()
Link
# File activesupport/test/multibyte_chars_test.rb, line 197 def test_should_use_character_offsets_for_insert_offsets assert_equal '', ''.mb_chars.insert(0, '') assert_equal 'こわにちわ', @chars.insert(1, 'わ') assert_equal 'こわわわにちわ', @chars.insert(2, 'わわ') assert_equal 'わこわわわにちわ', @chars.insert(0, 'わ') assert_equal 'わこわわわにちわ', @chars.wrapped_string end
test_size_returns_characters_instead_of_bytes()
Link
test_slice_bang_removes_the_slice_from_the_receiver()
Link
test_slice_bang_returns_nil_and_does_not_modify_receiver_if_out_of_bounds()
Link
test_slice_bang_returns_nil_on_out_of_bound_arguments()
Link
test_slice_bang_returns_sliced_out_substring()
Link
test_slice_should_take_character_offsets()
Link
# File activesupport/test/multibyte_chars_test.rb, line 392 def test_slice_should_take_character_offsets assert_equal nil, ''.mb_chars.slice(0) assert_equal 'こ', @chars.slice(0) assert_equal 'わ', @chars.slice(3) assert_equal nil, ''.mb_chars.slice(-1..1) assert_equal nil, ''.mb_chars.slice(-1, 1) assert_equal '', ''.mb_chars.slice(0..10) assert_equal 'にちわ', @chars.slice(1..3) assert_equal 'にちわ', @chars.slice(1, 3) assert_equal 'こ', @chars.slice(0, 1) assert_equal 'ちわ', @chars.slice(2..10) assert_equal '', @chars.slice(4..10) assert_equal 'に', @chars.slice(/に/u) assert_equal 'にち', @chars.slice(/に./u) assert_equal nil, @chars.slice(/unknown/u) assert_equal 'にち', @chars.slice(/(にち)/u, 1) assert_equal nil, @chars.slice(/(にち)/u, 2) assert_equal nil, @chars.slice(7..6) end
test_slice_should_throw_exceptions_on_invalid_arguments()
Link
# File activesupport/test/multibyte_chars_test.rb, line 434 def test_slice_should_throw_exceptions_on_invalid_arguments assert_raise(TypeError) { @chars.slice(2..3, 1) } assert_raise(TypeError) { @chars.slice(1, 2..3) } assert_raise(ArgumentError) { @chars.slice(1, 1, 1) } end
test_sortability()
Link
test_split_should_return_an_array_of_chars_instances()
Link
test_string_methods_are_chainable()
Link
# File activesupport/test/multibyte_chars_test.rb, line 152 def test_string_methods_are_chainable assert chars('').insert(0, '').kind_of?(ActiveSupport::Multibyte.proxy_class) assert chars('').rjust(1).kind_of?(ActiveSupport::Multibyte.proxy_class) assert chars('').ljust(1).kind_of?(ActiveSupport::Multibyte.proxy_class) assert chars('').center(1).kind_of?(ActiveSupport::Multibyte.proxy_class) assert chars('').rstrip.kind_of?(ActiveSupport::Multibyte.proxy_class) assert chars('').lstrip.kind_of?(ActiveSupport::Multibyte.proxy_class) assert chars('').strip.kind_of?(ActiveSupport::Multibyte.proxy_class) assert chars('').reverse.kind_of?(ActiveSupport::Multibyte.proxy_class) assert chars(' ').slice(0).kind_of?(ActiveSupport::Multibyte.proxy_class) assert chars('').limit(0).kind_of?(ActiveSupport::Multibyte.proxy_class) assert chars('').upcase.kind_of?(ActiveSupport::Multibyte.proxy_class) assert chars('').downcase.kind_of?(ActiveSupport::Multibyte.proxy_class) assert chars('').capitalize.kind_of?(ActiveSupport::Multibyte.proxy_class) assert chars('').normalize.kind_of?(ActiveSupport::Multibyte.proxy_class) assert chars('').decompose.kind_of?(ActiveSupport::Multibyte.proxy_class) assert chars('').compose.kind_of?(ActiveSupport::Multibyte.proxy_class) assert chars('').tidy_bytes.kind_of?(ActiveSupport::Multibyte.proxy_class) assert chars('').swapcase.kind_of?(ActiveSupport::Multibyte.proxy_class) end
test_strip_strips_whitespace()
Link
# File activesupport/test/multibyte_chars_test.rb, line 355 def test_strip_strips_whitespace assert_equal UNICODE_STRING, UNICODE_STRING.mb_chars.strip assert_equal UNICODE_STRING, (@whitespace + UNICODE_STRING).mb_chars.strip assert_equal UNICODE_STRING, (UNICODE_STRING + @whitespace).mb_chars.strip assert_equal UNICODE_STRING, (@whitespace + UNICODE_STRING + @whitespace).mb_chars.strip end
test_stripping_whitespace_leaves_whitespace_within_the_string_intact()
Link
# File activesupport/test/multibyte_chars_test.rb, line 362 def test_stripping_whitespace_leaves_whitespace_within_the_string_intact string_with_whitespace = UNICODE_STRING + @whitespace + UNICODE_STRING assert_equal string_with_whitespace, string_with_whitespace.mb_chars.strip assert_equal string_with_whitespace, string_with_whitespace.mb_chars.lstrip assert_equal string_with_whitespace, string_with_whitespace.mb_chars.rstrip end
test_swapcase_should_swap_ascii_characters()
Link
test_tidy_bytes_bang_should_change_wrapped_string()
Link
test_tidy_bytes_bang_should_return_self()
Link
test_titleize_should_work_on_ascii_characters()
Link
test_unicode_string_should_have_utf8_encoding()
Link