Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

70 řádky
1.7 KiB

  1. /*
  2. * all full libcaca API test
  3. * Copyright (c) 2006 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 <string.h>
  18. #endif
  19. #include "cucul.h"
  20. #include "caca.h"
  21. #define ITER 128
  22. int main(int argc, char *argv[])
  23. {
  24. cucul_canvas_t *cv;
  25. unsigned int i, j, w, h;
  26. fprintf(stderr, "testing cucul_create_canvas()\n");
  27. for(i = 0; i < ITER; i++)
  28. {
  29. w = cucul_rand(1, 1000);
  30. h = cucul_rand(1, 1000);
  31. cv = cucul_create_canvas(w, h);
  32. cucul_put_char(cv, w - 1, h - 1, 'x');
  33. if(cucul_get_char(cv, w - 1, h - 1) != 'x')
  34. fprintf(stderr, " failed (%ux%u)\n", w, h);
  35. cucul_free_canvas(cv);
  36. }
  37. fprintf(stderr, "testing cucul_set_frame_name()\n");
  38. cv = cucul_create_canvas(1, 1);
  39. if(cv == NULL)
  40. {
  41. printf("Failed to create canvas\n");
  42. return 1;
  43. }
  44. for(i = 0; i < ITER; i++)
  45. {
  46. cucul_create_frame(cv, 0);
  47. for(j = 0; j < ITER; j++)
  48. {
  49. char buf[BUFSIZ];
  50. w = cucul_rand(1, 1000);
  51. memset(buf, 'x', w);
  52. buf[w] = '\0';
  53. cucul_set_frame_name(cv, buf);
  54. }
  55. }
  56. cucul_free_canvas(cv);
  57. fprintf(stderr, "all tests passed\n");
  58. return 0;
  59. }