aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_protover.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2020-10-14 13:05:00 -0400
committerNick Mathewson <nickm@torproject.org>2020-10-14 13:09:29 -0400
commit33fb51a111da68352183437332a8f01a4a57571d (patch)
treee1cec96a187c2be3c731159098befadee67bb180 /src/test/test_protover.c
parent4a80dde43c44e619a53547e73283602747cba370 (diff)
downloadtor-33fb51a111da68352183437332a8f01a4a57571d.tar.gz
tor-33fb51a111da68352183437332a8f01a4a57571d.zip
Protover: simplify implementation structure to use 64-bit property
Now that prop318 is in, we can simplify our representation for protocol range sets to just be a bitmask.
Diffstat (limited to 'src/test/test_protover.c')
-rw-r--r--src/test/test_protover.c38
1 files changed, 5 insertions, 33 deletions
diff --git a/src/test/test_protover.c b/src/test/test_protover.c
index f129aa7f1c..be3aeb5e40 100644
--- a/src/test/test_protover.c
+++ b/src/test/test_protover.c
@@ -39,53 +39,25 @@ test_protover_parse(void *arg)
tt_int_op(smartlist_len(elts), OP_EQ, 4);
const proto_entry_t *e;
- const proto_range_t *r;
e = smartlist_get(elts, 0);
tt_str_op(e->name, OP_EQ, "Foo");
- tt_int_op(smartlist_len(e->ranges), OP_EQ, 2);
- {
- r = smartlist_get(e->ranges, 0);
- tt_int_op(r->low, OP_EQ, 1);
- tt_int_op(r->high, OP_EQ, 1);
-
- r = smartlist_get(e->ranges, 1);
- tt_int_op(r->low, OP_EQ, 3);
- tt_int_op(r->high, OP_EQ, 3);
- }
+ tt_int_op(e->bitmask, OP_EQ, 0x0a);
e = smartlist_get(elts, 1);
tt_str_op(e->name, OP_EQ, "Bar");
- tt_int_op(smartlist_len(e->ranges), OP_EQ, 1);
- {
- r = smartlist_get(e->ranges, 0);
- tt_int_op(r->low, OP_EQ, 3);
- tt_int_op(r->high, OP_EQ, 3);
- }
+ tt_int_op(e->bitmask, OP_EQ, 0x08);
e = smartlist_get(elts, 2);
tt_str_op(e->name, OP_EQ, "Baz");
- tt_int_op(smartlist_len(e->ranges), OP_EQ, 0);
+ tt_int_op(e->bitmask, OP_EQ, 0x00);
e = smartlist_get(elts, 3);
tt_str_op(e->name, OP_EQ, "Quux");
- tt_int_op(smartlist_len(e->ranges), OP_EQ, 3);
- {
- r = smartlist_get(e->ranges, 0);
- tt_int_op(r->low, OP_EQ, 9);
- tt_int_op(r->high, OP_EQ, 12);
-
- r = smartlist_get(e->ranges, 1);
- tt_int_op(r->low, OP_EQ, 14);
- tt_int_op(r->high, OP_EQ, 14);
-
- r = smartlist_get(e->ranges, 2);
- tt_int_op(r->low, OP_EQ, 15);
- tt_int_op(r->high, OP_EQ, 16);
- }
+ tt_int_op(e->bitmask, OP_EQ, 0x1de00);
re_encoded = encode_protocol_list(elts);
tt_assert(re_encoded);
- tt_str_op(re_encoded, OP_EQ, orig);
+ tt_str_op(re_encoded, OP_EQ, "Foo=1,3 Bar=3 Baz= Quux=9-12,14-16");
done:
if (elts)