]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
added unit test.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 5 Feb 2007 14:57:16 +0000 (14:57 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 5 Feb 2007 14:57:16 +0000 (14:57 +0000)
git-svn-id: file:///svn/unbound/trunk@67 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
testcode/unitmain.c

index d85b6677de164e53bcfdc3e1fe50ba2621ed741d..3afc8fa52dedbc88844114bbb828ef138f97286c 100644 (file)
@@ -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
index 0627b7ddd347c38ff7e4a8ef129ebc9581ce5f08..c9a53895a6b701f2186392265d3df5b98c98045b 100644 (file)
  */
 
 #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;
 }