Changeset 19949 in vbox
- Timestamp:
- May 23, 2009 10:21:46 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstCidr.cpp
r13837 r19949 5 5 6 6 /* 7 * Copyright (C) 2008 Sun Microsystems, Inc.7 * Copyright (C) 2008-2009 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 34 34 *******************************************************************************/ 35 35 #include <iprt/cidr.h> 36 36 37 #include <iprt/err.h> 37 #include <iprt/stream.h>38 38 #include <iprt/initterm.h> 39 #include <iprt/test.h> 39 40 40 41 … … 42 43 * Defined Constants And Macros * 43 44 *******************************************************************************/ 44 #define CHECKNETWORK( string, expected_result, expected_network, expected_netmask) \45 #define CHECKNETWORK(String, rcExpected, ExpectedNetwork, ExpectedNetMask) \ 45 46 do { \ 46 RTIPV4ADDR network, netmask; \47 int r esult = RTCidrStrToIPv4(string, &network, &netmask); \48 if ( expected_result && !result) \47 RTIPV4ADDR Network, NetMask; \ 48 int rc = RTCidrStrToIPv4(String, &Network, &NetMask); \ 49 if ((rcExpected) && !rc) \ 49 50 { \ 50 g_cErrors++; \ 51 RTPrintf("%s, %d: %s: expected %Rrc got %Rrc\n", \ 52 __FUNCTION__, __LINE__, string, expected_result, result); \ 51 RTTestIFailed("at line %d: '%s': expected %Rrc got %Rrc\n", \ 52 __LINE__, String, (rcExpected), rc); \ 53 53 } \ 54 else if ( expected_result != result\55 || ( r esult== VINF_SUCCESS \56 && ( expected_network != network \57 || expected_netmask != netmask))) \54 else if ( (rcExpected) != rc \ 55 || ( rc == VINF_SUCCESS \ 56 && ( (ExpectedNetwork) != Network \ 57 || (ExpectedNetMask) != NetMask))) \ 58 58 { \ 59 g_cErrors++; \ 60 RTPrintf("%s, %d: '%s': expected %Rrc got %Rrc, expected network %08x got %08x, expected netmask %08x got %08x\n", \ 61 __FUNCTION__, __LINE__, string, expected_result, result, expected_network, network, expected_netmask, netmask); \ 59 RTTestIFailed("at line %d: '%s': expected %Rrc got %Rrc, expected network %08x got %08x, expected netmask %08x got %08x\n", \ 60 __LINE__, String, rcExpected, rc, (ExpectedNetwork), Network, (ExpectedNetMask), NetMask); \ 62 61 } \ 63 62 } while (0) 64 63 65 64 66 /*******************************************************************************67 * Global Variables *68 *******************************************************************************/69 static unsigned g_cErrors = 0;70 71 72 65 int main() 73 66 { 74 RTR3Init(); 67 int rc = RTR3Init(); 68 if (RT_FAILURE(rc)) 69 return 1; 70 RTTEST hTest; 71 rc = RTTestCreate("tstRTCidr", &hTest); 72 if (RT_FAILURE(rc)) 73 return 1; 74 RTTestBanner(hTest); 75 75 76 CHECKNETWORK("10.0.0/24", VINF_SUCCESS, 0x0A000000, 0xFFFFFF00); 76 77 CHECKNETWORK("10.0.0/8", VINF_SUCCESS, 0x0A000000, 0xFF000000); … … 87 88 CHECKNETWORK("10.1.2/16", VINF_SUCCESS, 0x0A010200, 0xFFFF0000); 88 89 CHECKNETWORK("1.2.3.4", VINF_SUCCESS, 0x01020304, 0xFFFFFFFF); 89 if (!g_cErrors) 90 RTPrintf("tstIp: SUCCESS\n", g_cErrors); 91 else 92 RTPrintf("tstIp: FAILURE - %d errors\n", g_cErrors); 93 return !!g_cErrors; 90 91 return RTTestSummaryAndDestroy(hTest); 94 92 } 95 93
Note:
See TracChangeset
for help on using the changeset viewer.