hl_node.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 <libhighlight.h>
  15. #include <assert.h>
  16. #include <string.h>
  17. int simple_create_free() {
  18. hl_node * root = hl_node_create();
  19. assert(root != NULL);
  20. hl_node_free(root);
  21. return 0;
  22. }
  23. int simple_insert_free() {
  24. hl_node *node = hl_node_create();
  25. node->text = strdup("hello");
  26. node = hl_node_insert(node);
  27. node->text = strdup("world12345");
  28. node = hl_node_insert(node);
  29. node->text = strdup("hhhhhhhhhhhhhhhh");
  30. node = hl_node_insert(node);
  31. while (node->children) {
  32. node = node->children;
  33. }
  34. for (int i = 0; i < 3; i++) {
  35. node = hl_node_at(node, i);
  36. /* printf("%s\n", node->text);*/
  37. }
  38. hl_node_free(node);
  39. return 0;
  40. }
  41. /*
  42. * Kinda simple linked list tester
  43. */
  44. int main() {
  45. assert(!simple_create_free());
  46. assert(!simple_insert_free());
  47. return 0;
  48. }