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.
 
 
 
 
 
 

104 righe
2.8 KiB

  1. /*
  2. * cucul-test testsuite program for libcucul
  3. * Copyright (c) 2008 Sam Hocevar <sam@zoy.org>
  4. * Copyright (c) 2008 Sam Hocevar <sam@zoy.org>
  5. * All Rights Reserved
  6. *
  7. * $Id$
  8. *
  9. * This program is free software. It comes without any warranty, to
  10. * the extent permitted by applicable law. You can redistribute it
  11. * and/or modify it under the terms of the Do What The Fuck You Want
  12. * To Public License, Version 2, as published by Sam Hocevar. See
  13. * http://sam.zoy.org/wtfpl/COPYING for more details.
  14. */
  15. #include "config.h"
  16. #include <cppunit/extensions/HelperMacros.h>
  17. #include <cppunit/TestCaller.h>
  18. #include <cppunit/TestCase.h>
  19. #include <cppunit/TestSuite.h>
  20. #include "cucul.h"
  21. class CanvasTest : public CppUnit::TestCase
  22. {
  23. CPPUNIT_TEST_SUITE(CanvasTest);
  24. CPPUNIT_TEST(test_creation);
  25. CPPUNIT_TEST(test_resize);
  26. CPPUNIT_TEST(test_chars);
  27. CPPUNIT_TEST_SUITE_END();
  28. public:
  29. CanvasTest() : CppUnit::TestCase("Canvas Test") {}
  30. void setUp() {}
  31. void tearDown() {}
  32. void test_creation()
  33. {
  34. cucul_canvas_t *cv;
  35. cv = cucul_create_canvas(0, 0);
  36. CPPUNIT_ASSERT(cv != NULL);
  37. cucul_free_canvas(cv);
  38. }
  39. void test_resize()
  40. {
  41. cucul_canvas_t *cv;
  42. cv = cucul_create_canvas(0, 0);
  43. CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_width(cv), 0U);
  44. CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_height(cv), 0U);
  45. cucul_set_canvas_size(cv, 1, 1);
  46. CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_width(cv), 1U);
  47. CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_height(cv), 1U);
  48. cucul_set_canvas_size(cv, 1234, 1001);
  49. CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_width(cv), 1234U);
  50. CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_height(cv), 1001U);
  51. cucul_set_canvas_size(cv, 0, 0);
  52. CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_width(cv), 0U);
  53. CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_height(cv), 0U);
  54. cucul_free_canvas(cv);
  55. }
  56. void test_chars()
  57. {
  58. cucul_canvas_t *cv;
  59. cv = cucul_create_canvas(0, 0);
  60. CPPUNIT_ASSERT(cucul_get_char(cv, 0, 0) == ' ');
  61. cucul_put_char(cv, 0, 0, 'x');
  62. CPPUNIT_ASSERT(cucul_get_char(cv, 0, 0) == ' ');
  63. cucul_set_canvas_size(cv, 1, 1);
  64. CPPUNIT_ASSERT(cucul_get_char(cv, 0, 0) == ' ');
  65. cucul_put_char(cv, 0, 0, 'x');
  66. CPPUNIT_ASSERT(cucul_get_char(cv, 0, 0) == 'x');
  67. cucul_put_char(cv, 0, 0, 'y');
  68. CPPUNIT_ASSERT(cucul_get_char(cv, 0, 0) == 'y');
  69. cucul_set_canvas_size(cv, 1000, 1000);
  70. CPPUNIT_ASSERT(cucul_get_char(cv, 999, 999) == ' ');
  71. cucul_put_char(cv, 999, 999, 'z');
  72. CPPUNIT_ASSERT(cucul_get_char(cv, 999, 999) == 'z');
  73. cucul_free_canvas(cv);
  74. }
  75. };
  76. CPPUNIT_TEST_SUITE_REGISTRATION(CanvasTest);