diff options
author | Joel Rosdahl <joel@rosdahl.net> | 2020-07-29 14:29:14 +0200 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2020-07-29 16:43:59 +0200 |
commit | 88ecdc34365974186cd8248e88029d89ff4cfd85 (patch) | |
tree | d5dfc6f7818c20b07b565df80cd1fc300c6c47d5 /unittest/test_Win32Util.cpp | |
parent | 5a4c7d45456b1f1a6d57ae749b5254345066c9c5 (diff) | |
download | ccache-88ecdc34365974186cd8248e88029d89ff4cfd85.tar.gz |
C++-ify win32argvtos
Diffstat (limited to 'unittest/test_Win32Util.cpp')
-rw-r--r-- | unittest/test_Win32Util.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/unittest/test_Win32Util.cpp b/unittest/test_Win32Util.cpp new file mode 100644 index 00000000..eb7dc8f5 --- /dev/null +++ b/unittest/test_Win32Util.cpp @@ -0,0 +1,43 @@ +// Copyright (C) 2020 Joel Rosdahl and other contributors +// +// See doc/AUTHORS.adoc for a complete list of contributors. +// +// This program is free software; you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 3 of the License, or (at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +// more details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the Free Software Foundation, Inc., 51 +// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +#include "../src/Win32Util.hpp" +#include "TestUtil.hpp" + +#include "third_party/doctest.h" + +TEST_SUITE_BEGIN("Win32Util"); + +TEST_CASE("Win32Util::argv_to_string") +{ + { + const char* const argv[] = {"a", nullptr}; + CHECK(Win32Util::argv_to_string(argv, "") == R"("a")"); + } + { + const char* const argv[] = {"a", nullptr}; + CHECK(Win32Util::argv_to_string(argv, "p") == R"("p" "a")"); + } + { + const char* const argv[] = {"a", "b c", "\"d\"", "'e'", "\\\"h", nullptr}; + CHECK(Win32Util::argv_to_string(argv, "") + == R"("a" "b c" "\"d\"" "'e'" "\\\"h")"); + } +} + +TEST_SUITE_END(); |