Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

simple.c 1.5 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * simple simple testsuite program
  3. * Copyright (c) 2007 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. #if !defined(__KERNEL__)
  16. # include <stdio.h>
  17. # include <stdlib.h>
  18. #endif
  19. #include "cucul.h"
  20. #define TEST(x) \
  21. do \
  22. { \
  23. tests++; \
  24. if((x)) \
  25. passed++; \
  26. else \
  27. fprintf(stderr, "test #%i failed\n", (tests)); \
  28. } \
  29. while(0)
  30. int main(int argc, char *argv[])
  31. {
  32. cucul_canvas_t *cv;
  33. int tests = 0, passed = 0;
  34. cv = cucul_create_canvas(0, 0);
  35. cucul_put_char(cv, 0, 0, 'x');
  36. TEST(cucul_get_char(cv, 0, 0) != 'x');
  37. cucul_set_canvas_size(cv, 1, 1);
  38. TEST(cucul_get_char(cv, 0, 0) != 'x');
  39. TEST(cucul_get_char(cv, 0, 0) == ' ');
  40. cucul_put_char(cv, 0, 0, 'y');
  41. TEST(cucul_get_char(cv, 0, 0) == 'y');
  42. cucul_set_canvas_size(cv, 1000, 1000);
  43. TEST(cucul_get_canvas_width(cv) == 1000);
  44. cucul_put_char(cv, 999, 999, 'z');
  45. TEST(cucul_get_char(cv, 999, 999) == 'z');
  46. cucul_free_canvas(cv);
  47. fprintf(stderr, "%i tests, %i errors\n", tests, tests - passed);
  48. return 0;
  49. }