hl_html.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * This program is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU General Public License
  4. * as published by the Free Software Foundation; either version 2
  5. * of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. * Author: g0tsu
  12. * Email: g0tsu at dnmx.0rg
  13. */
  14. #include <config.h>
  15. #ifdef CONFIG_USE_HTML
  16. #include <libhighlight.h>
  17. #include <assert.h>
  18. #include <unistd.h>
  19. #include <string.h>
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. char *test_str[] = {
  23. "// this is a single line comment",
  24. "int hello; //world",
  25. "void hello (int world, char *p) {\n if ( a==3) { printf(\"hello\"); } \n}\n",
  26. "#include <stdio.h>\nint main(int ac, char **av) { \n int a = 1; return 0; \n}\n",
  27. "char *a = \"hello \\\"world\\\"\n 'and bye'\";\n",
  28. "t",
  29. "tc",
  30. "/* \n * multiline \n comment */",
  31. "char *c = \"hello <wordl>\";\n"
  32. };
  33. int ts_len = 9;
  34. static int compile_html1() {
  35. size_t rlen;
  36. hl_root *res;
  37. char *html;
  38. char *str = test_str[1];
  39. assert((res = hl_parser(str, strlen(str), NULL)));
  40. assert((html = hl_compile_html(res)));
  41. hl_root_free(res);
  42. free(html);
  43. str = test_str[7];
  44. assert((res = hl_parser(str, strlen(str), NULL)));
  45. assert((html = hl_compile_html(res)));
  46. hl_root_free(res);
  47. free(html);
  48. str = test_str[8];
  49. assert((res = hl_parser(str, strlen(str), NULL)));
  50. assert((html = hl_compile_html(res)));
  51. hl_root_free(res);
  52. /* printf("%s\n", html);*/
  53. free(html);
  54. }
  55. int main() {
  56. assert(!compile_html1());
  57. return 0;
  58. }
  59. #endif