Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

59 righe
1.7 KiB

  1. require 'caca'
  2. class TC_Canvas < Test::Unit::TestCase
  3. def setup
  4. @c = Caca::Canvas.new(3, 3)
  5. end
  6. def test_create
  7. c = Caca::Canvas.new(3, 3)
  8. assert_not_nil(c, 'Canvas creation failed')
  9. assert(c.width == 3 && c.height == 3, 'Wrong size for new canvas')
  10. end
  11. def test_width
  12. @c.width = 42
  13. assert_equal(42, @c.width, 'Failed to set width with =')
  14. @c.set_width(24)
  15. assert_equal(24, @c.width, 'Failed to set width')
  16. end
  17. def test_height
  18. @c.height = 42
  19. assert_equal(42, @c.height, 'Failed to set height with =')
  20. @c.set_height(24)
  21. assert_equal(24, @c.height, 'Failed to set height')
  22. end
  23. def test_size
  24. @c.set_size(100,100)
  25. assert(@c.width == 100 && @c.height == 100, 'Failed to set size')
  26. end
  27. def test_import
  28. @c.import_from_memory("foo", "")
  29. assert_equal("foo\r\n", @c.export_to_memory("irc"), "Import/Export failed")
  30. end
  31. def test_cursor
  32. @c.gotoxy(1,1)
  33. assert_equal(1, @c.wherex)
  34. assert_equal(1, @c.wherey)
  35. end
  36. def test_clear
  37. @c.put_char(1, 1, 64)
  38. @c.clear
  39. assert_equal("", @c.export_to_memory("irc").strip, "Failed to clear canvas")
  40. end
  41. def test_char
  42. @c.put_char(1, 1, 42)
  43. assert_equal(42, @c.get_char(1,1))
  44. end
  45. def test_render
  46. c = Caca::Canvas.new(4,4)
  47. c.put_str(0,0,"plop")
  48. f = Caca::Font.new(Caca::Font.list[0])
  49. assert_not_nil(c.render(f, c.width*f.width, c.height*f.height, c.width*f.width*4))
  50. end
  51. def test_fail_render
  52. c = Caca::Canvas.new(4,4)
  53. assert_raise(ArgumentError) {
  54. c.render(nil, c.width, c.height, c.width*4)
  55. }
  56. end
  57. end