+ return errors;
+}
+
+/*
+ String tools related tests.
+*/
+static int str_tests() {
+ int j;
+ char* buf = "2,Fred,Wilma,Barney,Betty,Dino,Pebbles,Bambam,Mr. Slate,Gazoo";
+ int errors = 0;
+
+ j = uta_has_str( buf, "Mr. Slate", ',', 1 ); // should fail (-1) because user should use strcmp in this situation
+ errors += fail_if_true( j >= 0, "test to ensure has str rejects small max" );
+
+ j = uta_has_str( buf, "Mr. Slate", ',', 27 );
+ errors += fail_if_true( j < 0, "has string did not find Mr. Slate" );
+
+ j = uta_has_str( buf, "Mrs. Slate", ',', 27 );
+ errors += fail_if_true( j >= 0, "has string not found Mrs. Slate" );
+
+ return errors;
+}
+
+/*
+ Tests related to host name tools.
+*/
+static int hostname_tests() {
+ int errors = 0;
+ char* hname;
+
+
+ hname = uta_h2ip( "192.168.1.2" );
+ errors += fail_not_equal( strcmp( hname, "192.168.1.2" ), 0, "h2ip did not return IP address when given address" );
+ errors += fail_if_nil( hname, "h2ip did not return a pointer" );
+ free( hname );
+
+ hname = uta_h2ip( "yahoo.com" );
+ errors += fail_if_nil( hname, "h2ip did not return a pointer" );
+ free( hname );
+
+ hname = uta_h2ip( "yahoo.com:1234" ); // should ignore the port
+ errors += fail_if_nil( hname, "h2ip did not return a pointer" );
+ free( hname );
+
+ hname = uta_h2ip( "bugaboofoo.com:1234" ); // should not be there
+ errors += fail_not_nil( hname, "h2ip lookup returned non-nil when given bogus name" );
+
+ return errors;
+}
+
+/*
+ Misc coverage mostly.
+*/
+static int misc_tests() {
+ int errors = 0;
+ int v;
+ if_addrs_t* ifl; // interface list
+
+ if( (ifl = get_iflist( 1 )) != NULL ) {
+ v = is_this_myip( ifl, NULL );
+ errors += fail_if_false( v == 0, "is this my ip didn't fail when given nil address" );
+ }
+
+ return errors;
+}
+// ----------------------------------------------------------------------------------------------------------------------
+
+
+/*
+ Primary test function driven by the testing main().
+*/
+static int tools_test( ) {
+ int errors = 0;
+
+ uta_dump_env();
+
+ errors += tok_tests();
+ errors += my_ip();
+ errors += str_tests();
+ errors += hostname_tests();
+ errors += ztbf_test();