Sha256: 99fff30282b4deed2cd02fab955541ce57bb7751adf582776ffe4b71af67d298

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

require 'minitest/autorun'
require 'tempfile'
require 'curses'
require 'curses/pad'

class TestCursesPad < MiniTest::Unit::TestCase

  def setup
    skip 'using built-in Curses::Pad' unless
      Curses::Pad.const_defined? :VERSION

    Curses.init_screen
  end

  def teardown
    Curses.close_screen
  end

  def test_initialize
    pad = Curses::Pad.new Curses.lines, Curses.cols

    assert_equal 0, pad.curx
    assert_equal 0, pad.cury

    assert_equal Curses.cols,  pad.maxx
    assert_equal Curses.lines, pad.maxy

    assert_equal 0, pad.begx
    assert_equal 0, pad.begy
  end

  def test_noutrefresh
    pad = Curses::Pad.new Curses.lines * 2, Curses.cols

    pad.noutrefresh 3, 4, 5, 6, 7, 8

    Curses.doupdate

    assert_equal 0, pad.curx
    assert_equal 0, pad.cury

    assert_equal Curses.cols,      pad.maxx
    assert_equal Curses.lines * 2, pad.maxy

    assert_equal 6, pad.begx
    assert_equal 5, pad.begy
  end

  def test_refresh
    pad = Curses::Pad.new Curses.lines * 2, Curses.cols

    pad.refresh 3, 4, 5, 6, 7, 8

    assert_equal 0, pad.curx
    assert_equal 0, pad.cury

    assert_equal Curses.cols,      pad.maxx
    assert_equal Curses.lines * 2, pad.maxy

    assert_equal 6, pad.begx
    assert_equal 5, pad.begy
  end

  def test_subpad
    pad = Curses::Pad.new Curses.lines, Curses.cols

    subpad = pad.subpad 5, 4, 3, 2

    assert_equal 0, subpad.curx
    assert_equal 0, subpad.cury

    assert_equal 4, subpad.maxx
    assert_equal 5, subpad.maxy

    assert_equal 2, subpad.begx
    assert_equal 3, subpad.begy
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
curses-pad-1.0 test/test_curses_pad.rb