Commit 924b873b authored by Daniel Salzman's avatar Daniel Salzman

tests: add tests for yparser

parent 8482de78
......@@ -368,6 +368,9 @@ tests/utils.c
tests/wire.c
tests/worker_pool.c
tests/worker_queue.c
tests/yparser.c
tests/ypscheme.c
tests/yptrafo.c
tests/zone_events.c
tests/zone_timers.c
tests/zone_update.c
......
......@@ -40,6 +40,9 @@ utils
wire
worker_pool
worker_queue
yparser
ypscheme
yptrafo
zone_events
zone_timers
zone_update
......
......@@ -5,6 +5,7 @@ AM_CPPFLAGS = \
LDADD = \
$(top_builddir)/libtap/libtap.a \
$(top_builddir)/src/libknot-int.la \
$(top_builddir)/src/libknotd.la
check_PROGRAMS = \
......@@ -44,6 +45,9 @@ check_PROGRAMS = \
wire \
worker_pool \
worker_queue \
yparser \
ypscheme \
yptrafo \
zone_events \
zone_timers \
zone_update \
......
/* Copyright (C) 2015 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <tap/basic.h>
#include "libknot/internal/yparser/yparser.h"
#include "libknot/errcode.h"
const char *syntax =
"a:\n"
"a :\n"
"a : #comment\n"
"\n"
"b:\"b\"\n"
"b: \"b\"\n"
"b:b#comment\n"
"b: b #comment\n"
"b :b\n"
"b : b\n"
"b: [b]#comment\n"
"b: [ b] # comment\n"
"b: [b ]\n"
"b: [ b ]\n"
"\n"
" f:\"f\"\n"
" f: \"f\"\n"
" f:f#comment\n"
" f: f #comment\n"
" f :f\n"
" f : f\n"
" f: [f]#comment\n"
" f: [ f] # comment\n"
" f: [f ]\n"
" f: [ f ]\n"
"\n"
"c: a b\n"
"c: a,b\n"
"c: a, b\n"
"c: a ,b\n"
"c: a , b\n"
"c: [a b]\n"
"c: [a,b]\n"
"c: [a, b]\n"
"c: [a ,b]\n"
"c: [a , b]\n"
"c: [ a , b ]\n"
"\n"
"-d:d\n"
" -d:d\n"
" - d:d\n"
" - d: d\n"
" - d :d\n"
" - d : d\n"
"\n"
"e: \"a#b' c[d,]\"";
int main(int argc, char *argv[])
{
plan_lazy();
int ret;
size_t line;
yp_parser_t *yp = yp_create();
ok(yp != NULL, "create yparser");
ret = yp_set_input_string(yp, syntax, strlen(syntax));
ok(ret == KNOT_EOK, "set input string");
line = 1;
for (int i = 0; i < 3; i++) {
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse %i. key0", i);
ok(yp->key_len == 1 && yp->key[0] == 'a' &&
yp->data_len == 0 && yp->event == YP_EKEY0 &&
yp->line_count == line + i, "compare %i. key0", i);
}
line = 5;
for (int i = 0; i < 10; i++) {
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse %i. key0 with value", i);
ok(yp->key_len == 1 && yp->key[0] == 'b' &&
yp->data_len == 1 && yp->key[0] == 'b' &&
yp->event == YP_EKEY0 && yp->line_count == line + i,
"compare %i. key0 with value", i);
}
line = 16;
for (int i = 0; i < 10; i++) {
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse %i. key1 with value", i);
ok(yp->key_len == 1 && yp->key[0] == 'f' &&
yp->data_len == 1 && yp->key[0] == 'f' &&
yp->event == YP_EKEY1 && yp->line_count == line + i,
"compare %i. key1 with value", i);
}
line = 27;
for (int i = 0; i < 11; i++) {
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse %i. key0 with first value", i);
ok(yp->key_len == 1 && yp->key[0] == 'c' &&
yp->data_len == 1 && yp->data[0] == 'a' &&
yp->event == YP_EKEY0 && yp->line_count == line + i,
"compare %i. key0 with first value", i);
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse %i. key0 with second value", i);
ok(yp->key_len == 1 && yp->key[0] == 'c' &&
yp->data_len == 1 && yp->data[0] == 'b' &&
yp->event == YP_EKEY0 && yp->line_count == line + i,
"compare %i. key0 with second value", i);
}
line = 39;
for (int i = 0; i < 6; i++) {
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse %i. id", i);
ok(yp->key_len == 1 && yp->key[0] == 'd' &&
yp->data_len == 1 && yp->key[0] == 'd' &&
yp->event == YP_EID && yp->line_count == line + i,
"compare %i. id", i);
}
line = 46;
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse key0 with quoted value");
ok(yp->key_len == 1 && yp->key[0] == 'e' && yp->data_len == 10 &&
memcmp(yp->data, "a#b' c[d,]", yp->data_len) == 0 &&
yp->event == YP_EKEY0 && yp->line_count == line,
"compare key0 with quoted value");
ret = yp_parse(yp);
ok(ret == KNOT_EOF, "parse EOF");
yp_free(yp);
return 0;
}
/* Copyright (C) 2015 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <tap/basic.h>
#include "libknot/internal/yparser/ypscheme.h"
#include "libknot/internal/yparser/yptrafo.h"
#include "libknot/errcode.h"
#define C_ID "\x02""id"
#define C_INT "\x07""integer"
#define C_BOOL "\x04""bool"
#define C_OPT "\x06""option"
#define C_STR "\x06""string"
#define C_ADDR "\x07""address"
#define C_NET "\x07""network"
#define C_DNAME "\x06""domain"
#define C_BASE64 "\x06""base64"
#define C_REF "\x09""reference"
#define C_GRP "\x05""group"
#define C_MULTIGRP "\x0B""multi-group"
static const yp_item_t group[] = {
{ C_INT, YP_TINT, YP_VINT = { 0, 100, YP_NIL } },
{ C_STR, YP_TSTR, YP_VNONE, YP_FMULTI },
{ NULL }
};
static const yp_item_t multi_group[] = {
{ C_ID, YP_TSTR, YP_VNONE },
{ C_BASE64, YP_TB64, YP_VNONE },
{ NULL }
};
static const lookup_table_t opts[] = {
{ 1, "one" },
{ 10, "ten" },
{ 0, NULL }
};
static const yp_item_t static_scheme[] = {
{ C_OPT, YP_TOPT, YP_VOPT = { opts } },
{ C_GRP, YP_TGRP, YP_VGRP = { group } },
{ C_MULTIGRP, YP_TGRP, YP_VGRP = { multi_group }, YP_FMULTI },
{ C_REF, YP_TREF, YP_VREF = { C_MULTIGRP } },
{ NULL }
};
int main(int argc, char *argv[])
{
plan_lazy();
int ret;
const char *str;
yp_item_t *scheme;
ret = yp_scheme_copy(&scheme, static_scheme);
ok(ret == KNOT_EOK, "scheme copy");
yp_parser_t *yp = yp_create();
ok(yp != NULL, "create yparser");
yp_check_ctx_t *ctx = yp_scheme_check_init(scheme);
ok(ctx != NULL, "create check ctx");
/* Key0 test. */
str = "option: one";
ret = yp_set_input_string(yp, str, strlen(str));
ok(ret == KNOT_EOK, "set input string");
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse");
ret = yp_scheme_check_parser(ctx, yp);
ok(ret == KNOT_EOK, "check parser");
ok(ctx->event == YP_EKEY0, "event check");
ok(strcmp(ctx->key0->name + 1, "option") == 0, "name check");
ok(ctx->key0->type == YP_TOPT, "type check");
ok(yp_opt(ctx->data) == 1, "value check");
/* Group test. */
str = "group:\n integer: 20\n string: short, \"long string\"";
ret = yp_set_input_string(yp, str, strlen(str));
ok(ret == KNOT_EOK, "set input string");
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse");
ret = yp_scheme_check_parser(ctx, yp);
ok(ret == KNOT_EOK, "check parser");
ok(ctx->event == YP_EKEY0, "event check");
ok(strcmp(ctx->key0->name + 1, "group") == 0, "name check");
ok(ctx->key0->type == YP_TGRP, "type check");
ok(ctx->data_len == 0, "value length check");
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse");
ret = yp_scheme_check_parser(ctx, yp);
ok(ret == KNOT_EOK, "check parser");
ok(ctx->event == YP_EKEY1, "event check");
ok(strcmp(ctx->key1->name + 1, "integer") == 0, "name check");
ok(ctx->key1->type == YP_TINT, "type check");
ok(yp_int(ctx->data, ctx->data_len) == 20, "value check");
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse");
ret = yp_scheme_check_parser(ctx, yp);
ok(ret == KNOT_EOK, "check parser");
ok(ctx->event == YP_EKEY1, "event check");
ok(strcmp(ctx->key1->name + 1, "string") == 0, "name check");
ok(ctx->key1->type == YP_TSTR, "type check");
ok(strcmp(yp_str(ctx->data), "short") == 0, "value check");
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse");
ret = yp_scheme_check_parser(ctx, yp);
ok(ret == KNOT_EOK, "check parser");
ok(ctx->event == YP_EKEY1, "event check");
ok(strcmp(ctx->key1->name + 1, "string") == 0, "name check");
ok(ctx->key1->type == YP_TSTR, "type check");
ok(strcmp(yp_str(ctx->data), "long string") == 0, "value check");
/* Multi-group test. */
str = "multi-group:\n - id: foo\n base64: Zm9vYmFy\nreference: foo";
ret = yp_set_input_string(yp, str, strlen(str));
ok(ret == KNOT_EOK, "set input string");
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse");
ret = yp_scheme_check_parser(ctx, yp);
ok(ret == KNOT_EOK, "check parser");
ok(ctx->event == YP_EKEY0, "event check");
ok(strcmp(ctx->key0->name + 1, "multi-group") == 0, "name check");
ok(ctx->key0->type == YP_TGRP, "type check");
ok(ctx->data_len == 0, "value length check");
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse");
ret = yp_scheme_check_parser(ctx, yp);
ok(ret == KNOT_EOK, "check parser");
ok(ctx->event == YP_EID, "event check");
ok(strcmp(ctx->key1->name + 1, "id") == 0, "name check");
ok(ctx->key1->type == YP_TSTR, "type check");
ok(strcmp(yp_str(ctx->id), "foo") == 0, "value check");
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse");
ret = yp_scheme_check_parser(ctx, yp);
ok(ret == KNOT_EOK, "check parser");
ok(ctx->event == YP_EKEY1, "event check");
ok(strcmp(ctx->key1->name + 1, "base64") == 0, "name check");
ok(ctx->key1->type == YP_TB64, "type check");
ok(memcmp(yp_data(ctx->data), "foobar", ctx->data_len) == 0, "value check");
ret = yp_parse(yp);
ok(ret == KNOT_EOK, "parse");
ret = yp_scheme_check_parser(ctx, yp);
ok(ret == KNOT_EOK, "check parser");
ok(ctx->event == YP_EKEY0, "event check");
ok(strcmp(ctx->key0->name + 1, "reference") == 0, "name check");
ok(ctx->key0->type == YP_TREF, "type check");
ok(strcmp(yp_str(ctx->data), "foo") == 0, "value check");
/* Scheme find tests. */
const yp_item_t *i = yp_scheme_find(C_OPT, NULL, scheme);
ok(i != NULL, "scheme find");
ok(strcmp(i->name + 1, "option") == 0, "name check");
i = yp_scheme_find(C_STR, C_GRP, scheme);
ok(i != NULL, "scheme find");
ok(strcmp(i->name + 1, "string") == 0, "name check");
yp_scheme_check_deinit(ctx);
yp_free(yp);
yp_scheme_free(scheme);
return 0;
}
/* Copyright (C) 2015 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <tap/basic.h>
#include "libknot/internal/yparser/yptrafo.h"
#include "libknot/internal/sockaddr.h"
#include "libknot/errcode.h"
static void int_test(const char *txt, int64_t num, yp_style_t s,
int64_t min, int64_t max)
{
int ret;
uint8_t b[64];
size_t b_len = sizeof(b);
char t[64];
size_t t_len = sizeof(t);
yp_item_t i = { NULL, YP_TINT, YP_VINT = { min, max, YP_NIL, s } };
diag("integer \"%s\":", txt);
ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len);
ok(ret == KNOT_EOK, "txt to bin");
ok(yp_int(b, b_len) == num, "compare");
ret = yp_item_to_txt(&i, b, b_len, t, &t_len, s | YP_SNOQUOTE);
ok(ret == KNOT_EOK, "bin to txt");
ok(strlen(t) == t_len, "txt length");
ok(memcmp(txt, t, t_len) == 0, "compare");
}
static void int_bad_test(const char *txt, int code, yp_style_t s,
int64_t min, int64_t max)
{
int ret;
uint8_t b[64];
size_t b_len = sizeof(b);
yp_item_t i = { NULL, YP_TINT, YP_VINT = { min, max, YP_NIL, s } };
diag("integer \"%s\":", txt);
ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len);
ok(ret == code, "invalid txt to bin");
}
static void bool_test(const char *txt, bool val)
{
int ret;
uint8_t b[64];
size_t b_len = sizeof(b);
char t[64];
size_t t_len = sizeof(t);
yp_item_t i = { NULL, YP_TBOOL, YP_VNONE };
diag("boolean \"%s\":", txt);
ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len);
ok(ret == KNOT_EOK, "txt to bin");
ok(yp_bool(b_len) == val, "compare");
ret = yp_item_to_txt(&i, b, b_len, t, &t_len, YP_SNOQUOTE);
ok(ret == KNOT_EOK, "bin to txt");
ok(strlen(t) == t_len, "txt length");
ok(memcmp(txt, t, t_len) == 0, "compare");
}
static void bool_bad_test(const char *txt, int code)
{
int ret;
uint8_t b[64];
size_t b_len = sizeof(b);
yp_item_t i = { NULL, YP_TBOOL, YP_VNONE };
diag("boolean \"%s\":", txt);
ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len);
ok(ret == code, "invalid txt to bin");
}
static void opt_test(const char *txt, unsigned val, const lookup_table_t *opts)
{
int ret;
uint8_t b[64];
size_t b_len = sizeof(b);
char t[64];
size_t t_len = sizeof(t);
yp_item_t i = { NULL, YP_TOPT, YP_VOPT = { opts } };
diag("option \"%s\":", txt);
ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len);
ok(ret == KNOT_EOK, "txt to bin");
ok(b_len == 1, "compare length");
ok(yp_opt(b) == val, "compare");
ret = yp_item_to_txt(&i, b, b_len, t, &t_len, YP_SNOQUOTE);
ok(ret == KNOT_EOK, "bin to txt");
ok(strlen(t) == t_len, "txt length");
ok(memcmp(txt, t, t_len) == 0, "compare");
}
static void opt_bad_test(const char *txt, int code, const lookup_table_t *opts)
{
int ret;
uint8_t b[64];
size_t b_len = sizeof(b);
yp_item_t i = { NULL, YP_TOPT, YP_VOPT = { opts } };
diag("option \"%s\":", txt);
ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len);
ok(ret == code, "invalid txt to bin");
}
static void str_test(const char *txt, const char *val)
{
int ret;
uint8_t b[64];
size_t b_len = sizeof(b);
char t[64];
size_t t_len = sizeof(t);
yp_item_t i = { NULL, YP_TSTR, YP_VNONE };
diag("string \"%s\":", txt);
ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len);
ok(ret == KNOT_EOK, "txt to bin");
ok(b_len == strlen(txt) + 1, "compare length");
ok(memcmp(yp_str(b), val, b_len) == 0, "compare");
ret = yp_item_to_txt(&i, b, b_len, t, &t_len, YP_SNOQUOTE);
ok(ret == KNOT_EOK, "bin to txt");
ok(strlen(t) == t_len, "txt length");
ok(memcmp(txt, t, t_len) == 0, "compare");
}
static void addr_test(const char *txt, int port)
{
int ret;
uint8_t b[64];
size_t b_len = sizeof(b);
char t[64];
size_t t_len = sizeof(t);
yp_item_t i = { NULL, YP_TADDR, YP_VNONE };
diag("address \"%s\":", txt);
ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len);
ok(ret == KNOT_EOK, "txt to bin");
int num;
yp_addr(b, b_len, &num);
ok(num == port, "compare port");
ret = yp_item_to_txt(&i, b, b_len, t, &t_len, YP_SNOQUOTE);
ok(ret == KNOT_EOK, "bin to txt");
ok(strlen(t) == t_len, "txt length");
ok(memcmp(txt, t, t_len) == 0, "compare");
}
static void addr_bad_test(const char *txt, int code)
{
int ret;
uint8_t b[64];
size_t b_len = sizeof(b);
yp_item_t i = { NULL, YP_TADDR, YP_VNONE };
diag("address \"%s\":", txt);
ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len);
ok(ret == code, "invalid txt to bin");
}
static void net_test(const char *txt, int mask)
{
int ret;
uint8_t b[64];
size_t b_len = sizeof(b);
char t[64];
size_t t_len = sizeof(t);
yp_item_t i = { NULL, YP_TNET, YP_VNONE };
diag("network \"%s\":", txt);
ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len);
ok(ret == KNOT_EOK, "txt to bin");
int num;
yp_addr(b, b_len, &num);
ok(num == mask, "compare mask");
ret = yp_item_to_txt(&i, b, b_len, t, &t_len, YP_SNOQUOTE);
ok(ret == KNOT_EOK, "bin to txt");
ok(strlen(t) == t_len, "txt length");
ok(memcmp(txt, t, t_len) == 0, "compare");
}
static void net_bad_test(const char *txt, int code)
{
int ret;
uint8_t b[64];
size_t b_len = sizeof(b);
yp_item_t i = { NULL, YP_TNET, YP_VNONE };
diag("network \"%s\":", txt);
ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len);
ok(ret == code, "invalid txt to bin");
}
static void dname_test(const char *txt, const char *val)
{
int ret;
uint8_t b[64];
size_t b_len = sizeof(b);
char t[64];
size_t t_len = sizeof(t);
yp_item_t i = { NULL, YP_TDNAME, YP_VNONE };
diag("dname \"%s\":", txt);
ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len);
ok(ret == KNOT_EOK, "txt to bin");
ok(memcmp(yp_dname(b), val, b_len) == 0, "compare");
ret = yp_item_to_txt(&i, b, b_len, t, &t_len, YP_SNOQUOTE);
ok(ret == KNOT_EOK, "bin to txt");
ok(strlen(t) == t_len, "txt length");
ok(memcmp(txt, t, t_len) == 0, "compare");
}
static void base64_test(const char *txt, const char *val)
{
int ret;
uint8_t b[64];
size_t b_len = sizeof(b);
char t[64];
size_t t_len = sizeof(t);
yp_item_t i = { NULL, YP_TB64, YP_VNONE };
diag("base64 \"%s\":", txt);
ret = yp_item_to_bin(&i, txt, strlen(txt), b, &b_len);
ok(ret == KNOT_EOK, "txt to bin");
ok(memcmp(yp_data(b), val, b_len) == 0, "compare");
ret = yp_item_to_txt(&i, b, b_len, t, &t_len, YP_SNOQUOTE);
ok(ret == KNOT_EOK, "bin to txt");
ok(strlen(t) == t_len, "txt length");
ok(memcmp(txt, t, t_len) == 0, "compare");
}
int main(int argc, char *argv[])
{
plan_lazy();
/* Integer tests. */
int64_t min = -20000000000, max = 20000000000;
int_test("5", 5, YP_SNONE, min, max);
int_test("0", 0, YP_SNONE, min, max);
int_test("-5", -5, YP_SNONE, min, max);
int_test("20000000000", max, YP_SNONE, min, max);
int_test("-20000000000", min, YP_SNONE, min, max);
int_test("11B", 11LL * 1, YP_SSIZE, min, max);
int_test("11K", 11LL * 1024, YP_SSIZE, min, max);
int_test("11M", 11LL * 1024 * 1024, YP_SSIZE, min, max);
int_test("11G", 11LL * 1024 * 1024 * 1024, YP_SSIZE, min, max);
int_test("11s", 11LL * 1, YP_STIME, min, max);
int_test("11m", 11LL * 60, YP_STIME, min, max);
int_test("11h", 11LL * 3600, YP_STIME, min, max);
int_test("11d", 11LL * 24 * 3600, YP_STIME, min, max);
int_bad_test("20000000001", KNOT_ERANGE, YP_SNONE, min, max);
int_bad_test("-20000000001", KNOT_ERANGE, YP_SNONE, min, max);
int_bad_test("1X", KNOT_EINVAL, YP_SNONE, min, max);
/* Boolean tests. */
bool_test("on", true);
bool_test("off", false);
bool_bad_test("enable", KNOT_EINVAL);
/* Option tests. */
static const lookup_table_t opts[] = {
{ 1, "one" },
{ 10, "ten" },
{ 255, "max" },
{ 0, NULL }
};
opt_test("one", 1, opts);
opt_test("ten", 10, opts);
opt_test("max", 255, opts);
opt_bad_test("word", KNOT_EINVAL, opts);
/* String tests. */
str_test("Test string!", "Test string!");
/* Address tests. */
addr_test("192.168.123.1", -1);
addr_test("192.168.123.1@12345", 12345);
addr_test("2001:db8::1", -1);
addr_test("::1@12345", 12345);
addr_test("/tmp/test.sock", -1);
addr_bad_test("192.168.123.1@65536", KNOT_ERANGE);
/* Network tests. */
net_test("192.168.123.1", -1);
net_test("192.168.123.1/32", 32);
net_test("2001:db8::1", -1);
net_test("::1/128", 128);
net_bad_test("192.168.123.1/33", KNOT_ERANGE);
net_bad_test("::1/129", KNOT_ERANGE);
net_bad_test("/tmp/test.sock", KNOT_EINVAL);
/* Dname tests. */
dname_test("example.com.", "\x07""example""\x03""com""\x00");
/* Base64 tests. */
base64_test("Zm9vYmFy", "foobar");
/* TODO: data, ref tests. */
return 0;
}
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