From: Wouter Wijngaards Date: Mon, 5 Feb 2007 14:57:16 +0000 (+0000) Subject: added unit test. X-Git-Tag: release-0.0~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e1071511ab29b5a100a4388124d17ed4d4539356;p=thirdparty%2Funbound.git added unit test. git-svn-id: file:///svn/unbound/trunk@67 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/doc/Changelog b/doc/Changelog index d85b6677d..3afc8fa52 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -2,6 +2,7 @@ - Picked up stdc99 and other define tests from ldns. Improved POSIX define test to include getaddrinfo. - defined constants for netevent callback error code. + - unit test for strisip6. 2 February 2007: Wouter - Created udp4 and udp6 port arrays to provide service for both diff --git a/testcode/unitmain.c b/testcode/unitmain.c index 0627b7ddd..c9a53895a 100644 --- a/testcode/unitmain.c +++ b/testcode/unitmain.c @@ -40,6 +40,26 @@ */ #include "config.h" +#include "util/log.h" + +/** number of tests done */ +int testcount = 0; +/** test bool x, exits on failure, increases testcount. */ +#define unit_assert(x) testcount++; log_assert(x); + +/** test net code */ +#include "services/outside_network.h" +static void net_test() +{ + unit_assert( str_is_ip6("::") ); + unit_assert( str_is_ip6("::1") ); + unit_assert( str_is_ip6("2001:7b8:206:1:240:f4ff:fe37:8810") ); + unit_assert( str_is_ip6("fe80::240:f4ff:fe37:8810") ); + unit_assert( !str_is_ip6("0.0.0.0") ); + unit_assert( !str_is_ip6("213.154.224.12") ); + unit_assert( !str_is_ip6("213.154.224.255") ); + unit_assert( !str_is_ip6("255.255.255.0") ); +} /** * Main unit test program. Setup, teardown and report errors. @@ -54,5 +74,7 @@ int main(int argc, char* argv[]) return 1; } printf("Start of %s unit test.\n", PACKAGE_STRING); + net_test(); + printf("%d tests succeeded\n", testcount); return 0; }