You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tc_canvas.rb 1.4 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. require 'test/unit'
  2. require 'cucul'
  3. class TC_Canvas < Test::Unit::TestCase
  4. def setup
  5. @c = Cucul::Canvas.new(3, 3)
  6. end
  7. def test_create
  8. c = Cucul::Canvas.new(3, 3)
  9. assert_not_nil(c, 'Canvas creation failed')
  10. assert(c.width == 3 && c.height == 3, 'Wrong size for new canvas')
  11. end
  12. def test_width
  13. @c.width = 42
  14. assert_equal(42, @c.width, 'Failed to set width with =')
  15. @c.set_width(24)
  16. assert_equal(24, @c.width, 'Failed to set width')
  17. end
  18. def test_height
  19. @c.height = 42
  20. assert_equal(42, @c.height, 'Failed to set height with =')
  21. @c.set_height(24)
  22. assert_equal(24, @c.height, 'Failed to set height')
  23. end
  24. def test_size
  25. @c.set_size(100,100)
  26. assert(@c.width == 100 && @c.height == 100, 'Failed to set size')
  27. end
  28. def test_import
  29. @c.import_memory("foo", "")
  30. assert_equal("foo\r\n", @c.export_memory("irc"), "Import/Export failed")
  31. end
  32. def test_cursor
  33. @c.gotoxy(1,1)
  34. assert_equal(1, @c.cursor_x)
  35. assert_equal(1, @c.cursor_y)
  36. end
  37. def test_clear
  38. @c.put_char(1, 1, 64)
  39. @c.clear
  40. assert_equal("", @c.export_memory("irc").strip, "Failed to clear canvas")
  41. end
  42. def test_char
  43. @c.put_char(1, 1, 42)
  44. assert_equal(42, @c.get_char(1,1))
  45. end
  46. end