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 regels
1.4 KiB

  1. /*
  2. * bug-setlocale: unit test for wrong setlocale() calls
  3. * Copyright (c) 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. # include <string.h>
  17. #endif
  18. #include "caca.h"
  19. #define TEST(x) \
  20. do \
  21. { \
  22. tests++; \
  23. if((x)) \
  24. passed++; \
  25. else \
  26. fprintf(stderr, "test #%i failed: %s\n", (tests), #x); \
  27. } \
  28. while(0)
  29. int main(int argc, char *argv[])
  30. {
  31. char buf[10];
  32. char const * const * list;
  33. list = caca_get_display_driver_list();
  34. int i, tests = 0, passed = 0;
  35. snprintf(buf, 10, "%.1f", 0.0f);
  36. TEST(buf[1] == '.');
  37. for (i = 0; list[i]; i += 2)
  38. {
  39. if (!strcmp(list[i], "x11") || !strcmp(list[i], "ncurses"))
  40. {
  41. caca_display_t *dp = caca_create_display_with_driver(NULL, list[i]);
  42. snprintf(buf, 10, "%.1f", 0.0f);
  43. TEST(buf[1] == '.');
  44. caca_free_display(dp);
  45. }
  46. }
  47. fprintf(stderr, "%i tests, %i errors\n", tests, tests - passed);
  48. return 0;
  49. }