Commit 2968fdf2 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Add '<' and '>' operators

parent 9bcf907c
......@@ -57,3 +57,31 @@ logexpect l1 -d 1 -g vxid -q "RespStatus != 503." {
expect * = ReqEnd
expect * = End
} -run
# Test '<' operator on integers
logexpect l1 -d 1 -g vxid -q "RespStatus < 201" {
expect * * Begin req
expect * = ReqEnd
expect * = End
} -run
# Test '<' operator on floats
logexpect l1 -d 1 -g vxid -q "RespStatus < 201." {
expect * * Begin req
expect * = ReqEnd
expect * = End
} -run
# Test '>' operator on integers
logexpect l1 -d 1 -g vxid -q "RespStatus > 199" {
expect * * Begin req
expect * = ReqEnd
expect * = End
} -run
# Test '>' operator on floats
logexpect l1 -d 1 -g vxid -q "RespStatus > 199." {
expect * * Begin req
expect * = ReqEnd
expect * = End
} -run
......@@ -104,11 +104,11 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec)
case T_EQ: /* == */
switch (val->type) {
case VEX_INT:
if (val->val_int == recint)
if (recint == val->val_int)
return (1);
return (0);
case VEX_FLOAT:
if (val->val_float == recfloat)
if (recfloat == val->val_float)
return (1);
return (0);
default:
......@@ -117,11 +117,37 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec)
case T_NEQ: /* != */
switch (val->type) {
case VEX_INT:
if (val->val_int != recint)
if (recint != val->val_int)
return (1);
return (0);
case VEX_FLOAT:
if (val->val_float != recfloat)
if (recfloat != val->val_float)
return (1);
return (0);
default:
WRONG("Wrong value type");
}
case '<': /* < */
switch (val->type) {
case VEX_INT:
if (recint < val->val_int)
return (1);
return (0);
case VEX_FLOAT:
if (recfloat < val->val_float)
return (1);
return (0);
default:
WRONG("Wrong value type");
}
case '>':
switch (val->type) {
case VEX_INT:
if (recint > val->val_int)
return (1);
return (0);
case VEX_FLOAT:
if (recfloat > val->val_float)
return (1);
return (0);
default:
......@@ -130,13 +156,13 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec)
case T_SEQ: /* eq */
assert(val->type == VEX_STRING);
if (reclen == val->val_stringlen + 1 &&
!strncmp(val->val_string, recdata, reclen))
!strncmp(recdata, val->val_string, reclen))
return (1);
return (0);
case T_SNEQ: /* ne */
assert(val->type == VEX_STRING);
if (reclen != val->val_stringlen + 1 ||
strncmp(val->val_string, recdata, reclen))
strncmp(recdata, val->val_string, reclen))
return (1);
return (0);
default:
......
......@@ -199,6 +199,10 @@ vxp_expr_cmp(struct vxp *vxp, struct vex **pvex)
/* Valid operators */
case T_EQ: /* == */
case '<': /* < */
case '>': /* > */
case T_GEQ: /* >= */
case T_LEQ: /* <= */
case T_NEQ: /* != */
case T_SEQ: /* eq */
case T_SNEQ: /* ne */
......@@ -222,6 +226,8 @@ vxp_expr_cmp(struct vxp *vxp, struct vex **pvex)
case '\0':
WRONG("Missing token");
case T_EQ: /* == */
case '<': /* < */
case '>': /* > */
case T_GEQ: /* >= */
case T_LEQ: /* <= */
case T_NEQ: /* != */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment