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.
 
 
 
 
 
 

103 lines
2.7 KiB

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