////////////////////////////////////////////////////////////////////// // Test "data" module // Written by Jonathan A. Foster // Started June 28th, 2021 // // NOTE: This is really incomplete. More tests to come. ////////////////////////////////////////////////////////////////////// #include #include #include #include "testit.h" #include "../data.h" ////////////////////////////////////////////////////////////////////// // TestIt Jig ////////////////////////////////////////////////////////////////////// TestIt test; ////////////////////////////////////////////////////////////////////// // Test 1 - Wild Card Address Comparisons ////////////////////////////////////////////////////////////////////// /// Table /// struct WildAddrTest { std::string addr1, addr2; int result; }; const int wild_addr_tests_ct = 13; WildAddrTest wild_addr_tests[wild_addr_tests_ct] = { // IPv4 {"192.168.255." , "192.168.255.7", 0}, {"192.168.255.7", "192.168.255." , 0}, {"192.168.255.7", "192.168.255.7", 0}, {"192.168.255.7", "192.168.255.8", -1}, {"192.168.254.7", "192.168.255." , -1}, {"192.168.256.7", "192.168.255." , 1}, {"*" , "192.168.255." , 0}, {"192.168.256.7", "*" , 0}, //IPv6 {"2001:0470:000a:0169:" , "2001:0470:000a:0169:0000:0000:0000:0001", 0}, {"2001:0470:000a:0169:0000:0000:0000:0002", "2001:0470:000a:0169:" , 0}, {"2001:0470:000a:0170:" , "2001:0470:000a:0169:0000:0000:0000:0003", 1}, {"2001:0470:000a:0168:0000:0000:0000:0004", "2001:0470:000a:0169:" , -1}, {"2001:0470:000a:0169:0000:0000:0000:0001", "2001:0470:000a:0169:0000:0000:0000:0001", 0}, }; bool wild_addr_test() { int i; bool ok = true; char s[256]; s[255]=0; test.module("Wild Card Address Match"); for(i=0; i