From: Tomas Krizek Date: Thu, 25 Nov 2021 11:14:31 +0000 (+0100) Subject: config.basic: test coverage for parse_rdata() X-Git-Tag: v5.4.3~2^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=abb562ead2dd39f3ec8a2c833a495b8bd67e8a28;p=thirdparty%2Fknot-resolver.git config.basic: test coverage for parse_rdata() --- diff --git a/tests/config/basic.test.lua b/tests/config/basic.test.lua index af9a5847c..73356a43d 100644 --- a/tests/config/basic.test.lua +++ b/tests/config/basic.test.lua @@ -31,6 +31,15 @@ local function test_globals() same(table_print({fakepizza=1}), "{\n ['fakepizza'] = 1,\n}", 'table print works on tables') end +-- test global API functions +local function test_global_functions() + boom(kres.parse_rdata, {'A 127.0.0.1'}, 'parse_rdata with non-table argument') + boom(kres.parse_rdata, {{1}}, 'parse_rdata with non-string data in arg table') + same(kres.parse_rdata({'A 127.0.0.1'}), {string.char(127, 0, 0, 1)}, 'parse_rdata with single record') + same(kres.parse_rdata({'A 127.0.0.1', 'A 127.0.0.2'}), + {string.char(127, 0, 0, 1), string.char(127, 0, 0, 2)}, 'parse_rdata with multiple records') +end + -- test if dns library functions work local function test_rrset_functions() local rr = {owner = '\3com\0', ttl = 1, type = kres.type.TXT, rdata = '\5hello'} @@ -195,6 +204,7 @@ end return { test_constants, test_globals, + test_global_functions, test_rrset_functions, test_packet_functions, test_json_functions,