Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

69 lignes
1.6 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 "caca.h"
  20. #define ITER 128
  21. int main(int argc, char *argv[])
  22. {
  23. caca_canvas_t *cv;
  24. unsigned int i, j, w, h;
  25. fprintf(stderr, "testing caca_create_canvas()\n");
  26. for(i = 0; i < ITER; i++)
  27. {
  28. w = caca_rand(1, 1000);
  29. h = caca_rand(1, 1000);
  30. cv = caca_create_canvas(w, h);
  31. caca_put_char(cv, w - 1, h - 1, 'x');
  32. if(caca_get_char(cv, w - 1, h - 1) != 'x')
  33. fprintf(stderr, " failed (%ux%u)\n", w, h);
  34. caca_free_canvas(cv);
  35. }
  36. fprintf(stderr, "testing caca_set_frame_name()\n");
  37. cv = caca_create_canvas(1, 1);
  38. if(cv == NULL)
  39. {
  40. printf("Failed to create canvas\n");
  41. return 1;
  42. }
  43. for(i = 0; i < ITER; i++)
  44. {
  45. caca_create_frame(cv, 0);
  46. for(j = 0; j < ITER; j++)
  47. {
  48. char buf[BUFSIZ];
  49. w = caca_rand(1, 1000);
  50. memset(buf, 'x', w);
  51. buf[w] = '\0';
  52. caca_set_frame_name(cv, buf);
  53. }
  54. }
  55. caca_free_canvas(cv);
  56. fprintf(stderr, "all tests passed\n");
  57. return 0;
  58. }