[test] Parsing command-line arguments on Windows
Hi,
Here is table with four example of command-line input on Windows
and expected values of 'argv' elements, according to the rules when
interpreting arguments, escape sequences etc.:
https://msdn.microsoft.com/en-us/library/17w5ykft.aspx
Double-checking this actually works:
///////// Windows console program //////////////////////////////////
#include <cstdio>
int main(int argc, char* argv[])
{
for (int i = 0; i < argc; ++i) std::printf("%d: %s\n", i, argv[i]);
}
F:\test_cpp2015\Debug>test_cpp2015.exe "abc" d e
0: test_cpp2015.exe
1: abc
2: d
3: e
F:\test_cpp2015\Debug>test_cpp2015.exe a\\b d"e f"g h
0: test_cpp2015.exe
1: a\\b
2: de fg
3: h
F:\test_cpp2015\Debug>test_cpp2015.exe a\\\"b c d
0: test_cpp2015.exe
1: a\"b
2: c
3: d
F:\test_cpp2015\Debug>test_cpp2015.exe a\\\\"b c" d e
0: test_cpp2015.exe
1: a\\b c
2: d
3: e
//////////////////////////////////
Now, the same test but with values of framework::master_test_suite().argv
///////// Boost.Test program ///////////////////////////////////////
#define BOOST_TEST_MAIN
#include
On 26 November 2015 at 17:57, Mateusz Loskot
Here is table with four example of command-line input on Windows and expected values of 'argv' elements, according to the rules when interpreting arguments, escape sequences etc.: https://msdn.microsoft.com/en-us/library/17w5ykft.aspx [...] I can't see any caveats mentioned in the documentation http://www.boost.org/doc/libs/1_59_0/libs/test/doc/html/boost_test/tests_org...
I forgot to add why I started investigating it. I have Boost.Test-based program which I'm trying to feed with ODBC connection string given as command-line argument. Here similar exercise as in my first post where it shows master_test_suite().argv is having trouble to parse it properly: // The Windows console program test_cpp2015.exe "Driver={SQLite3 ODBC Driver};Database=test.db;" 0: test_cpp2015.exe 1: Driver={SQLite3 ODBC Driver};Database=test.db; // The Boost.Test program test_boost.exe "Driver={SQLite3 ODBC Driver};Database=test.db;" Running 1 test case... 0: %ΓΏ$ 1: Driver={SQLite3 2: ODBC 3: Driver};Database=nanodbc2.db; Best regards, -- Mateusz Loskot, http://mateusz.loskot.net
On 26 November 2015 at 17:57, Mateusz Loskot
Here is table with four example of command-line input on Windows and expected values of 'argv' elements, according to the rules when interpreting arguments, escape sequences etc.: https://msdn.microsoft.com/en-us/library/17w5ykft.aspx [...]
FYI, I have transformed the post to bug report - I believe it is unexpected behaviour: https://svn.boost.org/trac/boost/ticket/11825 Best regards, -- Mateusz Loskot, http://mateusz.loskot.net
On 30 November 2015 at 15:29, Mateusz Loskot
On 26 November 2015 at 17:57, Mateusz Loskot
wrote: Here is table with four example of command-line input on Windows and expected values of 'argv' elements, according to the rules when interpreting arguments, escape sequences etc.: https://msdn.microsoft.com/en-us/library/17w5ykft.aspx [...]
FYI, I have transformed the post to bug report - I believe it is unexpected behaviour: https://svn.boost.org/trac/boost/ticket/11825
FYI, there was a bug indeed which has been fixed in the current master branch (to be 1.60). Best regards, -- Mateusz Loskot, http://mateusz.loskot.net
participants (1)
-
Mateusz Loskot