VirtualBox

Changeset 19949 in vbox


Ignore:
Timestamp:
May 23, 2009 10:21:46 PM (16 years ago)
Author:
vboxsync
Message:

tstCidr: Converted to RTTest.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/testcase/tstCidr.cpp

    r13837 r19949  
    55
    66/*
    7  * Copyright (C) 2008 Sun Microsystems, Inc.
     7 * Copyright (C) 2008-2009 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3434*******************************************************************************/
    3535#include <iprt/cidr.h>
     36
    3637#include <iprt/err.h>
    37 #include <iprt/stream.h>
    3838#include <iprt/initterm.h>
     39#include <iprt/test.h>
    3940
    4041
     
    4243*   Defined Constants And Macros                                               *
    4344*******************************************************************************/
    44 #define CHECKNETWORK(string, expected_result, expected_network, expected_netmask) \
     45#define CHECKNETWORK(String, rcExpected, ExpectedNetwork, ExpectedNetMask) \
    4546    do { \
    46         RTIPV4ADDR network, netmask; \
    47         int result = RTCidrStrToIPv4(string, &network, &netmask); \
    48         if (expected_result && !result) \
     47        RTIPV4ADDR Network, NetMask; \
     48        int rc = RTCidrStrToIPv4(String, &Network, &NetMask); \
     49        if ((rcExpected) && !rc) \
    4950        { \
    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); \
    5353        } \
    54         else if (   expected_result != result \
    55                  || (   result == 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))) \
    5858        { \
    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); \
    6261        } \
    6362    } while (0)
    6463
    6564
    66 /*******************************************************************************
    67 *   Global Variables                                                           *
    68 *******************************************************************************/
    69 static unsigned g_cErrors = 0;
    70 
    71 
    7265int main()
    7366{
    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
    7576    CHECKNETWORK("10.0.0/24",                VINF_SUCCESS, 0x0A000000, 0xFFFFFF00);
    7677    CHECKNETWORK("10.0.0/8",                 VINF_SUCCESS, 0x0A000000, 0xFF000000);
     
    8788    CHECKNETWORK("10.1.2/16",                VINF_SUCCESS, 0x0A010200, 0xFFFF0000);
    8889    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);
    9492}
    9593
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette