ruby-changes:58874
From: aycabta <ko1@a...>
Date: Thu, 21 Nov 2019 07:29:41 +0900 (JST)
Subject: [ruby-changes:58874] 8f1062127e (master): Add test/reline/test_string_processing.rb
https://git.ruby-lang.org/ruby.git/commit/?id=8f1062127e From 8f1062127e40767240aa0a0fe18fd48687bc04e9 Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Thu, 21 Nov 2019 07:28:18 +0900 Subject: Add test/reline/test_string_processing.rb diff --git a/test/reline/test_string_processing.rb b/test/reline/test_string_processing.rb new file mode 100644 index 0000000..4df0363 --- /dev/null +++ b/test/reline/test_string_processing.rb @@ -0,0 +1,23 @@ https://github.com/ruby/ruby/blob/trunk/test/reline/test_string_processing.rb#L1 +require_relative 'helper' + +class Reline::LineEditor::StringProcessingTest < Reline::TestCase + def setup + Reline.send(:test_mode) + @prompt = '> ' + @config = Reline::Config.new + Reline::HISTORY.instance_variable_set(:@config, @config) + @encoding = (RELINE_TEST_ENCODING rescue Encoding.default_external) + @line_editor = Reline::LineEditor.new(@config) + @line_editor.reset(@prompt, @encoding) + end + + def test_calculate_width + width = @line_editor.send(:calculate_width, 'Ruby string') + assert_equal('Ruby string'.size, width) + end + + def test_calculate_width_with_escape_sequence + width = @line_editor.send(:calculate_width, "\1\e[31m\2RubyColor\1\e[34m\2 default string \1\e[m\2>", true) + assert_equal('RubyColor default string >'.size, width) + end +end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/