Now working with real xmls

This commit is contained in:
Tristan Roux
2019-12-06 14:00:45 +01:00
parent 49aa1ca861
commit cfe1e2c633
4 changed files with 28 additions and 2 deletions
+2 -1
View File
@@ -13,7 +13,8 @@ SRC = src/xmlparser.c \
OBJ = $(SRC:%.c=%.o)
TESTS = tests/test_basics.c
TESTS = tests/test_basics.c \
tests/tests_realxml.c
TEST_MAIN = tests/test_main.c
+3 -1
View File
@@ -32,6 +32,7 @@ int xml_handle_prolog(char **nodestr)
free(strconst);
return (-1);
}
*nodestr += 2;
return (0);
}
@@ -71,9 +72,10 @@ node *xmlparse(char *path)
if (fd < 0)
return (NULL);
fstat(fd, &stats);
nodestr = malloc(stats.st_size);
nodestr = malloc(stats.st_size + 1);
if (nodestr) {
count = read(fd, nodestr, stats.st_size);
nodestr[stats.st_size + 1] = '\0';
if (count == stats.st_size)
n = xml_parsestr(nodestr);
}
+23
View File
@@ -0,0 +1,23 @@
/*
** EPITECH PROJECT, 2019
** xmlparser
** File description:
** tests_realxml
*/
#include "xml.h"
#include <criterion/criterion.h>
#include <string.h>
Test(xml, complete)
{
node *n = xmlparse("tests/testprolog.txt");
cr_assert_str_eq(n->name, "yes");
cr_assert_eq(n->next, NULL);
cr_assert_eq(n->properties, NULL);
cr_assert_str_eq(n->child->name, "nop");
cr_assert_eq(n->child->child, NULL);
cr_assert_eq(n->child->properties, NULL);
cr_assert_eq(n->child->next, NULL);
}