tstRTGetOptArgv.cpp revision b6cc4092c1e80655a5bc19dc125e772a8d2b870d
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * IPRT Testcase - RTGetOptArgv*.
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * Copyright (C) 2010 Sun Microsystems, Inc.
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * available from http://www.virtualbox.org. This file is free software;
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * you can redistribute it and/or modify it under the terms of the GNU
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * General Public License (GPL) as published by the Free Software
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * The contents of this file may alternatively be used under the terms
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * of the Common Development and Distribution License Version 1.0
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * VirtualBox OSE distribution, in which case the provisions of the
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * CDDL are applicable instead of those of the GPL.
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * You may elect to license modified versions of this file under the
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * terms and conditions of either the GPL or the CDDL or both.
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * additional information or have any questions.
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync/*******************************************************************************
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync* Header Files *
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync*******************************************************************************/
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsyncstatic void tst1(void)
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync RTTESTI_CHECK_RC_RETV(RTGetOptArgvFromString(&papszArgs, &cArgs, "", NULL), VINF_SUCCESS);
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync RTTESTI_CHECK_RC_RETV(RTGetOptArgvFromString(&papszArgs, &cArgs, "0 1 \"\"2'' '3' 4 5 '''''6' 7 8 9 10 11", NULL), VINF_SUCCESS);
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync RTTESTI_CHECK_RC_RETV(RTGetOptArgvFromString(&papszArgs, &cArgs, "\t\" asdf \" '\"'xyz \"\t\" '\n' '\"' \"'\"\n\r ", NULL), VINF_SUCCESS);
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync RTTESTI_CHECK_RETV(!strcmp(papszArgs[0], " asdf "));
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync RTTESTI_CHECK_RETV(!strcmp(papszArgs[1], "\"xyz"));
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync RTTESTI_CHECK_RC_RETV(RTGetOptArgvFromString(&papszArgs, &cArgs, ":0::1::::2:3:4:5:", ":"), VINF_SUCCESS);
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync RTTESTI_CHECK_RC_RETV(RTGetOptArgvFromString(&papszArgs, &cArgs, "0:1;2:3;4:5", ";;;;;;;;;;;;;;;;;;;;;;:"), VINF_SUCCESS);
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * Init RT+Test.
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync int rc = RTTestInitAndCreate("tstRTGetOptArgv", &hTest);
b6cc4092c1e80655a5bc19dc125e772a8d2b870dvboxsync * The test.