Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

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