mirror of
https://github.com/zoriya/xmlParser.git
synced 2026-05-24 23:15:01 +00:00
Now working with real xmls
This commit is contained in:
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user