summaryrefslogtreecommitdiff
path: root/test/tokeniser.c
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@netsurf-browser.org>2009-02-14 11:12:22 +0000
committerDaniel Silverstone <dsilvers@netsurf-browser.org>2009-02-14 11:12:22 +0000
commit4456645b451300aff4a763e966746e247ec5ae39 (patch)
tree0e2d93b749e073e79336601a0aee6c3306456960 /test/tokeniser.c
parent472d9ed91f2e43642edd7ae92269b76a293e004e (diff)
downloadlibhubbub-4456645b451300aff4a763e966746e247ec5ae39.tar.gz
libhubbub-4456645b451300aff4a763e966746e247ec5ae39.tar.bz2
Allow TESTTYPE=release to be specified to build the tests with the release CFLAGS.
Add TARGET to the build paths. You should 'make distclean' before updating to this. Add BUILD_SHARED=yes support to the *nix build svn path=/trunk/hubbub/; revision=6478
Diffstat (limited to 'test/tokeniser.c')
-rw-r--r--test/tokeniser.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/test/tokeniser.c b/test/tokeniser.c
index 0614e78..29a2a7e 100644
--- a/test/tokeniser.c
+++ b/test/tokeniser.c
@@ -59,31 +59,22 @@ int main(int argc, char **argv)
origlen = len = ftell(fp);
fseek(fp, 0, SEEK_SET);
- while (len >= CHUNK_SIZE) {
- fread(buf, 1, CHUNK_SIZE, fp);
-
- assert(parserutils_inputstream_append(stream,
- buf, CHUNK_SIZE) == HUBBUB_OK);
-
- len -= CHUNK_SIZE;
-
- assert(hubbub_tokeniser_run(tok) == HUBBUB_OK);
- }
-
- if (len > 0) {
- fread(buf, 1, len, fp);
-
+ while (len > 0) {
+ ssize_t bytes_read = fread(buf, 1, CHUNK_SIZE, fp);
+
+ if (bytes_read < 1)
+ break;
+
assert(parserutils_inputstream_append(stream,
- buf, len) == HUBBUB_OK);
+ buf, bytes_read) == HUBBUB_OK);
- len = 0;
-
- assert(parserutils_inputstream_append(stream, NULL, 0) ==
- HUBBUB_OK);
+ len -= bytes_read;
assert(hubbub_tokeniser_run(tok) == HUBBUB_OK);
}
-
+
+ assert(len == 0);
+
fclose(fp);
hubbub_tokeniser_destroy(tok);