Sha256: cd391946a126e8b981111fc4484589f3dfc45c9940ea373499a03d42c622134c

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

# Copyright (c) 2023 M.J.N. Corino, The Netherlands
#
# This software is released under the MIT license.

require_relative './lib/wxframe_runner'

class StyledTextCtrlTests < WxRuby::Test::GUITests

  def setup
    super
    @text = Wx::STC::StyledTextCtrl.new(frame_win, name: 'StyledText')
  end

  def cleanup
    @text.destroy
    super
  end

  attr_reader :text

  def test_text
    assert_equal('', text.get_value)
  end

  def test_enumerate_lines
    text.write_text <<~__HEREDOC
      This is line 1.
      This is line 2.
      This is line 3.
      __HEREDOC
    assert_equal(4, text.get_number_of_lines)
    text.each_line.each_with_index do |txt, lnr|
      if lnr < 3
        assert("This is line #{lnr+1}.", txt)
      else
        assert('', txt)
      end
    end
    txt = text.each_line { |l| break l if l.index('2')}
    assert_equal('This is line 2.', txt)
    line_enum = text.each_line
    txt = line_enum.detect { |l| l.index('3') }
    assert_equal('This is line 3.', txt)
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wxruby3-0.9.7-x64-mingw-ucrt tests/test_styled_text_ctrl.rb
wxruby3-0.9.5-x64-mingw-ucrt tests/test_styled_text_ctrl.rb
wxruby3-0.9.4-x64-mingw-ucrt tests/test_styled_text_ctrl.rb
wxruby3-0.9.3-x64-mingw-ucrt tests/test_styled_text_ctrl.rb
wxruby3-0.9.2-x64-mingw-ucrt tests/test_styled_text_ctrl.rb