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.
 
 
 
 
 
 

64 rivejä
1.5 KiB

  1. /*
  2. * simple simple testsuite program
  3. * Copyright © 2007—2016 Sam Hocevar <sam@hocevar.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://www.wtfpl.net/ for more details.
  11. */
  12. #include "config.h"
  13. #if !defined(__KERNEL__)
  14. # include <stdio.h>
  15. # include <stdlib.h>
  16. #endif
  17. #include "caca.h"
  18. #define TEST(x) \
  19. do \
  20. { \
  21. tests++; \
  22. if((x)) \
  23. passed++; \
  24. else \
  25. fprintf(stderr, "test #%i failed: %s\n", (tests), #x); \
  26. } \
  27. while(0)
  28. int main(int argc, char *argv[])
  29. {
  30. caca_canvas_t *cv;
  31. int tests = 0, passed = 0;
  32. cv = caca_create_canvas(0, 0);
  33. caca_put_char(cv, 0, 0, 'x');
  34. TEST(caca_get_char(cv, 0, 0) != 'x');
  35. caca_rotate_180(cv);
  36. caca_set_canvas_size(cv, 1, 1);
  37. TEST(caca_get_char(cv, 0, 0) != 'x');
  38. TEST(caca_get_char(cv, 0, 0) == ' ');
  39. caca_put_char(cv, 0, 0, 'y');
  40. TEST(caca_get_char(cv, 0, 0) == 'y');
  41. caca_set_canvas_size(cv, 1000, 1000);
  42. TEST(caca_get_canvas_width(cv) == 1000);
  43. caca_put_char(cv, 999, 999, 'z');
  44. TEST(caca_get_char(cv, 999, 999) == 'z');
  45. caca_free_canvas(cv);
  46. fprintf(stderr, "%i tests, %i errors\n", tests, tests - passed);
  47. return 0;
  48. }