summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-05-26 01:02:43 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-05-26 01:02:43 +0000
commiteb6a36696e4eedd330ba966ae56329d29bc7ebf0 (patch)
treef925f3b3ddd5a02bba9cd87ae1d714366c869504 /test
parentb0ecb2bc565b44ceabf5b91176d96a5b01fbc99c (diff)
downloadlibcss-eb6a36696e4eedd330ba966ae56329d29bc7ebf0.tar.gz
libcss-eb6a36696e4eedd330ba966ae56329d29bc7ebf0.tar.bz2
Fix automated lexer test code to correctly handle escape sequences and the absence of expected text.
svn path=/trunk/libcss/; revision=7548
Diffstat (limited to 'test')
-rw-r--r--test/lex-auto.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/test/lex-auto.c b/test/lex-auto.c
index 56a06eb..65118d6 100644
--- a/test/lex-auto.c
+++ b/test/lex-auto.c
@@ -19,6 +19,7 @@ typedef struct exp_entry {
#define EXP_ENTRY_TEXT_LEN (128)
char text[EXP_ENTRY_TEXT_LEN];
size_t textLen;
+ bool hasText;
} exp_entry;
typedef struct line_ctx {
@@ -162,6 +163,8 @@ void parse_expected(line_ctx *ctx, const char *data, size_t len)
ctx->exp[ctx->expused].type = type;
ctx->exp[ctx->expused].textLen = 0;
+ ctx->exp[ctx->expused].hasText = (colon != data + len);
+
if (colon != data + len) {
const char *p = colon + 1;
bool escape = false;
@@ -169,7 +172,7 @@ void parse_expected(line_ctx *ctx, const char *data, size_t len)
for (len = len - (colon + 1 - data); len > 0; len--, p++) {
char c;
- if (*p == '\\') {
+ if (escape == false && *p == '\\') {
escape = true;
continue;
}
@@ -297,7 +300,7 @@ void run_test(const uint8_t *data, size_t len, exp_entry *exp, size_t explen)
assert(0 && "Types differ");
}
- if (exp[e].textLen > 0) {
+ if (exp[e].hasText) {
if (tok->data.len != exp[e].textLen) {
printf("%d: Got length %d, Expected %d\n",
testnum, (int) tok->data.len,