Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/program_options/test/winmain.cpp @ 20

Last change on this file since 20 was 12, checked in by landauf, 17 years ago

added boost

File size: 1.6 KB
Line 
1// Copyright Vladimir Prus 2002-2004.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt
4// or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6#if defined(_WIN32)
7#include <string>
8#include <vector>
9#include <cctype>
10
11#include <boost/program_options/parsers.hpp>
12using namespace boost::program_options;
13
14#include <boost/test/test_tools.hpp>
15#include <boost/preprocessor/cat.hpp>
16
17void test_winmain()
18{
19    using namespace std;
20
21#define C ,
22#define TEST(input, expected) \
23    char* BOOST_PP_CAT(e, __LINE__)[] = expected;\
24    vector<string> BOOST_PP_CAT(v, __LINE__) = split_winmain(input);\
25    BOOST_CHECK_EQUAL_COLLECTIONS(BOOST_PP_CAT(v, __LINE__).begin(),\
26                                  BOOST_PP_CAT(v, __LINE__).end(),\
27                                  BOOST_PP_CAT(e, __LINE__),\
28                                  BOOST_PP_CAT(e, __LINE__) + \
29                        sizeof(BOOST_PP_CAT(e, __LINE__))/sizeof(char*));   
30
31// The following expectations were obtained in Win2000 shell:
32    TEST("1 ", {"1"});
33    TEST("1\"2\" ", {"12"});
34    TEST("1\"2  ", {"12  "});
35    TEST("1\"\\\"2\" ", {"1\"2"});
36    TEST("\"1\" \"2\" ", {"1" C "2"});
37    TEST("1\\\" ", {"1\""});
38    TEST("1\\\\\" ", {"1\\ "});
39    TEST("1\\\\\\\" ", {"1\\\""});
40    TEST("1\\\\\\\\\" ", {"1\\\\ "});
41
42    TEST("1\" 1 ", {"1 1 "});
43    TEST("1\\\" 1 ", {"1\"" C "1"});
44    TEST("1\\1 ", {"1\\1"});
45    TEST("1\\\\1 ", {"1\\\\1"});   
46}
47
48int test_main(int, char*[])
49{
50    test_winmain();
51    return 0;
52}
53#else
54int test_main(int, char*[])
55{
56    return 0;
57}
58#endif
Note: See TracBrowser for help on using the repository browser.