summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/INDEX2
-rw-r--r--test/Makefile4
-rw-r--r--test/csdetect.c11
-rw-r--r--test/dict.c52
-rw-r--r--test/entities.c13
-rw-r--r--test/hubbub.c29
-rw-r--r--test/parser.c5
-rw-r--r--test/tokeniser.c5
-rw-r--r--test/tokeniser2.c5
-rw-r--r--test/tokeniser3.c5
-rw-r--r--test/tree-buf.c5
-rw-r--r--test/tree.c5
-rw-r--r--test/tree2.c5
13 files changed, 3 insertions, 143 deletions
diff --git a/test/INDEX b/test/INDEX
index 94ba83b..a89931b 100644
--- a/test/INDEX
+++ b/test/INDEX
@@ -2,8 +2,6 @@
#
# Test Description DataDir
-hubbub Library initialisation/finalisation
-dict Generic string dictionary
entities Named entity dictionary
csdetect Charset detection csdetect
parser Public parser API html
diff --git a/test/Makefile b/test/Makefile
index db3f9fe..916b89f 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,6 +1,6 @@
# Tests
-DIR_TEST_ITEMS := csdetect:csdetect.c dict:dict.c entities:entities.c \
- hubbub:hubbub.c parser:parser.c tokeniser:tokeniser.c \
+DIR_TEST_ITEMS := csdetect:csdetect.c entities:entities.c \
+ parser:parser.c tokeniser:tokeniser.c \
tokeniser2:tokeniser2.c tokeniser3:tokeniser3.c tree:tree.c \
tree2:tree2.c tree-buf:tree-buf.c
diff --git a/test/csdetect.c b/test/csdetect.c
index d02efcb..de94852 100644
--- a/test/csdetect.c
+++ b/test/csdetect.c
@@ -25,13 +25,6 @@ typedef struct line_ctx {
static bool handle_line(const char *data, size_t datalen, void *pw);
static void run_test(const uint8_t *data, size_t len, char *expected);
-static void *myrealloc(void *ptr, size_t len, void *pw)
-{
- UNUSED(pw);
-
- return realloc(ptr, len);
-}
-
int main(int argc, char **argv)
{
line_ctx ctx;
@@ -41,8 +34,6 @@ int main(int argc, char **argv)
return 1;
}
- assert(hubbub_initialise(argv[1], myrealloc, NULL) == HUBBUB_OK);
-
ctx.buflen = parse_filesize(argv[2]);
if (ctx.buflen == 0)
return 1;
@@ -70,8 +61,6 @@ int main(int argc, char **argv)
free(ctx.buf);
- assert(hubbub_finalise(myrealloc, NULL) == HUBBUB_OK);
-
printf("PASS\n");
return 0;
diff --git a/test/dict.c b/test/dict.c
deleted file mode 100644
index 9ba05fd..0000000
--- a/test/dict.c
+++ /dev/null
@@ -1,52 +0,0 @@
-#include "utils/dict.h"
-
-#include "testutils.h"
-
-static void *myrealloc(void *ptr, size_t len, void *pw)
-{
- UNUSED(pw);
-
- return realloc(ptr, len);
-}
-
-int main(int argc, char **argv)
-{
- hubbub_dict *dict;
- const void *result;
- void *context = NULL;
-
- UNUSED(argc);
- UNUSED(argv);
-
- assert(hubbub_dict_create(myrealloc, NULL, &dict) == HUBBUB_OK);
-
- assert(hubbub_dict_insert(dict, "Hello", (const void *) 123) ==
- HUBBUB_OK);
- assert(hubbub_dict_insert(dict, "Hello1", (const void *) 456) ==
- HUBBUB_OK);
-
- assert(hubbub_dict_search_step(dict, 'H', &result, &context) ==
- HUBBUB_NEEDDATA);
- assert(hubbub_dict_search_step(dict, 'e', &result, &context) ==
- HUBBUB_NEEDDATA);
- assert(hubbub_dict_search_step(dict, 'l', &result, &context) ==
- HUBBUB_NEEDDATA);
- assert(hubbub_dict_search_step(dict, 'l', &result, &context) ==
- HUBBUB_NEEDDATA);
- assert(hubbub_dict_search_step(dict, 'o', &result, &context) ==
- HUBBUB_OK);
- assert(result == (const void *) 123);
- assert(hubbub_dict_search_step(dict, '1', &result, &context) ==
- HUBBUB_OK);
- assert(result == (const void *) 456);
- assert(hubbub_dict_search_step(dict, '\0', &result, &context) ==
- HUBBUB_OK);
- assert(hubbub_dict_search_step(dict, 'x', &result, &context) ==
- HUBBUB_INVALID);
-
- hubbub_dict_destroy(dict);
-
- printf("PASS\n");
-
- return 0;
-}
diff --git a/test/entities.c b/test/entities.c
index f340a58..f730f17 100644
--- a/test/entities.c
+++ b/test/entities.c
@@ -2,23 +2,14 @@
#include "testutils.h"
-static void *myrealloc(void *ptr, size_t len, void *pw)
-{
- UNUSED(pw);
-
- return realloc(ptr, len);
-}
-
int main(int argc, char **argv)
{
uint32_t result;
- void *context = NULL;
+ int32_t context = -1;
UNUSED(argc);
UNUSED(argv);
- assert(hubbub_entities_create(myrealloc, NULL) == HUBBUB_OK);
-
assert(hubbub_entities_search_step('A', &result, &context) ==
HUBBUB_NEEDDATA);
@@ -40,8 +31,6 @@ int main(int argc, char **argv)
assert(hubbub_entities_search_step('z', &result, &context) ==
HUBBUB_INVALID);
- hubbub_entities_destroy(myrealloc, NULL);
-
printf("PASS\n");
return 0;
diff --git a/test/hubbub.c b/test/hubbub.c
deleted file mode 100644
index ed61bb3..0000000
--- a/test/hubbub.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <hubbub/hubbub.h>
-
-#include "testutils.h"
-
-static void *myrealloc(void *ptr, size_t len, void *pw)
-{
- UNUSED(pw);
-
- return realloc(ptr, len);
-}
-
-int main(int argc, char **argv)
-{
- if (argc != 2) {
- printf("Usage: %s <filename>\n", argv[0]);
- return 1;
- }
-
- assert(hubbub_initialise(argv[1], myrealloc, NULL) == HUBBUB_OK);
-
- assert (hubbub_finalise(myrealloc, NULL) == HUBBUB_OK);
-
- printf("PASS\n");
-
- return 0;
-}
diff --git a/test/parser.c b/test/parser.c
index 1f7010a..291587e 100644
--- a/test/parser.c
+++ b/test/parser.c
@@ -31,9 +31,6 @@ static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
UNUSED(argc);
- /* Initialise library */
- assert(hubbub_initialise(argv[1], myrealloc, NULL) == HUBBUB_OK);
-
assert(hubbub_parser_create("UTF-8", false, myrealloc, NULL, &parser) ==
HUBBUB_OK);
@@ -74,8 +71,6 @@ static int run_test(int argc, char **argv, unsigned int CHUNK_SIZE)
hubbub_parser_destroy(parser);
- assert(hubbub_finalise(myrealloc, NULL) == HUBBUB_OK);
-
printf("PASS\n");
return 0;
diff --git a/test/tokeniser.c b/test/tokeniser.c
index 29a2a7e..17c60f4 100644
--- a/test/tokeniser.c
+++ b/test/tokeniser.c
@@ -35,9 +35,6 @@ int main(int argc, char **argv)
return 1;
}
- /* Initialise library */
- assert(hubbub_initialise(argv[1], myrealloc, NULL) == HUBBUB_OK);
-
assert(parserutils_inputstream_create("UTF-8", 0, NULL,
myrealloc, NULL, &stream) == PARSERUTILS_OK);
@@ -81,8 +78,6 @@ int main(int argc, char **argv)
parserutils_inputstream_destroy(stream);
- assert(hubbub_finalise(myrealloc, NULL) == HUBBUB_OK);
-
printf("PASS\n");
return 0;
diff --git a/test/tokeniser2.c b/test/tokeniser2.c
index 82cbea0..a584f49 100644
--- a/test/tokeniser2.c
+++ b/test/tokeniser2.c
@@ -54,9 +54,6 @@ int main(int argc, char **argv)
return 1;
}
- /* Initialise library */
- assert(hubbub_initialise(argv[1], myrealloc, NULL) == HUBBUB_OK);
-
json = json_object_from_file(argv[2]);
assert(!is_error(json));
@@ -113,8 +110,6 @@ int main(int argc, char **argv)
json_object_put(json);
- assert(hubbub_finalise(myrealloc, NULL) == HUBBUB_OK);
-
printf("PASS\n");
return 0;
diff --git a/test/tokeniser3.c b/test/tokeniser3.c
index 70e1e53..8e8795e 100644
--- a/test/tokeniser3.c
+++ b/test/tokeniser3.c
@@ -52,9 +52,6 @@ int main(int argc, char **argv)
return 1;
}
- /* Initialise library */
- assert(hubbub_initialise(argv[1], myrealloc, NULL) == HUBBUB_OK);
-
json = json_object_from_file(argv[2]);
assert(!is_error(json));
@@ -109,8 +106,6 @@ int main(int argc, char **argv)
run_test(&ctx);
}
- assert(hubbub_finalise(myrealloc, NULL) == HUBBUB_OK);
-
printf("PASS\n");
return 0;
diff --git a/test/tree-buf.c b/test/tree-buf.c
index 404c8f7..bfbf0a0 100644
--- a/test/tree-buf.c
+++ b/test/tree-buf.c
@@ -208,9 +208,6 @@ int main(int argc, char **argv)
return 1;
}
- /* Initialise library */
- assert(hubbub_initialise(argv[1], myrealloc, NULL) == HUBBUB_OK);
-
fp = fopen(argv[2], "rb");
if (fp == NULL) {
printf("Failed opening %s\n", argv[2]);
@@ -271,8 +268,6 @@ int main(int argc, char **argv)
free(got.buf);
- assert(hubbub_finalise(myrealloc, NULL) == HUBBUB_OK);
-
return 0;
}
diff --git a/test/tree.c b/test/tree.c
index 9f48922..3cfb849 100644
--- a/test/tree.c
+++ b/test/tree.c
@@ -174,16 +174,11 @@ int main(int argc, char **argv)
return 1;
}
- /* Initialise library */
- assert(hubbub_initialise(argv[1], myrealloc, NULL) == HUBBUB_OK);
-
#define DO_TEST(n) if ((ret = run_test(argc, argv, (n))) != 0) return ret
for (shift = 0; (1 << shift) != 16384; shift++)
for (offset = 0; offset < 10; offset += 3)
DO_TEST((1 << shift) + offset);
- assert(hubbub_finalise(myrealloc, NULL) == HUBBUB_OK);
-
return 0;
#undef DO_TEST
}
diff --git a/test/tree2.c b/test/tree2.c
index ee24655..9c5a4a3 100644
--- a/test/tree2.c
+++ b/test/tree2.c
@@ -229,9 +229,6 @@ int main(int argc, char **argv)
return 1;
}
- /* Initialise library */
- assert(hubbub_initialise(argv[1], myrealloc, NULL) == HUBBUB_OK);
-
fp = fopen(argv[2], "rb");
if (fp == NULL) {
printf("Failed opening %s\n", argv[2]);
@@ -350,8 +347,6 @@ int main(int argc, char **argv)
free(got.buf);
free(expected.buf);
- assert(hubbub_finalise(myrealloc, NULL) == HUBBUB_OK);
-
return 0;
}