summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeLib
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/CMakeLib')
-rw-r--r--Tests/CMakeLib/CMakeLists.txt75
-rw-r--r--Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt26
-rw-r--r--Tests/CMakeLib/PseudoMemcheck/NoLog/CMakeLists.txt14
-rw-r--r--Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in54
-rw-r--r--Tests/CMakeLib/run_compile_commands.cxx159
-rw-r--r--Tests/CMakeLib/testAffinity.cxx18
-rw-r--r--Tests/CMakeLib/testArgumentParser.cxx149
-rw-r--r--Tests/CMakeLib/testCMExtAlgorithm.cxx118
-rw-r--r--Tests/CMakeLib/testCMExtMemory.cxx65
-rw-r--r--Tests/CMakeLib/testCTestBinPacker.cxx300
-rw-r--r--Tests/CMakeLib/testCTestResourceAllocator.cxx426
-rw-r--r--Tests/CMakeLib/testCTestResourceGroups.cxx141
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec.cxx119
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec1.json27
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec10.json15
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec11.json16
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec12.json1
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec13.json1
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec14.json12
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec15.json12
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec16.json12
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec17.json15
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec18.json15
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec19.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec2.json8
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec20.json8
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec21.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec22.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec23.json7
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec24.json7
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec25.json8
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec26.json8
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec27.json8
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec28.json8
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec29.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec3.json12
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec30.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec31.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec32.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec33.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec34.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec35.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec36.json4
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec4.json8
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec5.json6
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec6.json9
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec7.json12
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec8.json13
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec9.json14
-rw-r--r--Tests/CMakeLib/testEncoding.cxx52
-rw-r--r--Tests/CMakeLib/testFindPackageCommand.cxx71
-rw-r--r--Tests/CMakeLib/testGccDepfileReader.cxx131
-rw-r--r--Tests/CMakeLib/testGccDepfileReader_data/deps1.d20
-rw-r--r--Tests/CMakeLib/testGccDepfileReader_data/deps1.txt26
-rw-r--r--Tests/CMakeLib/testGccDepfileReader_data/deps2.d1
-rw-r--r--Tests/CMakeLib/testGccDepfileReader_data/deps2.txt5
-rw-r--r--Tests/CMakeLib/testGccDepfileReader_data/deps3.d2
-rw-r--r--Tests/CMakeLib/testGccDepfileReader_data/deps3.txt11
-rw-r--r--Tests/CMakeLib/testGeneratedFileStream.cxx88
-rw-r--r--Tests/CMakeLib/testOptional.cxx701
-rw-r--r--Tests/CMakeLib/testRST.cxx86
-rw-r--r--Tests/CMakeLib/testRST.expect103
-rw-r--r--Tests/CMakeLib/testRST.rst110
-rw-r--r--Tests/CMakeLib/testRSTinclude1.rst6
-rw-r--r--Tests/CMakeLib/testRSTinclude2.rst3
-rw-r--r--Tests/CMakeLib/testRSTmod.cmake11
-rw-r--r--Tests/CMakeLib/testRSTtoc1.rst2
-rw-r--r--Tests/CMakeLib/testRSTtoc2.rst2
-rw-r--r--Tests/CMakeLib/testRange.cxx45
-rw-r--r--Tests/CMakeLib/testString.cxx1349
-rw-r--r--Tests/CMakeLib/testStringAlgorithms.cxx230
-rw-r--r--Tests/CMakeLib/testSystemTools.cxx99
-rw-r--r--Tests/CMakeLib/testUTF8.cxx197
-rw-r--r--Tests/CMakeLib/testUVProcessChain.cxx334
-rw-r--r--Tests/CMakeLib/testUVProcessChainHelper.cxx72
-rw-r--r--Tests/CMakeLib/testUVRAII.cxx230
-rw-r--r--Tests/CMakeLib/testUVStreambuf.cxx455
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser.cxx195
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser.h.in7
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/.gitattributes1
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/bom.sln-file2
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-data.sln-file6
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-empty.sln-file0
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-global.sln-file9
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-header.sln-file4
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectArgs.sln-file4
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectContents.sln-file6
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectSection.sln-file11
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayParen.sln-file4
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayQuote.sln-file4
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayQuote2.sln-file4
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-topLevel.sln-file4
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-unclosed.sln-file5
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/nobom.sln-file2
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/valid.sln-file680
-rw-r--r--Tests/CMakeLib/testXMLParser.cxx16
-rw-r--r--Tests/CMakeLib/testXMLParser.h.in6
-rw-r--r--Tests/CMakeLib/testXMLParser.xml4
-rw-r--r--Tests/CMakeLib/testXMLSafe.cxx42
99 files changed, 7438 insertions, 0 deletions
diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt
new file mode 100644
index 0000000..bb50d76
--- /dev/null
+++ b/Tests/CMakeLib/CMakeLists.txt
@@ -0,0 +1,75 @@
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMake_BINARY_DIR}/Source
+ ${CMake_SOURCE_DIR}/Source
+ ${CMake_SOURCE_DIR}/Source/CTest
+ )
+
+set(CMakeLib_TESTS
+ testArgumentParser.cxx
+ testCTestBinPacker.cxx
+ testCTestResourceAllocator.cxx
+ testCTestResourceSpec.cxx
+ testCTestResourceGroups.cxx
+ testGccDepfileReader.cxx
+ testGeneratedFileStream.cxx
+ testRST.cxx
+ testRange.cxx
+ testOptional.cxx
+ testString.cxx
+ testStringAlgorithms.cxx
+ testSystemTools.cxx
+ testUTF8.cxx
+ testXMLParser.cxx
+ testXMLSafe.cxx
+ testFindPackageCommand.cxx
+ testUVProcessChain.cxx
+ testUVRAII.cxx
+ testUVStreambuf.cxx
+ testCMExtMemory.cxx
+ testCMExtAlgorithm.cxx
+ )
+
+add_executable(testUVProcessChainHelper testUVProcessChainHelper.cxx)
+
+set(testRST_ARGS ${CMAKE_CURRENT_SOURCE_DIR})
+set(testUVProcessChain_ARGS $<TARGET_FILE:testUVProcessChainHelper>)
+set(testUVStreambuf_ARGS $<TARGET_FILE:cmake>)
+set(testCTestResourceSpec_ARGS ${CMAKE_CURRENT_SOURCE_DIR})
+set(testGccDepfileReader_ARGS ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(WIN32)
+ list(APPEND CMakeLib_TESTS
+ testVisualStudioSlnParser.cxx
+ )
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testVisualStudioSlnParser.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/testVisualStudioSlnParser.h @ONLY)
+endif()
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testXMLParser.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/testXMLParser.h @ONLY)
+
+create_test_sourcelist(CMakeLib_TEST_SRCS CMakeLibTests.cxx ${CMakeLib_TESTS})
+add_executable(CMakeLibTests ${CMakeLib_TEST_SRCS})
+target_link_libraries(CMakeLibTests CMakeLib CTestLib)
+
+set_property(TARGET CMakeLibTests PROPERTY C_CLANG_TIDY "")
+set_property(TARGET CMakeLibTests PROPERTY CXX_CLANG_TIDY "")
+
+add_executable(testEncoding testEncoding.cxx)
+target_link_libraries(testEncoding cmsys)
+
+foreach(testfile ${CMakeLib_TESTS})
+ get_filename_component(test "${testfile}" NAME_WE)
+ add_test(NAME CMakeLib.${test} COMMAND CMakeLibTests ${test} ${${test}_ARGS})
+endforeach()
+
+if(TEST_CompileCommandOutput)
+ add_executable(runcompilecommands run_compile_commands.cxx)
+ target_link_libraries(runcompilecommands CMakeLib)
+endif()
+
+add_subdirectory(PseudoMemcheck)
+
+add_executable(testAffinity testAffinity.cxx)
+target_link_libraries(testAffinity CMakeLib)
diff --git a/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt b/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt
new file mode 100644
index 0000000..7c84ee1
--- /dev/null
+++ b/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt
@@ -0,0 +1,26 @@
+foreach (_retval 0 1)
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/memtester.cxx.in" "${CMAKE_CURRENT_BINARY_DIR}/ret${_retval}.cxx" @ONLY)
+endforeach ()
+
+include_directories(${CMake_SOURCE_DIR}/Source ${CMake_BINARY_DIR}/Source)
+
+# create binaries that we will use as a pseudo memory checker
+add_executable(pseudo_valgrind "${CMAKE_CURRENT_BINARY_DIR}/ret0.cxx")
+set_target_properties(pseudo_valgrind PROPERTIES OUTPUT_NAME valgrind)
+target_link_libraries(pseudo_valgrind CMakeLib)
+
+add_executable(pseudo_purify "${CMAKE_CURRENT_BINARY_DIR}/ret0.cxx")
+set_target_properties(pseudo_purify PROPERTIES OUTPUT_NAME purify)
+target_link_libraries(pseudo_purify CMakeLib)
+add_executable(pseudo_BC "${CMAKE_CURRENT_BINARY_DIR}/ret0.cxx")
+set_target_properties(pseudo_BC PROPERTIES OUTPUT_NAME BC)
+target_link_libraries(pseudo_BC CMakeLib)
+
+# binary to be used as pre- and post-memcheck command that fails
+add_executable(memcheck_fail "${CMAKE_CURRENT_BINARY_DIR}/ret1.cxx")
+target_link_libraries(memcheck_fail CMakeLib)
+
+# Binaries that are used as memchecker that do not write the expected
+# output file. Need to be in their own subdirectory as they have the
+# same filenames.
+add_subdirectory(NoLog)
diff --git a/Tests/CMakeLib/PseudoMemcheck/NoLog/CMakeLists.txt b/Tests/CMakeLib/PseudoMemcheck/NoLog/CMakeLists.txt
new file mode 100644
index 0000000..e47b9db
--- /dev/null
+++ b/Tests/CMakeLib/PseudoMemcheck/NoLog/CMakeLists.txt
@@ -0,0 +1,14 @@
+# A dummy checker implementation that does not write the requested output file
+# so it triggers an error for every checker.
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ret0.c.in" "int main(){return 0;}\n")
+
+configure_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/ret0.c.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/ret0.c"
+ )
+
+foreach(_pseudo IN ITEMS valgrind purify BC)
+ add_executable(pseudonl_${_pseudo} "${CMAKE_CURRENT_BINARY_DIR}/ret0.c")
+ set_target_properties(pseudonl_${_pseudo} PROPERTIES OUTPUT_NAME ${_pseudo})
+endforeach()
diff --git a/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in b/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in
new file mode 100644
index 0000000..3183bc0
--- /dev/null
+++ b/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in
@@ -0,0 +1,54 @@
+#include <cmSystemTools.h>
+#include "cmsys/Encoding.hxx"
+#include <string>
+
+#define RETVAL @_retval@
+
+int main(int ac, char** av)
+{
+ cmsys::Encoding::CommandLineArguments args =
+ cmsys::Encoding::CommandLineArguments::Main(ac, av);
+ int argc = args.argc();
+ const char* const* argv = args.argv();
+
+ std::string exename = argv[0];
+ std::string logarg;
+ bool nextarg = false;
+
+ if (exename.find("valgrind") != std::string::npos) {
+ logarg = "--log-file=";
+ } else if (exename.find("purify") != std::string::npos) {
+#ifdef _WIN32
+ logarg = "/SAVETEXTDATA=";
+#else
+ logarg = "-log-file=";
+#endif
+ } else if (exename.find("BC") != std::string::npos) {
+ nextarg = true;
+ logarg = "/X";
+ }
+
+ if (!logarg.empty()) {
+ std::string logfile;
+ for (int i = 1; i < argc; i++) {
+ std::string arg = argv[i];
+ if (arg.find(logarg) == 0) {
+ if (nextarg) {
+ if (i == argc - 1) {
+ return 1; // invalid command line
+ }
+ logfile = argv[i + 1];
+ } else {
+ logfile = arg.substr(logarg.length());
+ }
+ // keep searching, it may be overridden later to provoke an error
+ }
+ }
+
+ if (!logfile.empty()) {
+ cmSystemTools::Touch(logfile, true);
+ }
+ }
+
+ return RETVAL;
+}
diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx
new file mode 100644
index 0000000..2c77acc
--- /dev/null
+++ b/Tests/CMakeLib/run_compile_commands.cxx
@@ -0,0 +1,159 @@
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <cstdlib>
+#include <iostream>
+#include <map>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "cmsys/FStream.hxx"
+
+#include "cmSystemTools.h"
+
+class CompileCommandParser
+{
+public:
+ class CommandType : public std::map<std::string, std::string>
+ {
+ public:
+ std::string const& at(std::string const& k) const
+ {
+ auto i = this->find(k);
+ if (i != this->end()) {
+ return i->second;
+ }
+ static std::string emptyString;
+ return emptyString;
+ }
+ };
+ using TranslationUnitsType = std::vector<CommandType>;
+
+ CompileCommandParser(std::istream& input)
+ : Input(input)
+ {
+ }
+
+ void Parse()
+ {
+ NextNonWhitespace();
+ ParseTranslationUnits();
+ }
+
+ const TranslationUnitsType& GetTranslationUnits()
+ {
+ return this->TranslationUnits;
+ }
+
+private:
+ void ParseTranslationUnits()
+ {
+ this->TranslationUnits = TranslationUnitsType();
+ ExpectOrDie('[', "at start of compile command file\n");
+ do {
+ ParseTranslationUnit();
+ this->TranslationUnits.push_back(this->Command);
+ } while (Expect(','));
+ ExpectOrDie(']', "at end of array");
+ }
+
+ void ParseTranslationUnit()
+ {
+ this->Command = CommandType();
+ if (!Expect('{')) {
+ return;
+ }
+ if (Expect('}')) {
+ return;
+ }
+ do {
+ ParseString();
+ std::string name = this->String;
+ ExpectOrDie(':', "between name and value");
+ ParseString();
+ std::string value = this->String;
+ this->Command[name] = value;
+ } while (Expect(','));
+ ExpectOrDie('}', "at end of object");
+ }
+
+ void ParseString()
+ {
+ this->String = "";
+ if (!Expect('"')) {
+ return;
+ }
+ while (!Expect('"')) {
+ Expect('\\');
+ this->String.append(1, C);
+ Next();
+ }
+ }
+
+ bool Expect(char c)
+ {
+ if (this->C == c) {
+ NextNonWhitespace();
+ return true;
+ }
+ return false;
+ }
+
+ void ExpectOrDie(char c, const std::string& message)
+ {
+ if (!Expect(c)) {
+ ErrorExit(std::string("'") + c + "' expected " + message + ".");
+ }
+ }
+
+ void NextNonWhitespace()
+ {
+ do {
+ Next();
+ } while (IsWhitespace());
+ }
+
+ void Next()
+ {
+ this->C = char(Input.get());
+ if (this->Input.bad()) {
+ ErrorExit("Unexpected end of file.");
+ }
+ }
+
+ void ErrorExit(const std::string& message)
+ {
+ std::cout << "ERROR: " << message;
+ exit(1);
+ }
+
+ bool IsWhitespace()
+ {
+ return (this->C == ' ' || this->C == '\t' || this->C == '\n' ||
+ this->C == '\r');
+ }
+
+ char C;
+ TranslationUnitsType TranslationUnits;
+ CommandType Command;
+ std::string String;
+ std::istream& Input;
+};
+
+int main()
+{
+ cmsys::ifstream file("compile_commands.json");
+ CompileCommandParser parser(file);
+ parser.Parse();
+ for (auto const& tu : parser.GetTranslationUnits()) {
+ std::vector<std::string> command;
+ cmSystemTools::ParseUnixCommandLine(tu.at("command").c_str(), command);
+ if (!cmSystemTools::RunSingleCommand(command, nullptr, nullptr, nullptr,
+ tu.at("directory").c_str())) {
+ std::cout << "ERROR: Failed to run command \"" << command[0] << "\""
+ << std::endl;
+ exit(1);
+ }
+ }
+ return 0;
+}
diff --git a/Tests/CMakeLib/testAffinity.cxx b/Tests/CMakeLib/testAffinity.cxx
new file mode 100644
index 0000000..6c68570
--- /dev/null
+++ b/Tests/CMakeLib/testAffinity.cxx
@@ -0,0 +1,18 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include <cstddef>
+#include <iostream>
+#include <set>
+
+#include "cmAffinity.h"
+
+int main()
+{
+ std::set<size_t> cpus = cmAffinity::GetProcessorsAvailable();
+ if (!cpus.empty()) {
+ std::cout << "CPU affinity mask count is '" << cpus.size() << "'.\n";
+ } else {
+ std::cout << "CPU affinity not supported on this platform.\n";
+ }
+ return 0;
+}
diff --git a/Tests/CMakeLib/testArgumentParser.cxx b/Tests/CMakeLib/testArgumentParser.cxx
new file mode 100644
index 0000000..20f98c2
--- /dev/null
+++ b/Tests/CMakeLib/testArgumentParser.cxx
@@ -0,0 +1,149 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include <initializer_list>
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include <cm/string_view>
+
+#include "cm_static_string_view.hxx"
+
+#include "cmArgumentParser.h"
+
+namespace {
+
+struct Result
+{
+ bool Option1 = false;
+ bool Option2 = false;
+
+ std::string String1;
+ std::string String2;
+
+ std::vector<std::string> List1;
+ std::vector<std::string> List2;
+ std::vector<std::string> List3;
+
+ std::vector<std::vector<std::string>> Multi1;
+ std::vector<std::vector<std::string>> Multi2;
+ std::vector<std::vector<std::string>> Multi3;
+};
+
+std::initializer_list<cm::string_view> const args = {
+ /* clang-format off */
+ "OPTION_1", // option
+ "STRING_1", // string arg missing value
+ "STRING_2", "foo", "bar", // string arg + unparsed value
+ "LIST_1", // list arg missing values
+ "LIST_2", "foo", "bar", // list arg with 2 elems
+ "LIST_3", "bar", // list arg ...
+ "LIST_3", "foo", // ... with continuation
+ "MULTI_2", // multi list with 0 lists
+ "MULTI_3", "foo", "bar", // multi list with first list with two elems
+ "MULTI_3", "bar", "foo", // multi list with second list with two elems
+ /* clang-format on */
+};
+
+bool verifyResult(Result const& result,
+ std::vector<std::string> const& unparsedArguments,
+ std::vector<std::string> const& keywordsMissingValue)
+{
+ static std::vector<std::string> const foobar = { "foo", "bar" };
+ static std::vector<std::string> const barfoo = { "bar", "foo" };
+ static std::vector<std::string> const missing = { "STRING_1", "LIST_1" };
+
+#define ASSERT_TRUE(x) \
+ do { \
+ if (!(x)) { \
+ std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << "\n"; \
+ return false; \
+ } \
+ } while (false)
+
+ ASSERT_TRUE(result.Option1);
+ ASSERT_TRUE(!result.Option2);
+
+ ASSERT_TRUE(result.String1.empty());
+ ASSERT_TRUE(result.String2 == "foo");
+
+ ASSERT_TRUE(result.List1.empty());
+ ASSERT_TRUE(result.List2 == foobar);
+ ASSERT_TRUE(result.List3 == barfoo);
+
+ ASSERT_TRUE(result.Multi1.empty());
+ ASSERT_TRUE(result.Multi2.size() == 1);
+ ASSERT_TRUE(result.Multi2[0].empty());
+ ASSERT_TRUE(result.Multi3.size() == 2);
+ ASSERT_TRUE(result.Multi3[0] == foobar);
+ ASSERT_TRUE(result.Multi3[1] == barfoo);
+
+ ASSERT_TRUE(unparsedArguments.size() == 1);
+ ASSERT_TRUE(unparsedArguments[0] == "bar");
+ ASSERT_TRUE(keywordsMissingValue == missing);
+
+ return true;
+}
+
+bool testArgumentParserDynamic()
+{
+ Result result;
+ std::vector<std::string> unparsedArguments;
+ std::vector<std::string> keywordsMissingValue;
+
+ cmArgumentParser<void>{}
+ .Bind("OPTION_1"_s, result.Option1)
+ .Bind("OPTION_2"_s, result.Option2)
+ .Bind("STRING_1"_s, result.String1)
+ .Bind("STRING_2"_s, result.String2)
+ .Bind("LIST_1"_s, result.List1)
+ .Bind("LIST_2"_s, result.List2)
+ .Bind("LIST_3"_s, result.List3)
+ .Bind("MULTI_1"_s, result.Multi1)
+ .Bind("MULTI_2"_s, result.Multi2)
+ .Bind("MULTI_3"_s, result.Multi3)
+ .Parse(args, &unparsedArguments, &keywordsMissingValue);
+
+ return verifyResult(result, unparsedArguments, keywordsMissingValue);
+}
+
+bool testArgumentParserStatic()
+{
+ static auto const parser = //
+ cmArgumentParser<Result>{}
+ .Bind("OPTION_1"_s, &Result::Option1)
+ .Bind("OPTION_2"_s, &Result::Option2)
+ .Bind("STRING_1"_s, &Result::String1)
+ .Bind("STRING_2"_s, &Result::String2)
+ .Bind("LIST_1"_s, &Result::List1)
+ .Bind("LIST_2"_s, &Result::List2)
+ .Bind("LIST_3"_s, &Result::List3)
+ .Bind("MULTI_1"_s, &Result::Multi1)
+ .Bind("MULTI_2"_s, &Result::Multi2)
+ .Bind("MULTI_3"_s, &Result::Multi3);
+
+ std::vector<std::string> unparsedArguments;
+ std::vector<std::string> keywordsMissingValue;
+ Result const result =
+ parser.Parse(args, &unparsedArguments, &keywordsMissingValue);
+
+ return verifyResult(result, unparsedArguments, keywordsMissingValue);
+}
+
+} // namespace
+
+int testArgumentParser(int /*unused*/, char* /*unused*/ [])
+{
+ if (!testArgumentParserDynamic()) {
+ std::cout << "While executing testArgumentParserDynamic().\n";
+ return -1;
+ }
+
+ if (!testArgumentParserStatic()) {
+ std::cout << "While executing testArgumentParserStatic().\n";
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/Tests/CMakeLib/testCMExtAlgorithm.cxx b/Tests/CMakeLib/testCMExtAlgorithm.cxx
new file mode 100644
index 0000000..b8319c3
--- /dev/null
+++ b/Tests/CMakeLib/testCMExtAlgorithm.cxx
@@ -0,0 +1,118 @@
+#include <iostream>
+#include <memory>
+#include <type_traits>
+#include <utility>
+#include <vector>
+
+#include <cmext/algorithm>
+
+namespace {
+
+int failed = 0;
+
+void testAppend()
+{
+ std::cout << "testAppend()" << std::endl;
+
+ // ----------------------------------------------------
+ // cm::append(Vector, Iterator, Iterator)
+ {
+ std::vector<int> v1{ 1, 2, 3 };
+ std::vector<int> v1_ref{ 1, 2, 3, 4, 5, 6 };
+ std::vector<int> v2{ 4, 5, 6 };
+ std::vector<int> v2_ref{ 4, 5, 6 };
+
+ cm::append(v1, v2.begin(), v2.end());
+
+ if (v1 != v1_ref || v2 != v2_ref) {
+ ++failed;
+ }
+ }
+
+ // ----------------------------------------------------
+ // cm::append(Vector, Range)
+ {
+ std::vector<int> v1{ 1, 2, 3 };
+ std::vector<int> v1_ref{ 1, 2, 3, 4, 5, 6 };
+ std::vector<int> v2{ 4, 5, 6 };
+ std::vector<int> v2_ref{ 4, 5, 6 };
+
+ cm::append(v1, v2);
+
+ if (v1 != v1_ref || v2 != v2_ref) {
+ ++failed;
+ }
+ }
+
+ // ----------------------------------------------------
+ // cm::append(Vector<*>, Vector<unique_ptr>)
+ {
+ std::vector<int*> v1{ new int(1), new int(2), new int(3) };
+ std::vector<int*> v1_ref = v1;
+ std::vector<std::unique_ptr<int>> v2;
+
+ v2.emplace_back(new int(4));
+ v2.emplace_back(new int(5));
+ v2.emplace_back(new int(6));
+
+ cm::append(v1, v2);
+
+ if (v1.size() == 6 && v2.size() == 3) {
+ for (int i = 0; i < 3; i++) {
+ if (v1[i] != v1_ref[i]) {
+ ++failed;
+ break;
+ }
+ }
+ for (int i = 0; i < 3; i++) {
+ if (v1[i + 3] != v2[i].get()) {
+ ++failed;
+ break;
+ }
+ }
+ } else {
+ ++failed;
+ }
+
+ // free memory to please memory sanitizer
+ delete v1[0];
+ delete v1[1];
+ delete v1[2];
+ }
+
+ // ----------------------------------------------------
+ // cm::append(Vector<unique_ptr>, Vector<unique_ptr>)
+ {
+ std::vector<std::unique_ptr<int>> v1;
+ std::vector<std::unique_ptr<int>> v2;
+
+ v1.emplace_back(new int(1));
+ v1.emplace_back(new int(2));
+ v1.emplace_back(new int(3));
+
+ v2.emplace_back(new int(4));
+ v2.emplace_back(new int(5));
+ v2.emplace_back(new int(6));
+
+ cm::append(v1, std::move(v2));
+
+ if (v1.size() == 6 && v2.empty()) {
+ for (int i = 0; i < 6; i++) {
+ if (*v1[i] != i + 1) {
+ ++failed;
+ break;
+ }
+ }
+ } else {
+ ++failed;
+ }
+ }
+}
+}
+
+int testCMExtAlgorithm(int /*unused*/, char* /*unused*/ [])
+{
+ testAppend();
+
+ return failed;
+}
diff --git a/Tests/CMakeLib/testCMExtMemory.cxx b/Tests/CMakeLib/testCMExtMemory.cxx
new file mode 100644
index 0000000..6663c17
--- /dev/null
+++ b/Tests/CMakeLib/testCMExtMemory.cxx
@@ -0,0 +1,65 @@
+#include <iostream>
+#include <memory>
+
+#include <cmext/memory>
+
+namespace {
+class Base
+{
+public:
+ virtual ~Base() = default;
+};
+
+class Derived : public Base
+{
+public:
+ ~Derived() = default;
+
+ void method() {}
+};
+
+template <typename T>
+class Wrapper
+{
+public:
+ Wrapper(T* v)
+ : value(v)
+ {
+ }
+ ~Wrapper() { delete value; }
+
+ T* get() const { return value; }
+
+private:
+ T* value;
+};
+
+bool testReferenceCast()
+{
+ std::cout << "testReferenceCast()" << std::endl;
+
+ std::unique_ptr<Base> u(new Derived);
+ cm::static_reference_cast<Derived>(u).method();
+ cm::dynamic_reference_cast<Derived>(u).method();
+
+ std::shared_ptr<Base> s(new Derived);
+ cm::static_reference_cast<Derived>(s).method();
+ cm::dynamic_reference_cast<Derived>(s).method();
+
+ // can also be used with custom wrappers
+ Wrapper<Base> w(new Derived);
+ cm::static_reference_cast<Derived>(w).method();
+ cm::dynamic_reference_cast<Derived>(w).method();
+
+ return true;
+}
+}
+
+int testCMExtMemory(int /*unused*/, char* /*unused*/ [])
+{
+ if (!testReferenceCast()) {
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/Tests/CMakeLib/testCTestBinPacker.cxx b/Tests/CMakeLib/testCTestBinPacker.cxx
new file mode 100644
index 0000000..6f09af2
--- /dev/null
+++ b/Tests/CMakeLib/testCTestBinPacker.cxx
@@ -0,0 +1,300 @@
+#include <cstddef>
+#include <iostream>
+#include <map>
+#include <string>
+#include <vector>
+
+#include "cmCTestBinPacker.h"
+#include "cmCTestResourceAllocator.h"
+
+struct ExpectedPackResult
+{
+ std::vector<int> SlotsNeeded;
+ std::map<std::string, cmCTestResourceAllocator::Resource> Resources;
+ bool ExpectedReturnValue;
+ std::vector<cmCTestBinPackerAllocation> ExpectedRoundRobinAllocations;
+ std::vector<cmCTestBinPackerAllocation> ExpectedBlockAllocations;
+};
+
+static const std::vector<ExpectedPackResult> expectedResults
+{
+ /* clang-format off */
+ {
+ { 2, 2, 2, 2 },
+ { { "0", { 4, 0 } }, { "1", { 4, 0 } }, { "2", { 4, 0 } },
+ { "3", { 4, 0 } } },
+ true,
+ {
+ { 0, 2, "0" },
+ { 1, 2, "1" },
+ { 2, 2, "2" },
+ { 3, 2, "3" },
+ },
+ {
+ { 0, 2, "0" },
+ { 1, 2, "0" },
+ { 2, 2, "1" },
+ { 3, 2, "1" },
+ },
+ },
+ {
+ { 2, 3, 2 },
+ { { "0", { 5, 0 } }, { "1", { 2, 0 } } },
+ true,
+ {
+ { 0, 2, "0" },
+ { 1, 3, "0" },
+ { 2, 2, "1" },
+ },
+ {
+ { 0, 2, "0" },
+ { 1, 3, "0" },
+ { 2, 2, "1" },
+ },
+ },
+ {
+ { 1, 2, 3 },
+ { { "0", { 1, 0 } }, { "1", { 2, 0 } }, { "2", { 2, 0 } } },
+ false,
+ { },
+ { },
+ },
+ {
+ { 48, 21, 31, 10, 40 },
+ { { "0", { 81, 0 } }, { "1", { 68, 0 } }, { "2", { 20, 0 } },
+ { "3", { 13, 0 } } },
+ true,
+ {
+ { 0, 48, "0" },
+ { 1, 21, "1" },
+ { 2, 31, "0" },
+ { 3, 10, "2" },
+ { 4, 40, "1" },
+ },
+ {
+ { 0, 48, "0" },
+ { 1, 21, "1" },
+ { 2, 31, "0" },
+ { 3, 10, "2" },
+ { 4, 40, "1" },
+ },
+ },
+ {
+ { 30, 31, 39, 67 },
+ { { "0", { 16, 0 } }, { "1", { 81, 0 } }, { "2", { 97, 0 } } },
+ true,
+ {
+ { 0, 30, "2" },
+ { 1, 31, "1" },
+ { 2, 39, "1" },
+ { 3, 67, "2" },
+ },
+ {
+ { 0, 30, "2" },
+ { 1, 31, "1" },
+ { 2, 39, "1" },
+ { 3, 67, "2" },
+ },
+ },
+ {
+ { 63, 47, 1, 9 },
+ { { "0", { 18, 0 } }, { "1", { 29, 0 } }, { "2", { 9, 0 } },
+ { "3", { 52, 0 } } },
+ false,
+ { },
+ { },
+ },
+ {
+ { 22, 29, 46, 85 },
+ { { "0", { 65, 0 } }, { "1", { 85, 0 } }, { "2", { 65, 0 } },
+ { "3", { 78, 0 } } },
+ true,
+ {
+ { 0, 22, "2" },
+ { 1, 29, "0" },
+ { 2, 46, "3" },
+ { 3, 85, "1" },
+ },
+ {
+ { 0, 22, "0" },
+ { 1, 29, "3" },
+ { 2, 46, "3" },
+ { 3, 85, "1" },
+ },
+ },
+ {
+ { 66, 11, 34, 21 },
+ { { "0", { 24, 0 } }, { "1", { 57, 0 } }, { "2", { 61, 0 } },
+ { "3", { 51, 0 } } },
+ false,
+ { },
+ { },
+ },
+ {
+ { 72, 65, 67, 45 },
+ { { "0", { 29, 0 } }, { "1", { 77, 0 } }, { "2", { 98, 0 } },
+ { "3", { 58, 0 } } },
+ false,
+ { },
+ { },
+ },
+ /*
+ * The following is a contrived attack on the bin-packing algorithm that
+ * causes it to execute with n! complexity, where n is the number of
+ * resources. This case is very unrepresentative of real-world usage, and
+ * has been documented but disabled. The bin-packing problem is NP-hard, and
+ * we may not be able to fix this case at all.
+ */
+#if 0
+ {
+ { 1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 19 },
+ { { "0", { 1000, 0 } }, { "1", { 1001, 0 } }, { "2", { 1002, 0 } },
+ { "3", { 1003, 0 } }, { "4", { 1004, 0 } }, { "5", { 1005, 0 } },
+ { "6", { 1006, 0 } }, { "7", { 1007, 0 } }, { "8", { 1008, 0 } },
+ { "9", { 1009, 0 } } },
+ false,
+ { },
+ { },
+ },
+#endif
+ /*
+ * These cases are more representative of real-world usage (the resource
+ * sizes are all the same.)
+ */
+ {
+ { 1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 10 },
+ { { "0", { 1000, 0 } }, { "1", { 1000, 0 } }, { "2", { 1000, 0 } },
+ { "3", { 1000, 0 } }, { "4", { 1000, 0 } }, { "5", { 1000, 0 } },
+ { "6", { 1000, 0 } }, { "7", { 1000, 0 } }, { "8", { 1000, 0 } },
+ { "9", { 1000, 0 } } },
+ false,
+ { },
+ { },
+ },
+ {
+ { 1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 9 },
+ { { "0", { 1000, 0 } }, { "1", { 1000, 0 } }, { "2", { 1000, 0 } },
+ { "3", { 1000, 0 } }, { "4", { 1000, 0 } }, { "5", { 1000, 0 } },
+ { "6", { 1000, 0 } }, { "7", { 1000, 0 } }, { "8", { 1000, 0 } },
+ { "9", { 1000, 0 } } },
+ true,
+ {
+ { 0, 1000, "0" },
+ { 1, 999, "1" },
+ { 2, 998, "2" },
+ { 3, 997, "3" },
+ { 4, 996, "4" },
+ { 5, 995, "5" },
+ { 6, 994, "6" },
+ { 7, 993, "7" },
+ { 8, 992, "8" },
+ { 9, 991, "9" },
+ { 10, 9, "9" },
+ },
+ {
+ { 0, 1000, "0" },
+ { 1, 999, "1" },
+ { 2, 998, "2" },
+ { 3, 997, "3" },
+ { 4, 996, "4" },
+ { 5, 995, "5" },
+ { 6, 994, "6" },
+ { 7, 993, "7" },
+ { 8, 992, "8" },
+ { 9, 991, "9" },
+ { 10, 9, "9" },
+ },
+ },
+ /* clang-format on */
+};
+
+struct AllocationComparison
+{
+ cmCTestBinPackerAllocation First;
+ cmCTestBinPackerAllocation Second;
+ bool Equal;
+};
+
+static const std::vector<AllocationComparison> comparisons{
+ /* clang-format off */
+ { { 0, 1, "0" }, { 0, 1, "0" }, true },
+ { { 0, 1, "0" }, { 1, 1, "0" }, false },
+ { { 0, 1, "0" }, { 0, 2, "0" }, false },
+ { { 0, 1, "0" }, { 0, 1, "1" }, false },
+ /* clang-format on */
+};
+
+bool TestExpectedPackResult(const ExpectedPackResult& expected)
+{
+ std::vector<cmCTestBinPackerAllocation> roundRobinAllocations;
+ roundRobinAllocations.reserve(expected.SlotsNeeded.size());
+ std::size_t index = 0;
+ for (auto const& n : expected.SlotsNeeded) {
+ roundRobinAllocations.push_back({ index++, n, "" });
+ }
+
+ bool roundRobinResult = cmAllocateCTestResourcesRoundRobin(
+ expected.Resources, roundRobinAllocations);
+ if (roundRobinResult != expected.ExpectedReturnValue) {
+ std::cout
+ << "cmAllocateCTestResourcesRoundRobin did not return expected value"
+ << std::endl;
+ return false;
+ }
+
+ if (roundRobinResult &&
+ roundRobinAllocations != expected.ExpectedRoundRobinAllocations) {
+ std::cout << "cmAllocateCTestResourcesRoundRobin did not return expected "
+ "allocations"
+ << std::endl;
+ return false;
+ }
+
+ std::vector<cmCTestBinPackerAllocation> blockAllocations;
+ blockAllocations.reserve(expected.SlotsNeeded.size());
+ index = 0;
+ for (auto const& n : expected.SlotsNeeded) {
+ blockAllocations.push_back({ index++, n, "" });
+ }
+
+ bool blockResult =
+ cmAllocateCTestResourcesBlock(expected.Resources, blockAllocations);
+ if (blockResult != expected.ExpectedReturnValue) {
+ std::cout << "cmAllocateCTestResourcesBlock did not return expected value"
+ << std::endl;
+ return false;
+ }
+
+ if (blockResult && blockAllocations != expected.ExpectedBlockAllocations) {
+ std::cout << "cmAllocateCTestResourcesBlock did not return expected"
+ " allocations"
+ << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+int testCTestBinPacker(int /*unused*/, char* /*unused*/ [])
+{
+ int retval = 0;
+
+ for (auto const& comparison : comparisons) {
+ if ((comparison.First == comparison.Second) != comparison.Equal) {
+ std::cout << "Comparison did not match expected" << std::endl;
+ retval = 1;
+ }
+ if ((comparison.First != comparison.Second) == comparison.Equal) {
+ std::cout << "Comparison did not match expected" << std::endl;
+ retval = 1;
+ }
+ }
+
+ for (auto const& expected : expectedResults) {
+ if (!TestExpectedPackResult(expected)) {
+ retval = 1;
+ }
+ }
+
+ return retval;
+}
diff --git a/Tests/CMakeLib/testCTestResourceAllocator.cxx b/Tests/CMakeLib/testCTestResourceAllocator.cxx
new file mode 100644
index 0000000..33d6b91
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceAllocator.cxx
@@ -0,0 +1,426 @@
+#include <iostream>
+#include <map>
+#include <string>
+#include <vector>
+
+#include "cmCTestResourceAllocator.h"
+#include "cmCTestResourceSpec.h"
+
+static const cmCTestResourceSpec spec{ { {
+ /* clang-format off */
+ { "gpus", { { "0", 4 }, { "1", 8 }, { "2", 0 }, { "3", 8 } } },
+ /* clang-format on */
+} } };
+
+bool testInitializeFromResourceSpec()
+{
+ bool retval = true;
+
+ cmCTestResourceAllocator allocator;
+ allocator.InitializeFromResourceSpec(spec);
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 0 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (allocator.GetResources() != expected) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ return retval;
+}
+
+bool testAllocateResource()
+{
+ bool retval = true;
+
+ cmCTestResourceAllocator allocator;
+ allocator.InitializeFromResourceSpec(spec);
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected1{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 2 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (!allocator.AllocateResource("gpus", "0", 2)) {
+ std::cout
+ << "AllocateResource(\"gpus\", \"0\", 2) returned false, should be "
+ "true\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected1) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected2{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 4 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (!allocator.AllocateResource("gpus", "0", 2)) {
+ std::cout
+ << "AllocateResource(\"gpus\", \"0\", 2) returned false, should be "
+ "true\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected2) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected3{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 4 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (allocator.AllocateResource("gpus", "0", 1)) {
+ std::cout
+ << "AllocateResource(\"gpus\", \"0\", 1) returned true, should be "
+ "false\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected3) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected4{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 4 } },
+ { "1", { 8, 7 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (!allocator.AllocateResource("gpus", "1", 7)) {
+ std::cout
+ << "AllocateResource(\"gpus\", \"1\", 7) returned false, should be "
+ "true\n";
+ retval = false;
+ }
+ if (allocator.AllocateResource("gpus", "1", 2)) {
+ std::cout
+ << "AllocateResource(\"gpus\", \"1\", 2) returned true, should be "
+ "false\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected4) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected5{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 4 } },
+ { "1", { 8, 7 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (allocator.AllocateResource("gpus", "2", 1)) {
+ std::cout
+ << "AllocateResource(\"gpus\", \"2\", 1) returned true, should be "
+ "false\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected5) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected6{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 4 } },
+ { "1", { 8, 7 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (allocator.AllocateResource("gpus", "4", 1)) {
+ std::cout
+ << "AllocateResource(\"gpus\", \"4\", 1) returned true, should be "
+ "false\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected6) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected7{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 4 } },
+ { "1", { 8, 7 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (allocator.AllocateResource("threads", "0", 1)) {
+ std::cout
+ << "AllocateResource(\"threads\", \"0\", 1) returned true, should be"
+ " false\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected7) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ return retval;
+}
+
+bool testDeallocateResource()
+{
+ bool retval = true;
+
+ cmCTestResourceAllocator allocator;
+ allocator.InitializeFromResourceSpec(spec);
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected1{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 1 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (!allocator.AllocateResource("gpus", "0", 2)) {
+ std::cout
+ << "AllocateResource(\"gpus\", \"0\", 2) returned false, should be "
+ "true\n";
+ retval = false;
+ }
+ if (!allocator.DeallocateResource("gpus", "0", 1)) {
+ std::cout
+ << "DeallocateResource(\"gpus\", \"0\", 1) returned false, should be"
+ " true\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected1) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected2{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 1 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (allocator.DeallocateResource("gpus", "0", 2)) {
+ std::cout
+ << "DeallocateResource(\"gpus\", \"0\", 2) returned true, should be"
+ " false\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected2) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected3{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 0 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (!allocator.DeallocateResource("gpus", "0", 1)) {
+ std::cout
+ << "DeallocateResource(\"gpus\", \"0\", 1) returned false, should be"
+ " true\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected3) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected4{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 0 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (allocator.DeallocateResource("gpus", "0", 1)) {
+ std::cout
+ << "DeallocateResource(\"gpus\", \"0\", 1) returned true, should be"
+ " false\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected4) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected5{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 0 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (allocator.DeallocateResource("gpus", "4", 1)) {
+ std::cout
+ << "DeallocateResource(\"gpus\", \"4\", 1) returned true, should be"
+ " false\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected5) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected6{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 0 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (allocator.DeallocateResource("threads", "0", 1)) {
+ std::cout
+ << "DeallocateResource(\"threads\", \"0\", 1) returned true, should be"
+ " false\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected6) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ return retval;
+}
+
+bool testResourceFree()
+{
+ bool retval = true;
+
+ const cmCTestResourceAllocator::Resource r1{ 5, 0 };
+ if (r1.Free() != 5) {
+ std::cout << "cmCTestResourceAllocator::Resource::Free() did not return "
+ "expected value for { 5, 0 }\n";
+ retval = false;
+ }
+
+ const cmCTestResourceAllocator::Resource r2{ 3, 2 };
+ if (r2.Free() != 1) {
+ std::cout << "cmCTestResourceAllocator::Resource::Free() did not return "
+ "expected value for { 3, 2 }\n";
+ retval = false;
+ }
+
+ const cmCTestResourceAllocator::Resource r3{ 4, 4 };
+ if (r3.Free() != 0) {
+ std::cout << "cmCTestResourceAllocator::Resource::Free() did not return "
+ "expected value for { 4, 4 }\n";
+ retval = false;
+ }
+
+ return retval;
+}
+
+int testCTestResourceAllocator(int, char** const)
+{
+ int retval = 0;
+
+ if (!testInitializeFromResourceSpec()) {
+ std::cout << "in testInitializeFromResourceSpec()\n";
+ retval = -1;
+ }
+
+ if (!testAllocateResource()) {
+ std::cout << "in testAllocateResource()\n";
+ retval = -1;
+ }
+
+ if (!testDeallocateResource()) {
+ std::cout << "in testDeallocateResource()\n";
+ retval = -1;
+ }
+
+ if (!testResourceFree()) {
+ std::cout << "in testResourceFree()\n";
+ retval = -1;
+ }
+
+ return retval;
+}
diff --git a/Tests/CMakeLib/testCTestResourceGroups.cxx b/Tests/CMakeLib/testCTestResourceGroups.cxx
new file mode 100644
index 0000000..c3532a6
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceGroups.cxx
@@ -0,0 +1,141 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include "cmCTestTestHandler.h"
+
+struct ExpectedParseResult
+{
+ std::string String;
+ bool ExpectedReturnValue;
+ std::vector<std::vector<cmCTestTestHandler::cmCTestTestResourceRequirement>>
+ ExpectedValue;
+};
+
+static const std::vector<ExpectedParseResult> expectedResults{
+ /* clang-format off */
+ { "threads:2", true, {
+ { { "threads", 2, 1 } },
+ } },
+ { "3,threads:2", true, {
+ { { "threads", 2, 1 } },
+ { { "threads", 2, 1 } },
+ { { "threads", 2, 1 } },
+ } },
+ { "3,threads:2,gpus:4", true, {
+ { { "threads", 2, 1 }, { "gpus", 4, 1 } },
+ { { "threads", 2, 1 }, { "gpus", 4, 1 } },
+ { { "threads", 2, 1 }, { "gpus", 4, 1 } },
+ } },
+ { "2,threads:2;gpus:4", true, {
+ { { "threads", 2, 1 } },
+ { { "threads", 2, 1 } },
+ { { "gpus", 4, 1 } },
+ } },
+ { "threads:2;2,gpus:4", true, {
+ { { "threads", 2, 1 } },
+ { { "gpus", 4, 1 } },
+ { { "gpus", 4, 1 } },
+ } },
+ { "threads:2;gpus:4", true, {
+ { { "threads", 2, 1 } },
+ { { "gpus", 4, 1 } },
+ } },
+ { "1,threads:2;0,gpus:4", true, {
+ { { "threads", 2, 1 } },
+ } },
+ { "1,_:1", true, {
+ { { "_", 1, 1 } },
+ } },
+ { "1,a:1", true, {
+ { { "a", 1, 1 } },
+ } },
+ { "2", true, {
+ {},
+ {},
+ } },
+ { "1;2,threads:1", true, {
+ {},
+ { { "threads", 1, 1 } },
+ { { "threads", 1, 1 } },
+ } },
+ { "1,,threads:1", true, {
+ { { "threads", 1, 1 } },
+ } },
+ { ";1,threads:1", true, {
+ { { "threads", 1, 1 } },
+ } },
+ { "1,threads:1;", true, {
+ { { "threads", 1, 1 } },
+ } },
+ { "1,threads:1,", true, {
+ { { "threads", 1, 1 } },
+ } },
+ { "threads:1,threads:1", true, {
+ { { "threads", 1, 1 }, { "threads", 1, 1 } },
+ } },
+ { "threads:1;;threads:2", true, {
+ { { "threads", 1, 1 } },
+ { { "threads", 2, 1 } },
+ } },
+ { "1,", true, {
+ {},
+ } },
+ { ";", true, {} },
+ { "", true, {} },
+ { ",", false, {} },
+ { "1,0:1", false, {} },
+ { "1,A:1", false, {} },
+ { "1,a-b:1", false, {} },
+ { "invalid", false, {} },
+ { ",1,invalid:1", false, {} },
+ { "1,1", false, {} },
+ { "-1,invalid:1", false, {} },
+ { "1,invalid:*", false, {} },
+ { "1,invalid:-1", false, {} },
+ { "1,invalid:-", false, {} },
+ { "1,invalid:ab2", false, {} },
+ { "1,invalid :2", false, {} },
+ { "1, invalid:2", false, {} },
+ { "1,invalid:ab", false, {} },
+ /* clang-format on */
+};
+
+bool TestExpectedParseResult(const ExpectedParseResult& expected)
+{
+ std::vector<std::vector<cmCTestTestHandler::cmCTestTestResourceRequirement>>
+ result;
+ bool retval;
+ if ((retval = cmCTestTestHandler::ParseResourceGroupsProperty(
+ expected.String, result)) != expected.ExpectedReturnValue) {
+ std::cout << "ParseResourceGroupsProperty(\"" << expected.String
+ << "\") returned " << retval << ", should be "
+ << expected.ExpectedReturnValue << std::endl;
+ return false;
+ }
+
+ if (result != expected.ExpectedValue) {
+ std::cout << "ParseResourceGroupsProperty(\"" << expected.String
+ << "\") did not yield expected set of resource groups"
+ << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+int testCTestResourceGroups(int /*unused*/, char* /*unused*/ [])
+{
+ int retval = 0;
+
+ for (auto const& expected : expectedResults) {
+ if (!TestExpectedParseResult(expected)) {
+ retval = 1;
+ }
+ }
+
+ return retval;
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec.cxx b/Tests/CMakeLib/testCTestResourceSpec.cxx
new file mode 100644
index 0000000..b49f8ff
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec.cxx
@@ -0,0 +1,119 @@
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include "cmCTestResourceSpec.h"
+
+struct ExpectedSpec
+{
+ std::string Path;
+ cmCTestResourceSpec::ReadFileResult ParseResult;
+ cmCTestResourceSpec Expected;
+};
+
+static const std::vector<ExpectedSpec> expectedResourceSpecs = {
+ { "spec1.json",
+ cmCTestResourceSpec::ReadFileResult::READ_OK,
+ { { {
+ { "gpus",
+ {
+ { "2", 4 },
+ { "e", 1 },
+ } },
+ { "threads", {} },
+ } } } },
+ { "spec2.json", cmCTestResourceSpec::ReadFileResult::READ_OK, {} },
+ { "spec3.json",
+ cmCTestResourceSpec::ReadFileResult::INVALID_SOCKET_SPEC,
+ {} },
+ { "spec4.json",
+ cmCTestResourceSpec::ReadFileResult::INVALID_SOCKET_SPEC,
+ {} },
+ { "spec5.json",
+ cmCTestResourceSpec::ReadFileResult::INVALID_SOCKET_SPEC,
+ {} },
+ { "spec6.json",
+ cmCTestResourceSpec::ReadFileResult::INVALID_SOCKET_SPEC,
+ {} },
+ { "spec7.json",
+ cmCTestResourceSpec::ReadFileResult::INVALID_RESOURCE_TYPE,
+ {} },
+ { "spec8.json", cmCTestResourceSpec::ReadFileResult::INVALID_RESOURCE, {} },
+ { "spec9.json", cmCTestResourceSpec::ReadFileResult::INVALID_RESOURCE, {} },
+ { "spec10.json", cmCTestResourceSpec::ReadFileResult::INVALID_RESOURCE, {} },
+ { "spec11.json", cmCTestResourceSpec::ReadFileResult::INVALID_RESOURCE, {} },
+ { "spec12.json", cmCTestResourceSpec::ReadFileResult::INVALID_ROOT, {} },
+ { "spec13.json", cmCTestResourceSpec::ReadFileResult::JSON_PARSE_ERROR, {} },
+ { "spec14.json", cmCTestResourceSpec::ReadFileResult::READ_OK, {} },
+ { "spec15.json", cmCTestResourceSpec::ReadFileResult::READ_OK, {} },
+ { "spec16.json", cmCTestResourceSpec::ReadFileResult::READ_OK, {} },
+ { "spec17.json", cmCTestResourceSpec::ReadFileResult::INVALID_RESOURCE, {} },
+ { "spec18.json", cmCTestResourceSpec::ReadFileResult::INVALID_RESOURCE, {} },
+ { "spec19.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec20.json", cmCTestResourceSpec::ReadFileResult::READ_OK, {} },
+ { "spec21.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec22.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec23.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec24.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec25.json",
+ cmCTestResourceSpec::ReadFileResult::UNSUPPORTED_VERSION,
+ {} },
+ { "spec26.json",
+ cmCTestResourceSpec::ReadFileResult::UNSUPPORTED_VERSION,
+ {} },
+ { "spec27.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec28.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec29.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec30.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec31.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec32.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec33.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec34.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec35.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec36.json", cmCTestResourceSpec::ReadFileResult::NO_VERSION, {} },
+ { "noexist.json", cmCTestResourceSpec::ReadFileResult::FILE_NOT_FOUND, {} },
+};
+
+static bool testSpec(const std::string& path,
+ cmCTestResourceSpec::ReadFileResult expectedResult,
+ const cmCTestResourceSpec& expected)
+{
+ cmCTestResourceSpec actual;
+ auto result = actual.ReadFromJSONFile(path);
+ if (result != expectedResult) {
+ std::cout << "ReadFromJSONFile(\"" << path << "\") returned \""
+ << cmCTestResourceSpec::ResultToString(result)
+ << "\", should be \""
+ << cmCTestResourceSpec::ResultToString(expectedResult) << "\""
+ << std::endl;
+ return false;
+ }
+
+ if (actual != expected) {
+ std::cout << "ReadFromJSONFile(\"" << path
+ << "\") did not give expected spec" << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+int testCTestResourceSpec(int argc, char** const argv)
+{
+ if (argc < 2) {
+ std::cout << "Invalid arguments.\n";
+ return -1;
+ }
+
+ int retval = 0;
+ for (auto const& spec : expectedResourceSpecs) {
+ std::string path = argv[1];
+ path += "/testCTestResourceSpec_data/";
+ path += spec.Path;
+ if (!testSpec(path, spec.ParseResult, spec.Expected)) {
+ retval = -1;
+ }
+ }
+
+ return retval;
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec1.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec1.json
new file mode 100644
index 0000000..b01aa6b
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec1.json
@@ -0,0 +1,27 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "gpus": [
+ {
+ "id": "2",
+ "slots": 4
+ },
+ {
+ "id": "e"
+ }
+ ],
+ ".reserved": [
+ {
+ "id": "a",
+ "slots": 3
+ }
+ ],
+ "threads": [
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec10.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec10.json
new file mode 100644
index 0000000..8764907
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec10.json
@@ -0,0 +1,15 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "gpus": [
+ {
+ "id": 4
+ }
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec11.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec11.json
new file mode 100644
index 0000000..7551ea2
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec11.json
@@ -0,0 +1,16 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "gpus": [
+ {
+ "id": "4",
+ "slots": "giraffe"
+ }
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec12.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec12.json
new file mode 100644
index 0000000..fe51488
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec12.json
@@ -0,0 +1 @@
+[]
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec13.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec13.json
new file mode 100644
index 0000000..6b7a9f4
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec13.json
@@ -0,0 +1 @@
+not json
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec14.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec14.json
new file mode 100644
index 0000000..83f480c
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec14.json
@@ -0,0 +1,12 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "0": [
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec15.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec15.json
new file mode 100644
index 0000000..10fe2e3
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec15.json
@@ -0,0 +1,12 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "-": [
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec16.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec16.json
new file mode 100644
index 0000000..8546759
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec16.json
@@ -0,0 +1,12 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "A": [
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec17.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec17.json
new file mode 100644
index 0000000..e4cdfc9
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec17.json
@@ -0,0 +1,15 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "gpus": [
+ {
+ "id": "A"
+ }
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec18.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec18.json
new file mode 100644
index 0000000..26a7c70
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec18.json
@@ -0,0 +1,15 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "gpus": [
+ {
+ "id": "-"
+ }
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec19.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec19.json
new file mode 100644
index 0000000..3067f0c
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec19.json
@@ -0,0 +1,5 @@
+{
+ "version": 1,
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec2.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec2.json
new file mode 100644
index 0000000..df49390
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec2.json
@@ -0,0 +1,8 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec20.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec20.json
new file mode 100644
index 0000000..df49390
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec20.json
@@ -0,0 +1,8 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec21.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec21.json
new file mode 100644
index 0000000..7459ff2
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec21.json
@@ -0,0 +1,5 @@
+{
+ "version": [1, 0],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec22.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec22.json
new file mode 100644
index 0000000..23c57d8
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec22.json
@@ -0,0 +1,5 @@
+{
+ "version": 2,
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec23.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec23.json
new file mode 100644
index 0000000..a3d0a27
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec23.json
@@ -0,0 +1,7 @@
+{
+ "version": {
+ "major": 1
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec24.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec24.json
new file mode 100644
index 0000000..d5f6b08
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec24.json
@@ -0,0 +1,7 @@
+{
+ "version": {
+ "minor": 0
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec25.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec25.json
new file mode 100644
index 0000000..914da4b
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec25.json
@@ -0,0 +1,8 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 1
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec26.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec26.json
new file mode 100644
index 0000000..c06de22
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec26.json
@@ -0,0 +1,8 @@
+{
+ "version": {
+ "major": 2,
+ "minor": 0
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec27.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec27.json
new file mode 100644
index 0000000..9e2b6c3
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec27.json
@@ -0,0 +1,8 @@
+{
+ "version": {
+ "major": "1",
+ "minor": 0
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec28.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec28.json
new file mode 100644
index 0000000..ce3b76a
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec28.json
@@ -0,0 +1,8 @@
+{
+ "version": {
+ "major": 1,
+ "minor": "0"
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec29.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec29.json
new file mode 100644
index 0000000..58afd2b
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec29.json
@@ -0,0 +1,5 @@
+{
+ "version": [1, 0, 0],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec3.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec3.json
new file mode 100644
index 0000000..2f1045f
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec3.json
@@ -0,0 +1,12 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ },
+ {
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec30.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec30.json
new file mode 100644
index 0000000..9e13ff0
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec30.json
@@ -0,0 +1,5 @@
+{
+ "version": [1],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec31.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec31.json
new file mode 100644
index 0000000..c0ef7f4
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec31.json
@@ -0,0 +1,5 @@
+{
+ "version": [1, 1],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec32.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec32.json
new file mode 100644
index 0000000..abe977e
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec32.json
@@ -0,0 +1,5 @@
+{
+ "version": [2, 0],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec33.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec33.json
new file mode 100644
index 0000000..c6ca749
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec33.json
@@ -0,0 +1,5 @@
+{
+ "version": ["1", 0],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec34.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec34.json
new file mode 100644
index 0000000..be258f1
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec34.json
@@ -0,0 +1,5 @@
+{
+ "version": [1, "0"],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec35.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec35.json
new file mode 100644
index 0000000..137648c
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec35.json
@@ -0,0 +1,5 @@
+{
+ "version": "1",
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec36.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec36.json
new file mode 100644
index 0000000..6175b1a
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec36.json
@@ -0,0 +1,4 @@
+{
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec4.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec4.json
new file mode 100644
index 0000000..17349bd
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec4.json
@@ -0,0 +1,8 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": {
+ }
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec5.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec5.json
new file mode 100644
index 0000000..f6e6cb4
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec5.json
@@ -0,0 +1,6 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ }
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec6.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec6.json
new file mode 100644
index 0000000..eb8b14c
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec6.json
@@ -0,0 +1,9 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ []
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec7.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec7.json
new file mode 100644
index 0000000..0447981
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec7.json
@@ -0,0 +1,12 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "gpus": {
+ }
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec8.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec8.json
new file mode 100644
index 0000000..ee7a9c2
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec8.json
@@ -0,0 +1,13 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "gpus": [
+ []
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec9.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec9.json
new file mode 100644
index 0000000..ae1117b
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec9.json
@@ -0,0 +1,14 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "gpus": [
+ {
+ }
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testEncoding.cxx b/Tests/CMakeLib/testEncoding.cxx
new file mode 100644
index 0000000..4936898
--- /dev/null
+++ b/Tests/CMakeLib/testEncoding.cxx
@@ -0,0 +1,52 @@
+#include <iostream>
+#include <string>
+
+#include "cmsys/FStream.hxx"
+
+#ifdef _WIN32
+# include "cmsys/ConsoleBuf.hxx"
+#endif
+
+#ifdef _WIN32
+void setEncoding(cmsys::ConsoleBuf::Manager& buf, UINT codepage)
+{
+ cmsys::ConsoleBuf* cb = buf.GetConsoleBuf();
+ if (cb) {
+ cb->input_pipe_codepage = codepage;
+ cb->output_pipe_codepage = codepage;
+ cb->input_file_codepage = codepage;
+ cb->output_file_codepage = codepage;
+ cb->activateCodepageChange();
+ }
+}
+#endif
+
+int main(int argc, char* argv[])
+{
+#ifdef _WIN32
+ cmsys::ConsoleBuf::Manager consoleOut(std::cout);
+#endif
+ if (argc <= 2) {
+ std::cout << "Usage: testEncoding <encoding> <file>" << std::endl;
+ return 1;
+ }
+ const std::string encoding(argv[1]);
+#ifdef _WIN32
+ if ((encoding == "UTF8") || (encoding == "UTF-8")) {
+ setEncoding(consoleOut, CP_UTF8);
+ } else if (encoding == "ANSI") {
+ setEncoding(consoleOut, CP_ACP);
+ } else if (encoding == "OEM") {
+ setEncoding(consoleOut, CP_OEMCP);
+ } // else AUTO
+#endif
+ cmsys::ifstream file(argv[2]);
+ if (!file.is_open()) {
+ std::cout << "Failed to open file: " << argv[2] << std::endl;
+ return 2;
+ }
+ std::string text((std::istreambuf_iterator<char>(file)),
+ std::istreambuf_iterator<char>());
+ std::cout << text;
+ return 0;
+}
diff --git a/Tests/CMakeLib/testFindPackageCommand.cxx b/Tests/CMakeLib/testFindPackageCommand.cxx
new file mode 100644
index 0000000..bfd429f
--- /dev/null
+++ b/Tests/CMakeLib/testFindPackageCommand.cxx
@@ -0,0 +1,71 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include <cmConfigure.h> // IWYU pragma: keep
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include "cmFindPackageCommand.h"
+
+#define cmPassed(m) std::cout << "Passed: " << (m) << "\n"
+#define cmFailed(m) \
+ std::cout << "FAILED: " << (m) << "\n"; \
+ failed = 1
+
+int testFindPackageCommand(int /*unused*/, char* /*unused*/ [])
+{
+ int failed = 0;
+
+ // ----------------------------------------------------------------------
+ // Test cmFindPackage::Sort
+ std::vector<std::string> testString;
+ testString.push_back("lib-0.0");
+ testString.push_back("lib-1.2");
+ testString.push_back("lib-2.0");
+ testString.push_back("lib-19.0.1");
+ testString.push_back("lib-20.01.1");
+ testString.push_back("lib-20.2.2a");
+
+ cmFindPackageCommand::Sort(testString.begin(), testString.end(),
+ cmFindPackageCommand::Natural,
+ cmFindPackageCommand::Asc);
+ if (!(testString[0] == "lib-0.0" && testString[1] == "lib-1.2" &&
+ testString[2] == "lib-2.0" && testString[3] == "lib-19.0.1" &&
+ testString[4] == "lib-20.01.1" && testString[5] == "lib-20.2.2a")) {
+ cmFailed("cmSystemTools::Sort fail with Natural ASC");
+ }
+
+ cmFindPackageCommand::Sort(testString.begin(), testString.end(),
+ cmFindPackageCommand::Natural,
+ cmFindPackageCommand::Dec);
+ if (!(testString[5] == "lib-0.0" && testString[4] == "lib-1.2" &&
+ testString[3] == "lib-2.0" && testString[2] == "lib-19.0.1" &&
+ testString[1] == "lib-20.01.1" && testString[0] == "lib-20.2.2a")) {
+ cmFailed("cmSystemTools::Sort fail with Natural ASC");
+ }
+
+ cmFindPackageCommand::Sort(testString.begin(), testString.end(),
+ cmFindPackageCommand::Name_order,
+ cmFindPackageCommand::Dec);
+ if (!(testString[5] == "lib-0.0" && testString[4] == "lib-1.2" &&
+ testString[3] == "lib-19.0.1" && testString[2] == "lib-2.0" &&
+ testString[1] == "lib-20.01.1" && testString[0] == "lib-20.2.2a")) {
+ cmFailed("cmSystemTools::Sort fail with Name DEC");
+ }
+
+ cmFindPackageCommand::Sort(testString.begin(), testString.end(),
+ cmFindPackageCommand::Name_order,
+ cmFindPackageCommand::Asc);
+ if (!(testString[0] == "lib-0.0" && testString[1] == "lib-1.2" &&
+ testString[2] == "lib-19.0.1" && testString[3] == "lib-2.0" &&
+ testString[4] == "lib-20.01.1" && testString[5] == "lib-20.2.2a")) {
+ cmFailed("cmSystemTools::Sort fail with Natural ASC");
+ }
+
+ if (!failed) {
+ cmPassed("cmSystemTools::Sort working");
+ }
+ return failed;
+}
diff --git a/Tests/CMakeLib/testGccDepfileReader.cxx b/Tests/CMakeLib/testGccDepfileReader.cxx
new file mode 100644
index 0000000..924d87b
--- /dev/null
+++ b/Tests/CMakeLib/testGccDepfileReader.cxx
@@ -0,0 +1,131 @@
+#include <cstddef>
+#include <iostream>
+#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "cmsys/FStream.hxx"
+
+#include "cmGccDepfileReader.h"
+#include "cmGccDepfileReaderTypes.h" // for cmGccDepfileContent, cmGccStyle...
+#include "cmSystemTools.h"
+
+namespace {
+
+cmGccDepfileContent readPlainDepfile(const char* filePath)
+{
+ cmGccDepfileContent result;
+ cmsys::ifstream is(filePath);
+ if (!is.is_open())
+ return result;
+ std::string line;
+
+ cmGccStyleDependency dep;
+ bool readingRules = true;
+ while (cmSystemTools::GetLineFromStream(is, line)) {
+ if (line == "--RULES--") {
+ if (!dep.rules.empty()) {
+ result.push_back(std::move(dep));
+ dep = cmGccStyleDependency();
+ }
+ readingRules = true;
+ } else if (line == "--DEPENDENCIES--") {
+ readingRules = false;
+ } else {
+ std::vector<std::string>& dst = readingRules ? dep.rules : dep.paths;
+ dst.push_back(std::move(line));
+ line = std::string();
+ }
+ }
+
+ if (!dep.rules.empty()) {
+ result.push_back(std::move(dep));
+ }
+
+ return result;
+}
+
+bool compare(const std::vector<std::string>& actual,
+ const std::vector<std::string>& expected, const char* msg)
+{
+ if (actual.size() != expected.size()) {
+ std::cerr << msg << "expected " << expected.size() << " entries."
+ << std::endl
+ << "Actual number of entries: " << actual.size() << std::endl;
+ return false;
+ }
+ for (std::size_t i = 0; i < actual.size(); ++i) {
+ if (actual[i] != expected[i]) {
+ std::cerr << msg << std::endl
+ << "expected: " << expected[i] << std::endl
+ << "actual: " << actual[i] << std::endl;
+ return false;
+ }
+ }
+ return true;
+}
+
+bool compare(const cmGccDepfileContent& actual,
+ const cmGccDepfileContent& expected)
+{
+ if (actual.size() != expected.size()) {
+ std::cerr << "Expected " << expected.size() << " entries." << std::endl
+ << "Actual number of entries: " << actual.size() << std::endl;
+ return false;
+ }
+ for (std::size_t i = 0; i < actual.size(); ++i) {
+ if (!compare(actual[i].rules, expected[i].rules, "Rules differ: ") ||
+ !compare(actual[i].paths, expected[i].paths, "Paths differ: ")) {
+ return false;
+ }
+ }
+ return true;
+}
+
+void dump(const char* label, const cmGccDepfileContent& dfc)
+{
+ std::cerr << label << std::endl;
+ for (const auto& entry : dfc) {
+ auto rit = entry.rules.cbegin();
+ if (rit != entry.rules.cend()) {
+ std::cerr << *rit;
+ for (++rit; rit != entry.rules.cend(); ++rit) {
+ std::cerr << " " << *rit;
+ }
+ std::cerr << ": " << std::endl;
+ }
+ for (const auto& path : entry.paths) {
+ std::cerr << " " << path << std::endl;
+ }
+ }
+}
+
+} // anonymous namespace
+
+int testGccDepfileReader(int argc, char* argv[])
+{
+ if (argc < 2) {
+ std::cout << "Invalid arguments.\n";
+ return -1;
+ }
+
+ std::string dataDirPath = argv[1];
+ dataDirPath += "/testGccDepfileReader_data";
+ const int numberOfTestFiles = 3;
+ for (int i = 1; i <= numberOfTestFiles; ++i) {
+ const std::string base = dataDirPath + "/deps" + std::to_string(i);
+ const std::string depfile = base + ".d";
+ const std::string plainDepfile = base + ".txt";
+ std::cout << "Comparing " << base << " with " << plainDepfile << std::endl;
+ const auto actual = cmReadGccDepfile(depfile.c_str());
+ const auto expected = readPlainDepfile(plainDepfile.c_str());
+ if (!compare(actual, expected)) {
+ dump("actual", actual);
+ dump("expected", expected);
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/Tests/CMakeLib/testGccDepfileReader_data/deps1.d b/Tests/CMakeLib/testGccDepfileReader_data/deps1.d
new file mode 100644
index 0000000..9e34863
--- /dev/null
+++ b/Tests/CMakeLib/testGccDepfileReader_data/deps1.d
@@ -0,0 +1,20 @@
+main.o: main.cpp /usr/include/stdc-predef.h /usr/include/stdio.h \
+ /usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
+ /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \
+ /usr/include/x86_64-linux-gnu/bits/wordsize.h \
+ /usr/include/x86_64-linux-gnu/bits/long-double.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
+ /usr/lib/gcc/x86_64-linux-gnu/8/include/stddef.h \
+ /usr/lib/gcc/x86_64-linux-gnu/8/include/stdarg.h \
+ /usr/include/x86_64-linux-gnu/bits/types.h \
+ /usr/include/x86_64-linux-gnu/bits/typesizes.h \
+ /usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h \
+ /usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \
+ /usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h \
+ /usr/include/x86_64-linux-gnu/bits/types/__FILE.h \
+ /usr/include/x86_64-linux-gnu/bits/types/FILE.h \
+ /usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h \
+ /usr/include/x86_64-linux-gnu/bits/types/cookie_io_functions_t.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
+ /usr/include/x86_64-linux-gnu/bits/sys_errlist.h
diff --git a/Tests/CMakeLib/testGccDepfileReader_data/deps1.txt b/Tests/CMakeLib/testGccDepfileReader_data/deps1.txt
new file mode 100644
index 0000000..fd2679f
--- /dev/null
+++ b/Tests/CMakeLib/testGccDepfileReader_data/deps1.txt
@@ -0,0 +1,26 @@
+--RULES--
+main.o
+--DEPENDENCIES--
+main.cpp
+/usr/include/stdc-predef.h
+/usr/include/stdio.h
+/usr/include/x86_64-linux-gnu/bits/libc-header-start.h
+/usr/include/features.h
+/usr/include/x86_64-linux-gnu/sys/cdefs.h
+/usr/include/x86_64-linux-gnu/bits/wordsize.h
+/usr/include/x86_64-linux-gnu/bits/long-double.h
+/usr/include/x86_64-linux-gnu/gnu/stubs.h
+/usr/include/x86_64-linux-gnu/gnu/stubs-64.h
+/usr/lib/gcc/x86_64-linux-gnu/8/include/stddef.h
+/usr/lib/gcc/x86_64-linux-gnu/8/include/stdarg.h
+/usr/include/x86_64-linux-gnu/bits/types.h
+/usr/include/x86_64-linux-gnu/bits/typesizes.h
+/usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h
+/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h
+/usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h
+/usr/include/x86_64-linux-gnu/bits/types/__FILE.h
+/usr/include/x86_64-linux-gnu/bits/types/FILE.h
+/usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h
+/usr/include/x86_64-linux-gnu/bits/types/cookie_io_functions_t.h
+/usr/include/x86_64-linux-gnu/bits/stdio_lim.h
+/usr/include/x86_64-linux-gnu/bits/sys_errlist.h
diff --git a/Tests/CMakeLib/testGccDepfileReader_data/deps2.d b/Tests/CMakeLib/testGccDepfileReader_data/deps2.d
new file mode 100644
index 0000000..25f0d78
--- /dev/null
+++ b/Tests/CMakeLib/testGccDepfileReader_data/deps2.d
@@ -0,0 +1 @@
+foo.o bar.o: foobar.c
diff --git a/Tests/CMakeLib/testGccDepfileReader_data/deps2.txt b/Tests/CMakeLib/testGccDepfileReader_data/deps2.txt
new file mode 100644
index 0000000..afaf78e
--- /dev/null
+++ b/Tests/CMakeLib/testGccDepfileReader_data/deps2.txt
@@ -0,0 +1,5 @@
+--RULES--
+foo.o
+bar.o
+--DEPENDENCIES--
+foobar.c
diff --git a/Tests/CMakeLib/testGccDepfileReader_data/deps3.d b/Tests/CMakeLib/testGccDepfileReader_data/deps3.d
new file mode 100644
index 0000000..d75ceed
--- /dev/null
+++ b/Tests/CMakeLib/testGccDepfileReader_data/deps3.d
@@ -0,0 +1,2 @@
+main.o: main.cpp foo\#bar.h foo\\#bar.h foo\ bar.h \
+ foo\\\ bar.h foo\\\\\ bar.h foo\\\\ foo$$bar.h
diff --git a/Tests/CMakeLib/testGccDepfileReader_data/deps3.txt b/Tests/CMakeLib/testGccDepfileReader_data/deps3.txt
new file mode 100644
index 0000000..448f69c
--- /dev/null
+++ b/Tests/CMakeLib/testGccDepfileReader_data/deps3.txt
@@ -0,0 +1,11 @@
+--RULES--
+main.o
+--DEPENDENCIES--
+main.cpp
+foo#bar.h
+foo\#bar.h
+foo bar.h
+foo\ bar.h
+foo\\ bar.h
+foo\\\\
+foo$bar.h
diff --git a/Tests/CMakeLib/testGeneratedFileStream.cxx b/Tests/CMakeLib/testGeneratedFileStream.cxx
new file mode 100644
index 0000000..de44a0b
--- /dev/null
+++ b/Tests/CMakeLib/testGeneratedFileStream.cxx
@@ -0,0 +1,88 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include <iostream>
+#include <string>
+
+#include "cmGeneratedFileStream.h"
+#include "cmSystemTools.h"
+
+#define cmFailed(m1, m2) \
+ std::cout << "FAILED: " << (m1) << (m2) << "\n"; \
+ failed = 1
+
+int testGeneratedFileStream(int /*unused*/, char* /*unused*/ [])
+{
+ int failed = 0;
+ cmGeneratedFileStream gm;
+ std::string file1 = "generatedFile1";
+ std::string file2 = "generatedFile2";
+ std::string file3 = "generatedFile3";
+ std::string file4 = "generatedFile4";
+ std::string file1tmp = file1 + ".tmp";
+ std::string file2tmp = file2 + ".tmp";
+ std::string file3tmp = file3 + ".tmp";
+ std::string file4tmp = file4 + ".tmp";
+ gm.Open(file1.c_str());
+ gm << "This is generated file 1";
+ gm.Close();
+ gm.Open(file2.c_str());
+ gm << "This is generated file 2";
+ gm.Close();
+ gm.Open(file3.c_str());
+ gm << "This is generated file 3";
+ gm.Close();
+ gm.Open(file4.c_str());
+ gm << "This is generated file 4";
+ gm.Close();
+ if (cmSystemTools::FileExists(file1.c_str())) {
+ if (cmSystemTools::FileExists(file2.c_str())) {
+ if (cmSystemTools::FileExists(file3.c_str())) {
+ if (cmSystemTools::FileExists(file4.c_str())) {
+ if (cmSystemTools::FileExists(file1tmp.c_str())) {
+ cmFailed("Something wrong with cmGeneratedFileStream. Temporary "
+ "file is still here: ",
+ file1tmp.c_str());
+ } else if (cmSystemTools::FileExists(file2tmp.c_str())) {
+ cmFailed("Something wrong with cmGeneratedFileStream. Temporary "
+ "file is still here: ",
+ file2tmp.c_str());
+ } else if (cmSystemTools::FileExists(file3tmp.c_str())) {
+ cmFailed("Something wrong with cmGeneratedFileStream. Temporary "
+ "file is still here: ",
+ file3tmp.c_str());
+ } else if (cmSystemTools::FileExists(file4tmp.c_str())) {
+ cmFailed("Something wrong with cmGeneratedFileStream. Temporary "
+ "file is still here: ",
+ file4tmp.c_str());
+ } else {
+ std::cout << "cmGeneratedFileStream works\n";
+ }
+ } else {
+ cmFailed(
+ "Something wrong with cmGeneratedFileStream. Cannot find file: ",
+ file4.c_str());
+ }
+ } else {
+ cmFailed("Something wrong with cmGeneratedFileStream. Found file: ",
+ file3.c_str());
+ }
+ } else {
+ cmFailed(
+ "Something wrong with cmGeneratedFileStream. Cannot find file: ",
+ file2.c_str());
+ }
+ } else {
+ cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ",
+ file1.c_str());
+ }
+ cmSystemTools::RemoveFile(file1);
+ cmSystemTools::RemoveFile(file2);
+ cmSystemTools::RemoveFile(file3);
+ cmSystemTools::RemoveFile(file4);
+ cmSystemTools::RemoveFile(file1tmp);
+ cmSystemTools::RemoveFile(file2tmp);
+ cmSystemTools::RemoveFile(file3tmp);
+ cmSystemTools::RemoveFile(file4tmp);
+
+ return failed;
+}
diff --git a/Tests/CMakeLib/testOptional.cxx b/Tests/CMakeLib/testOptional.cxx
new file mode 100644
index 0000000..c6bc9c2
--- /dev/null
+++ b/Tests/CMakeLib/testOptional.cxx
@@ -0,0 +1,701 @@
+#include <iostream>
+#include <type_traits>
+#include <vector>
+
+#include <cm/optional>
+#include <cm/utility>
+
+class EventLogger;
+
+class Event
+{
+public:
+ enum EventType
+ {
+ DEFAULT_CONSTRUCT,
+ COPY_CONSTRUCT,
+ MOVE_CONSTRUCT,
+ VALUE_CONSTRUCT,
+
+ DESTRUCT,
+
+ COPY_ASSIGN,
+ MOVE_ASSIGN,
+ VALUE_ASSIGN,
+
+ REFERENCE,
+ CONST_REFERENCE,
+ RVALUE_REFERENCE,
+ CONST_RVALUE_REFERENCE,
+
+ SWAP,
+ };
+
+ EventType Type;
+ const EventLogger* Logger1;
+ const EventLogger* Logger2;
+ int Value;
+
+ bool operator==(const Event& other) const;
+ bool operator!=(const Event& other) const;
+};
+
+bool Event::operator==(const Event& other) const
+{
+ return this->Type == other.Type && this->Logger1 == other.Logger1 &&
+ this->Logger2 == other.Logger2 && this->Value == other.Value;
+}
+
+bool Event::operator!=(const Event& other) const
+{
+ return !(*this == other);
+}
+
+static std::vector<Event> events;
+
+class EventLogger
+{
+public:
+ EventLogger();
+ EventLogger(const EventLogger& other);
+ EventLogger(EventLogger&& other);
+ EventLogger(int value);
+
+ ~EventLogger();
+
+ EventLogger& operator=(const EventLogger& other);
+ EventLogger& operator=(EventLogger&& other);
+ EventLogger& operator=(int value);
+
+ void Reference() &;
+ void Reference() const&;
+ void Reference() &&;
+ void Reference() const&&;
+
+ int Value = 0;
+};
+
+// Certain builds of GCC generate false -Wmaybe-uninitialized warnings when
+// doing a release build with the system version of std::optional. These
+// warnings do not manifest when using our own cm::optional implementation.
+// Silence these false warnings.
+#if defined(__GNUC__) && !defined(__clang__)
+# define BEGIN_IGNORE_UNINITIALIZED \
+ _Pragma("GCC diagnostic push") \
+ _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
+# define END_IGNORE_UNINITIALIZED _Pragma("GCC diagnostic pop")
+#else
+# define BEGIN_IGNORE_UNINITIALIZED
+# define END_IGNORE_UNINITIALIZED
+#endif
+
+void swap(EventLogger& e1, EventLogger& e2)
+{
+ BEGIN_IGNORE_UNINITIALIZED
+ events.push_back({ Event::SWAP, &e1, &e2, e2.Value });
+ END_IGNORE_UNINITIALIZED
+ auto tmp = e1.Value;
+ e1.Value = e2.Value;
+ e2.Value = tmp;
+}
+
+EventLogger::EventLogger()
+ : Value(0)
+{
+ events.push_back({ Event::DEFAULT_CONSTRUCT, this, nullptr, 0 });
+}
+
+EventLogger::EventLogger(const EventLogger& other)
+ : Value(other.Value)
+{
+ events.push_back({ Event::COPY_CONSTRUCT, this, &other, other.Value });
+}
+
+BEGIN_IGNORE_UNINITIALIZED
+EventLogger::EventLogger(EventLogger&& other)
+ : Value(other.Value)
+{
+ events.push_back({ Event::MOVE_CONSTRUCT, this, &other, other.Value });
+}
+END_IGNORE_UNINITIALIZED
+
+EventLogger::EventLogger(int value)
+ : Value(value)
+{
+ events.push_back({ Event::VALUE_CONSTRUCT, this, nullptr, value });
+}
+
+EventLogger::~EventLogger()
+{
+ BEGIN_IGNORE_UNINITIALIZED
+ events.push_back({ Event::DESTRUCT, this, nullptr, this->Value });
+ END_IGNORE_UNINITIALIZED
+}
+
+EventLogger& EventLogger::operator=(const EventLogger& other)
+{
+ events.push_back({ Event::COPY_ASSIGN, this, &other, other.Value });
+ this->Value = other.Value;
+ return *this;
+}
+
+EventLogger& EventLogger::operator=(EventLogger&& other)
+{
+ events.push_back({ Event::MOVE_ASSIGN, this, &other, other.Value });
+ this->Value = other.Value;
+ return *this;
+}
+
+EventLogger& EventLogger::operator=(int value)
+{
+ events.push_back({ Event::VALUE_ASSIGN, this, nullptr, value });
+ this->Value = value;
+ return *this;
+}
+
+void EventLogger::Reference() &
+{
+ events.push_back({ Event::REFERENCE, this, nullptr, this->Value });
+}
+
+void EventLogger::Reference() const&
+{
+ events.push_back({ Event::CONST_REFERENCE, this, nullptr, this->Value });
+}
+
+void EventLogger::Reference() &&
+{
+ events.push_back({ Event::RVALUE_REFERENCE, this, nullptr, this->Value });
+}
+
+void EventLogger::Reference() const&&
+{
+ events.push_back(
+ { Event::CONST_RVALUE_REFERENCE, this, nullptr, this->Value });
+}
+
+static bool testDefaultConstruct(std::vector<Event>& expected)
+{
+ const cm::optional<EventLogger> o{};
+
+ expected = {};
+ return true;
+}
+
+static bool testNulloptConstruct(std::vector<Event>& expected)
+{
+ const cm::optional<EventLogger> o{ cm::nullopt };
+
+ expected = {};
+ return true;
+}
+
+static bool testValueConstruct(std::vector<Event>& expected)
+{
+ const cm::optional<EventLogger> o{ 4 };
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &*o, nullptr, 4 },
+ { Event::DESTRUCT, &*o, nullptr, 4 },
+ };
+ return true;
+}
+
+static bool testInPlaceConstruct(std::vector<Event>& expected)
+{
+ const cm::optional<EventLogger> o1{ cm::in_place, 4 };
+ const cm::optional<EventLogger> o2{ cm::in_place_t{}, 4 };
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
+ { Event::VALUE_CONSTRUCT, &*o2, nullptr, 4 },
+ { Event::DESTRUCT, &*o2, nullptr, 4 },
+ { Event::DESTRUCT, &*o1, nullptr, 4 },
+ };
+ return true;
+}
+
+static bool testCopyConstruct(std::vector<Event>& expected)
+{
+ const cm::optional<EventLogger> o1{ 4 };
+ const cm::optional<EventLogger> o2{ o1 };
+ const cm::optional<EventLogger> o3{};
+ const cm::optional<EventLogger> o4{ o3 };
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
+ { Event::COPY_CONSTRUCT, &*o2, &o1.value(), 4 },
+ { Event::DESTRUCT, &*o2, nullptr, 4 },
+ { Event::DESTRUCT, &*o1, nullptr, 4 },
+ };
+ return true;
+}
+
+static bool testMoveConstruct(std::vector<Event>& expected)
+{
+ cm::optional<EventLogger> o1{ 4 };
+ const cm::optional<EventLogger> o2{ std::move(o1) };
+ cm::optional<EventLogger> o3{};
+ const cm::optional<EventLogger> o4{ std::move(o3) };
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
+ { Event::MOVE_CONSTRUCT, &*o2, &*o1, 4 },
+ { Event::DESTRUCT, &*o2, nullptr, 4 },
+ { Event::DESTRUCT, &*o1, nullptr, 4 },
+ };
+ return true;
+}
+
+static bool testNulloptAssign(std::vector<Event>& expected)
+{
+ cm::optional<EventLogger> o1{ 4 };
+ auto const* v1 = &*o1;
+ o1 = cm::nullopt;
+ cm::optional<EventLogger> o2{};
+ o2 = cm::nullopt;
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, v1, nullptr, 4 },
+ { Event::DESTRUCT, v1, nullptr, 4 },
+ };
+ return true;
+}
+
+static bool testCopyAssign(std::vector<Event>& expected)
+{
+ cm::optional<EventLogger> o1{};
+ const cm::optional<EventLogger> o2{ 4 };
+ auto const* v2 = &*o2;
+ o1 = o2;
+ auto const* v1 = &*o1;
+ const cm::optional<EventLogger> o3{ 5 };
+ auto const* v3 = &*o3;
+ o1 = o3;
+ const cm::optional<EventLogger> o4{};
+ o1 = o4;
+ o1 = o4; // Intentionally duplicated to test assigning an empty optional to
+ // an empty optional
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, v2, nullptr, 4 },
+ { Event::COPY_CONSTRUCT, v1, v2, 4 },
+ { Event::VALUE_CONSTRUCT, v3, nullptr, 5 },
+ { Event::COPY_ASSIGN, v1, v3, 5 },
+ { Event::DESTRUCT, v1, nullptr, 5 },
+ { Event::DESTRUCT, v3, nullptr, 5 },
+ { Event::DESTRUCT, v2, nullptr, 4 },
+ };
+ return true;
+}
+
+static bool testMoveAssign(std::vector<Event>& expected)
+{
+ cm::optional<EventLogger> o1{};
+ cm::optional<EventLogger> o2{ 4 };
+ auto const* v2 = &*o2;
+ o1 = std::move(o2);
+ auto const* v1 = &*o1;
+ cm::optional<EventLogger> o3{ 5 };
+ auto const* v3 = &*o3;
+ o1 = std::move(o3);
+ cm::optional<EventLogger> o4{};
+ o1 = std::move(o4);
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, v2, nullptr, 4 },
+ { Event::MOVE_CONSTRUCT, v1, v2, 4 },
+ { Event::VALUE_CONSTRUCT, v3, nullptr, 5 },
+ { Event::MOVE_ASSIGN, v1, v3, 5 },
+ { Event::DESTRUCT, v1, nullptr, 5 },
+ { Event::DESTRUCT, v3, nullptr, 5 },
+ { Event::DESTRUCT, v2, nullptr, 4 },
+ };
+ return true;
+}
+
+static bool testPointer(std::vector<Event>& expected)
+{
+ cm::optional<EventLogger> o1{ 4 };
+ const cm::optional<EventLogger> o2{ 5 };
+
+ o1->Reference();
+ o2->Reference();
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
+ { Event::VALUE_CONSTRUCT, &*o2, nullptr, 5 },
+ { Event::REFERENCE, &*o1, nullptr, 4 },
+ { Event::CONST_REFERENCE, &*o2, nullptr, 5 },
+ { Event::DESTRUCT, &*o2, nullptr, 5 },
+ { Event::DESTRUCT, &*o1, nullptr, 4 },
+ };
+ return true;
+}
+
+#if !__GNUC__ || __GNUC__ > 4
+# define ALLOW_CONST_RVALUE
+#endif
+
+static bool testDereference(std::vector<Event>& expected)
+{
+ cm::optional<EventLogger> o1{ 4 };
+ auto const* v1 = &*o1;
+ const cm::optional<EventLogger> o2{ 5 };
+ auto const* v2 = &*o2;
+
+ (*o1).Reference();
+ (*o2).Reference();
+ (*std::move(o1)).Reference();
+#ifdef ALLOW_CONST_RVALUE
+ (*std::move(o2)).Reference(); // Broken in GCC 4.9.0. Sigh...
+#endif
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, v1, nullptr, 4 },
+ { Event::VALUE_CONSTRUCT, v2, nullptr, 5 },
+ { Event::REFERENCE, v1, nullptr, 4 },
+ { Event::CONST_REFERENCE, v2, nullptr, 5 },
+ { Event::RVALUE_REFERENCE, v1, nullptr, 4 },
+#ifdef ALLOW_CONST_RVALUE
+ { Event::CONST_RVALUE_REFERENCE, v2, nullptr, 5 },
+#endif
+ { Event::DESTRUCT, v2, nullptr, 5 },
+ { Event::DESTRUCT, v1, nullptr, 4 },
+ };
+ return true;
+}
+
+static bool testHasValue(std::vector<Event>& expected)
+{
+ bool retval = true;
+
+ const cm::optional<EventLogger> o1{ 4 };
+ const cm::optional<EventLogger> o2{};
+
+ if (!o1.has_value()) {
+ std::cout << "o1 should have a value" << std::endl;
+ retval = false;
+ }
+
+ if (!o1) {
+ std::cout << "(bool)o1 should be true" << std::endl;
+ retval = false;
+ }
+
+ if (o2.has_value()) {
+ std::cout << "o2 should not have a value" << std::endl;
+ retval = false;
+ }
+
+ if (o2) {
+ std::cout << "(bool)o2 should be false" << std::endl;
+ retval = false;
+ }
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
+ { Event::DESTRUCT, &*o1, nullptr, 4 },
+ };
+ return retval;
+}
+
+static bool testValue(std::vector<Event>& expected)
+{
+ bool retval = true;
+
+ cm::optional<EventLogger> o1{ 4 };
+ const cm::optional<EventLogger> o2{ 5 };
+ cm::optional<EventLogger> o3{};
+ const cm::optional<EventLogger> o4{};
+
+ o1.value().Reference();
+ o2.value().Reference();
+
+ bool thrown = false;
+ try {
+ (void)o3.value();
+ } catch (cm::bad_optional_access&) {
+ thrown = true;
+ }
+ if (!thrown) {
+ std::cout << "o3.value() did not throw" << std::endl;
+ retval = false;
+ }
+
+ thrown = false;
+ try {
+ (void)o4.value();
+ } catch (cm::bad_optional_access&) {
+ thrown = true;
+ }
+ if (!thrown) {
+ std::cout << "o4.value() did not throw" << std::endl;
+ retval = false;
+ }
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
+ { Event::VALUE_CONSTRUCT, &*o2, nullptr, 5 },
+ { Event::REFERENCE, &*o1, nullptr, 4 },
+ { Event::CONST_REFERENCE, &*o2, nullptr, 5 },
+ { Event::DESTRUCT, &*o2, nullptr, 5 },
+ { Event::DESTRUCT, &*o1, nullptr, 4 },
+ };
+ return retval;
+}
+
+static bool testValueOr()
+{
+ bool retval = true;
+
+ const cm::optional<EventLogger> o1{ 4 };
+ cm::optional<EventLogger> o2{ 5 };
+ const cm::optional<EventLogger> o3{};
+ cm::optional<EventLogger> o4{};
+
+ EventLogger e1{ 6 };
+ EventLogger e2{ 7 };
+ EventLogger e3{ 8 };
+ EventLogger e4{ 9 };
+
+ EventLogger r1 = o1.value_or(e1);
+ if (r1.Value != 4) {
+ std::cout << "r1.Value should be 4" << std::endl;
+ retval = false;
+ }
+ EventLogger r2 = std::move(o2).value_or(e2);
+ if (r2.Value != 5) {
+ std::cout << "r2.Value should be 5" << std::endl;
+ retval = false;
+ }
+ EventLogger r3 = o3.value_or(e3);
+ if (r3.Value != 8) {
+ std::cout << "r3.Value should be 8" << std::endl;
+ retval = false;
+ }
+ EventLogger r4 = std::move(o4).value_or(e4);
+ if (r4.Value != 9) {
+ std::cout << "r4.Value should be 9" << std::endl;
+ retval = false;
+ }
+
+ return retval;
+}
+
+static bool testSwap(std::vector<Event>& expected)
+{
+ bool retval = true;
+
+ cm::optional<EventLogger> o1{ 4 };
+ auto const* v1 = &*o1;
+ cm::optional<EventLogger> o2{};
+
+ o1.swap(o2);
+ auto const* v2 = &*o2;
+
+ if (o1.has_value()) {
+ std::cout << "o1 should not have value" << std::endl;
+ retval = false;
+ }
+ if (!o2.has_value()) {
+ std::cout << "o2 should have value" << std::endl;
+ retval = false;
+ }
+ if (o2.value().Value != 4) {
+ std::cout << "value of o2 should be 4" << std::endl;
+ retval = false;
+ }
+
+ o1.swap(o2);
+
+ if (!o1.has_value()) {
+ std::cout << "o1 should have value" << std::endl;
+ retval = false;
+ }
+ if (o1.value().Value != 4) {
+ std::cout << "value of o1 should be 4" << std::endl;
+ retval = false;
+ }
+ if (o2.has_value()) {
+ std::cout << "o2 should not have value" << std::endl;
+ retval = false;
+ }
+
+ o2.emplace(5);
+ o1.swap(o2);
+
+ if (!o1.has_value()) {
+ std::cout << "o1 should have value" << std::endl;
+ retval = false;
+ }
+ if (o1.value().Value != 5) {
+ std::cout << "value of o1 should be 5" << std::endl;
+ retval = false;
+ }
+ if (!o2.has_value()) {
+ std::cout << "o2 should not have value" << std::endl;
+ retval = false;
+ }
+ if (o2.value().Value != 4) {
+ std::cout << "value of o2 should be 4" << std::endl;
+ retval = false;
+ }
+
+ o1.reset();
+ o2.reset();
+ o1.swap(o2);
+
+ if (o1.has_value()) {
+ std::cout << "o1 should not have value" << std::endl;
+ retval = false;
+ }
+ if (o2.has_value()) {
+ std::cout << "o2 should not have value" << std::endl;
+ retval = false;
+ }
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, v1, nullptr, 4 },
+ { Event::MOVE_CONSTRUCT, v2, v1, 4 },
+ { Event::DESTRUCT, v1, nullptr, 4 },
+ { Event::MOVE_CONSTRUCT, v1, v2, 4 },
+ { Event::DESTRUCT, v2, nullptr, 4 },
+ { Event::VALUE_CONSTRUCT, v2, nullptr, 5 },
+ { Event::SWAP, v1, v2, 5 },
+ { Event::DESTRUCT, v1, nullptr, 5 },
+ { Event::DESTRUCT, v2, nullptr, 4 },
+ };
+ return retval;
+}
+
+static bool testReset(std::vector<Event>& expected)
+{
+ bool retval = true;
+
+ cm::optional<EventLogger> o{ 4 };
+ auto const* v = &*o;
+
+ o.reset();
+
+ if (o.has_value()) {
+ std::cout << "o should not have value" << std::endl;
+ retval = false;
+ }
+
+ o.reset();
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, v, nullptr, 4 },
+ { Event::DESTRUCT, v, nullptr, 4 },
+ };
+ return retval;
+}
+
+static bool testEmplace(std::vector<Event>& expected)
+{
+ cm::optional<EventLogger> o{ 4 };
+
+ o.emplace(5);
+ o.reset();
+ o.emplace();
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &*o, nullptr, 4 },
+ { Event::DESTRUCT, &*o, nullptr, 4 },
+ { Event::VALUE_CONSTRUCT, &*o, nullptr, 5 },
+ { Event::DESTRUCT, &*o, nullptr, 5 },
+ { Event::DEFAULT_CONSTRUCT, &*o, nullptr, 0 },
+ { Event::DESTRUCT, &*o, nullptr, 0 },
+ };
+ return true;
+}
+
+static bool testMakeOptional(std::vector<Event>& expected)
+{
+ EventLogger e{ 4 };
+ cm::optional<EventLogger> o1 = cm::make_optional<EventLogger>(e);
+ cm::optional<EventLogger> o2 = cm::make_optional<EventLogger>(5);
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &e, nullptr, 4 },
+ { Event::COPY_CONSTRUCT, &*o1, &e, 4 },
+ { Event::VALUE_CONSTRUCT, &*o2, nullptr, 5 },
+ { Event::DESTRUCT, &*o2, nullptr, 5 },
+ { Event::DESTRUCT, &*o1, nullptr, 4 },
+ { Event::DESTRUCT, &e, nullptr, 4 },
+ };
+ return true;
+}
+
+static bool testMemoryRange(std::vector<Event>& expected)
+{
+ bool retval = true;
+
+ cm::optional<EventLogger> o{ 4 };
+
+ auto* ostart = &o;
+ auto* oend = ostart + 1;
+ auto* estart = &o.value();
+ auto* eend = estart + 1;
+
+ if (static_cast<void*>(estart) < static_cast<void*>(ostart) ||
+ static_cast<void*>(eend) > static_cast<void*>(oend)) {
+ std::cout << "value is not within memory range of optional" << std::endl;
+ retval = false;
+ }
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &*o, nullptr, 4 },
+ { Event::DESTRUCT, &*o, nullptr, 4 },
+ };
+ return retval;
+}
+
+int testOptional(int /*unused*/, char* /*unused*/ [])
+{
+ int retval = 0;
+
+#define DO_EVENT_TEST(name) \
+ do { \
+ events.clear(); \
+ std::vector<Event> expected; \
+ if (!name(expected)) { \
+ std::cout << "in " #name << std::endl; \
+ retval = 1; \
+ } else if (expected != events) { \
+ std::cout << #name " did not produce expected events" << std::endl; \
+ retval = 1; \
+ } \
+ } while (0)
+
+#define DO_TEST(name) \
+ do { \
+ if (!name()) { \
+ std::cout << "in " #name << std::endl; \
+ retval = 1; \
+ } \
+ } while (0)
+
+ DO_EVENT_TEST(testDefaultConstruct);
+ DO_EVENT_TEST(testNulloptConstruct);
+ DO_EVENT_TEST(testValueConstruct);
+ DO_EVENT_TEST(testInPlaceConstruct);
+ DO_EVENT_TEST(testCopyConstruct);
+ DO_EVENT_TEST(testMoveConstruct);
+ DO_EVENT_TEST(testNulloptAssign);
+ DO_EVENT_TEST(testCopyAssign);
+ DO_EVENT_TEST(testMoveAssign);
+ DO_EVENT_TEST(testPointer);
+ DO_EVENT_TEST(testDereference);
+ DO_EVENT_TEST(testHasValue);
+ DO_EVENT_TEST(testValue);
+ DO_TEST(testValueOr);
+ DO_EVENT_TEST(testSwap);
+ DO_EVENT_TEST(testReset);
+ DO_EVENT_TEST(testEmplace);
+ DO_EVENT_TEST(testMakeOptional);
+ DO_EVENT_TEST(testMemoryRange);
+
+ return retval;
+}
diff --git a/Tests/CMakeLib/testRST.cxx b/Tests/CMakeLib/testRST.cxx
new file mode 100644
index 0000000..28d80a5
--- /dev/null
+++ b/Tests/CMakeLib/testRST.cxx
@@ -0,0 +1,86 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include <iostream>
+#include <string>
+
+#include "cmsys/FStream.hxx"
+
+#include "cmRST.h"
+#include "cmSystemTools.h"
+
+void reportLine(std::ostream& os, bool ret, std::string const& line, bool eol)
+{
+ if (ret) {
+ os << "\"" << line << "\" (" << (eol ? "with EOL" : "without EOL") << ")";
+ } else {
+ os << "EOF";
+ }
+}
+
+int testRST(int argc, char* argv[])
+{
+ if (argc != 2) {
+ std::cerr << "Usage: testRST <dir>" << std::endl;
+ return 1;
+ }
+ std::string dir = argv[1];
+ if (dir.empty()) {
+ dir = ".";
+ }
+ std::string a_name = "testRST.actual";
+ std::string e_name = dir + "/testRST.expect";
+
+ // Process the test RST file.
+ {
+ std::string fname = dir + "/testRST.rst";
+ std::ofstream fout(a_name.c_str());
+ if (!fout) {
+ std::cerr << "Could not open output " << a_name << std::endl;
+ return 1;
+ }
+
+ cmRST r(fout, dir);
+ if (!r.ProcessFile(fname)) {
+ std::cerr << "Could not open input " << fname << std::endl;
+ return 1;
+ }
+ }
+
+ // Compare expected and actual outputs.
+ cmsys::ifstream e_fin(e_name.c_str());
+ cmsys::ifstream a_fin(a_name.c_str());
+ if (!e_fin) {
+ std::cerr << "Could not open input " << e_name << std::endl;
+ return 1;
+ }
+ if (!a_fin) {
+ std::cerr << "Could not open input " << a_name << std::endl;
+ return 1;
+ }
+ int lineno = 0;
+ bool e_ret;
+ bool a_ret;
+ do {
+ std::string e_line;
+ std::string a_line;
+ bool e_eol;
+ bool a_eol;
+ e_ret = cmSystemTools::GetLineFromStream(e_fin, e_line, &e_eol);
+ a_ret = cmSystemTools::GetLineFromStream(a_fin, a_line, &a_eol);
+ ++lineno;
+ if (e_ret != a_ret || e_line != a_line || e_eol != a_eol) {
+ a_fin.seekg(0, std::ios::beg);
+ std::cerr << "Actual output does not match that expected on line "
+ << lineno << "." << std::endl
+ << "Expected ";
+ reportLine(std::cerr, e_ret, e_line, e_eol);
+ std::cerr << " but got ";
+ reportLine(std::cerr, a_ret, a_line, a_eol);
+ std::cerr << "." << std::endl
+ << "Actual output:" << std::endl
+ << a_fin.rdbuf();
+ return 1;
+ }
+ } while (e_ret && a_ret);
+ return 0;
+}
diff --git a/Tests/CMakeLib/testRST.expect b/Tests/CMakeLib/testRST.expect
new file mode 100644
index 0000000..c19ee94
--- /dev/null
+++ b/Tests/CMakeLib/testRST.expect
@@ -0,0 +1,103 @@
+title_text
+----------
+
+Command ``some_cmd()`` explicit cmake domain.
+Command ``some_cmd()`` without target.
+Command ``some_cmd`` with target.
+Command ``some_cmd_<cmd>()`` placeholder without target.
+Command ``some_cmd_<cmd>`` placholder with target.
+Command ``some_cmd()`` with parens.
+Command ``some_cmd(SUB)`` with subcommand.
+Command ``some_cmd(SUB)`` with subcommand and target.
+Command ``some_cmd (SUB)`` with space and subcommand and target.
+Command ``some command`` with space and target.
+Variable ``some variable`` space and target.
+Variable ``<PLACEHOLDER>_VARIABLE`` with leading placeholder.
+Variable ``VARIABLE_<PLACEHOLDER>`` with trailing placeholder.
+Variable ``<PLACEHOLDER>_VARIABLE`` with leading placeholder and target.
+Variable ``VARIABLE_<PLACEHOLDER>`` with trailing placeholder and target.
+Environment variable ``SOME_ENV_VAR``.
+Environment variable ``some env var`` with space and target.
+Generator ``Some Generator`` with space.
+Generator ``Some Generator`` with space.
+Inline literal ``~!@#$%^&*( )_+-=\\[]{}'":;,<>.?/``.
+Inline link Link Text.
+Inline link Link Text <With \-escaped Brackets>.
+Inline literal ``__`` followed by inline link Link Text.
+
+First TOC entry.
+
+|not replaced|
+Second TOC entry.
+
+CMake Module Content
+
+More CMake Module Content
+
+Bracket Comment Content
+
+[
+Bracket Comment Content
+]
+
+.. cmake:command:: some_cmd
+
+ Command some_cmd description.
+
+.. command:: other_cmd
+
+ Command other_cmd description.
+
+.. cmake:variable:: some_var
+
+ Variable some_var description.
+
+.. variable:: other_var
+
+ Variable other_var description.
+
+ Parsed-literal included without directive.
+ Common Indentation Removed
+ # replaced in parsed literal
+
+ # Sample CMake code block
+ if(condition)
+ message(indented)
+ endif()
+ # |not replaced in literal|
+
+A literal block starts after a line consisting of two colons
+
+::
+
+ Literal block.
+ Common Indentation Removed
+ # |not replaced in literal|
+
+or after a paragraph ending in two colons::
+
+ Literal block.
+ Common Indentation Removed
+ # |not replaced in literal|
+
+but not after a line ending in two colons::
+in the middle of a paragraph.
+
+A literal block can be empty::
+
+
+
+.. productionlist::
+ grammar: `production`
+ production: "content rendered"
+
+.. note::
+ Notes are called out.
+
+substituted text with multiple lines becomes one line
+
+End of first include.
+
+Cross-include substitution text with ``some_cmd()`` reference.
+
+End of second include.
diff --git a/Tests/CMakeLib/testRST.rst b/Tests/CMakeLib/testRST.rst
new file mode 100644
index 0000000..d2d1140
--- /dev/null
+++ b/Tests/CMakeLib/testRST.rst
@@ -0,0 +1,110 @@
+.. index::
+ single: directive ignored
+
+title_text
+----------
+
+.. comment ignored
+..
+ comment ignored
+
+Command :cmake:command:`some_cmd` explicit cmake domain.
+Command :command:`some_cmd` without target.
+Command :command:`some_cmd <some_cmd>` with target.
+Command :command:`some_cmd_<cmd>` placeholder without target.
+Command :command:`some_cmd_<cmd> <some_cmd>` placholder with target.
+Command :command:`some_cmd()` with parens.
+Command :command:`some_cmd(SUB)` with subcommand.
+Command :command:`some_cmd(SUB) <some_cmd>` with subcommand and target.
+Command :command:`some_cmd (SUB) <some_cmd>` with space and subcommand and target.
+Command :command:`some command <some_cmd>` with space and target.
+Variable :variable:`some variable <some_var>` space and target.
+Variable :variable:`<PLACEHOLDER>_VARIABLE` with leading placeholder.
+Variable :variable:`VARIABLE_<PLACEHOLDER>` with trailing placeholder.
+Variable :variable:`<PLACEHOLDER>_VARIABLE <target>` with leading placeholder and target.
+Variable :variable:`VARIABLE_<PLACEHOLDER> <target>` with trailing placeholder and target.
+Environment variable :envvar:`SOME_ENV_VAR`.
+Environment variable :envvar:`some env var <SOME_ENV_VAR>` with space and target.
+Generator :generator:`Some Generator` with space.
+Generator :cpack_gen:`Some Generator` with space.
+Inline literal ``~!@#$%^&*( )_+-=\\[]{}'":;,<>.?/``.
+Inline link `Link Text <ExternalDest>`_.
+Inline link `Link Text \<With \\-escaped Brackets\> <ExternalDest>`_.
+Inline literal ``__`` followed by inline link `Link Text <InternalDest_>`_.
+
+.. |not replaced| replace:: not replaced through toctree
+.. |not replaced in literal| replace:: replaced in parsed literal
+
+.. toctree::
+ :maxdepth: 2
+
+ testRSTtoc1
+ /testRSTtoc2
+
+.. cmake-module:: testRSTmod.cmake
+
+.. cmake:command:: some_cmd
+
+ Command some_cmd description.
+
+.. command:: other_cmd
+
+ Command other_cmd description.
+
+.. cmake:variable:: some_var
+
+ Variable some_var description.
+
+.. variable:: other_var
+
+ Variable other_var description.
+
+.. parsed-literal::
+
+ Parsed-literal included without directive.
+ Common Indentation Removed
+ # |not replaced in literal|
+
+.. code-block:: cmake
+
+ # Sample CMake code block
+ if(condition)
+ message(indented)
+ endif()
+ # |not replaced in literal|
+
+A literal block starts after a line consisting of two colons
+
+::
+
+ Literal block.
+ Common Indentation Removed
+ # |not replaced in literal|
+
+or after a paragraph ending in two colons::
+
+ Literal block.
+ Common Indentation Removed
+ # |not replaced in literal|
+
+but not after a line ending in two colons::
+in the middle of a paragraph.
+
+A literal block can be empty::
+
+
+
+.. productionlist::
+ grammar: `production`
+ production: "content rendered"
+
+.. note::
+ Notes are called out.
+
+.. |substitution| replace::
+ |nested substitution|
+ with multiple lines becomes one line
+.. |nested substitution| replace:: substituted text
+
+.. include:: testRSTinclude1.rst
+.. include:: /testRSTinclude2.rst
diff --git a/Tests/CMakeLib/testRSTinclude1.rst b/Tests/CMakeLib/testRSTinclude1.rst
new file mode 100644
index 0000000..91d394e
--- /dev/null
+++ b/Tests/CMakeLib/testRSTinclude1.rst
@@ -0,0 +1,6 @@
+|substitution|
+
+.. |cross-include substitution| replace:: Cross-include substitution text
+ with :command:`some_cmd` reference.
+
+End of first include.
diff --git a/Tests/CMakeLib/testRSTinclude2.rst b/Tests/CMakeLib/testRSTinclude2.rst
new file mode 100644
index 0000000..f2d619c
--- /dev/null
+++ b/Tests/CMakeLib/testRSTinclude2.rst
@@ -0,0 +1,3 @@
+|cross-include substitution|
+
+End of second include.
diff --git a/Tests/CMakeLib/testRSTmod.cmake b/Tests/CMakeLib/testRSTmod.cmake
new file mode 100644
index 0000000..8b807a6
--- /dev/null
+++ b/Tests/CMakeLib/testRSTmod.cmake
@@ -0,0 +1,11 @@
+#.rst:
+# CMake Module Content
+#.rst:
+# More CMake Module Content
+#[[.rst:
+Bracket Comment Content
+# not part of content]] # not part of content
+#[=[.rst:
+[
+Bracket Comment Content
+]]=] # not part of content
diff --git a/Tests/CMakeLib/testRSTtoc1.rst b/Tests/CMakeLib/testRSTtoc1.rst
new file mode 100644
index 0000000..fa7806e
--- /dev/null
+++ b/Tests/CMakeLib/testRSTtoc1.rst
@@ -0,0 +1,2 @@
+.. |not replaced| replace:: not replaced across toctree
+First TOC entry.
diff --git a/Tests/CMakeLib/testRSTtoc2.rst b/Tests/CMakeLib/testRSTtoc2.rst
new file mode 100644
index 0000000..9fd2fcb
--- /dev/null
+++ b/Tests/CMakeLib/testRSTtoc2.rst
@@ -0,0 +1,2 @@
+|not replaced|
+Second TOC entry.
diff --git a/Tests/CMakeLib/testRange.cxx b/Tests/CMakeLib/testRange.cxx
new file mode 100644
index 0000000..4efe98e
--- /dev/null
+++ b/Tests/CMakeLib/testRange.cxx
@@ -0,0 +1,45 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include "cmRange.h"
+
+#define ASSERT_TRUE(x) \
+ do { \
+ if (!(x)) { \
+ std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << "\n"; \
+ return -1; \
+ } \
+ } while (false)
+
+int testRange(int /*unused*/, char* /*unused*/ [])
+{
+ std::vector<int> const testData = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+
+ ASSERT_TRUE(!cmMakeRange(testData).empty());
+ ASSERT_TRUE(cmMakeRange(testData).size() == 10);
+
+ ASSERT_TRUE(!cmMakeRange(testData).advance(5).empty());
+ ASSERT_TRUE(cmMakeRange(testData).advance(5).size() == 5);
+
+ ASSERT_TRUE(cmMakeRange(testData).advance(5).retreat(5).empty());
+ ASSERT_TRUE(cmMakeRange(testData).advance(5).retreat(5).size() == 0);
+
+ ASSERT_TRUE(cmMakeRange(testData).any_of([](int n) { return n % 3 == 0; }));
+ ASSERT_TRUE(cmMakeRange(testData).all_of([](int n) { return n < 11; }));
+ ASSERT_TRUE(cmMakeRange(testData).none_of([](int n) { return n > 11; }));
+
+ std::vector<int> const evenData = { 2, 4, 6, 8, 10 };
+ ASSERT_TRUE(cmMakeRange(testData).filter([](int n) { return n % 2 == 0; }) ==
+ cmMakeRange(evenData));
+
+ std::vector<std::string> const stringRange = { "1", "2", "3", "4", "5" };
+ ASSERT_TRUE(cmMakeRange(testData)
+ .transform([](int n) { return std::to_string(n); })
+ .retreat(5) == cmMakeRange(stringRange));
+
+ return 0;
+}
diff --git a/Tests/CMakeLib/testString.cxx b/Tests/CMakeLib/testString.cxx
new file mode 100644
index 0000000..1fd3f38
--- /dev/null
+++ b/Tests/CMakeLib/testString.cxx
@@ -0,0 +1,1349 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include <cstddef>
+#include <cstring>
+#include <iostream>
+#include <iterator>
+#include <sstream>
+#include <stdexcept>
+#include <string>
+#include <type_traits>
+#include <utility>
+
+#include <cm/string_view>
+
+#include "cm_static_string_view.hxx"
+
+#include "cmString.hxx"
+
+#define ASSERT_TRUE(x) \
+ do { \
+ if (!(x)) { \
+ std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << "\n"; \
+ return false; \
+ } \
+ } while (false)
+
+static bool testConstructDefault()
+{
+ std::cout << "testConstructDefault()\n";
+ cm::String str;
+ cm::String const& str_const = str;
+ ASSERT_TRUE(bool(str_const) == false);
+ ASSERT_TRUE(str_const.data() == nullptr);
+ ASSERT_TRUE(str_const.size() == 0);
+ ASSERT_TRUE(str_const.empty());
+ ASSERT_TRUE(str_const.is_stable());
+ ASSERT_TRUE(str.c_str() == nullptr);
+ ASSERT_TRUE(str.str().empty());
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testFromNullPtr(cm::String str)
+{
+ cm::String const& str_const = str;
+ ASSERT_TRUE(bool(str_const) == false);
+ ASSERT_TRUE(str_const.data() == nullptr);
+ ASSERT_TRUE(str_const.size() == 0);
+ ASSERT_TRUE(str_const.empty());
+ ASSERT_TRUE(str_const.is_stable());
+ ASSERT_TRUE(str.c_str() == nullptr);
+ ASSERT_TRUE(str.str().empty());
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testConstructFromNullPtr()
+{
+ std::cout << "testConstructFromNullPtr()\n";
+ return testFromNullPtr(nullptr);
+}
+
+static bool testAssignFromNullPtr()
+{
+ std::cout << "testAssignFromNullPtr()\n";
+ cm::String str;
+ str = nullptr;
+ return testFromNullPtr(str);
+}
+
+static bool testFromCStrNull(cm::String str)
+{
+ cm::String const& str_const = str;
+ ASSERT_TRUE(bool(str_const) == false);
+ ASSERT_TRUE(str_const.data() == nullptr);
+ ASSERT_TRUE(str_const.size() == 0);
+ ASSERT_TRUE(str_const.empty());
+ ASSERT_TRUE(str_const.is_stable());
+ ASSERT_TRUE(str.c_str() == nullptr);
+ ASSERT_TRUE(str.str().empty());
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testConstructFromCStrNull()
+{
+ std::cout << "testConstructFromCStrNull()\n";
+ const char* null = nullptr;
+ return testFromCStrNull(null);
+}
+
+static bool testAssignFromCStrNull()
+{
+ std::cout << "testAssignFromCStrNull()\n";
+ const char* null = nullptr;
+ cm::String str;
+ str = null;
+ return testFromCStrNull(str);
+}
+
+static char const charArray[] = "abc";
+
+static bool testFromCharArray(cm::String str)
+{
+ cm::String const& str_const = str;
+ ASSERT_TRUE(str_const.data() != charArray);
+ ASSERT_TRUE(str_const.size() == sizeof(charArray) - 1);
+ ASSERT_TRUE(str_const.is_stable());
+ ASSERT_TRUE(str.c_str() != charArray);
+ ASSERT_TRUE(str.is_stable());
+ cm::String substr = str.substr(1);
+ cm::String const& substr_const = substr;
+ ASSERT_TRUE(substr_const.data() != &charArray[1]);
+ ASSERT_TRUE(substr_const.size() == 2);
+ ASSERT_TRUE(!substr_const.is_stable());
+ ASSERT_TRUE(substr.c_str() != &charArray[1]);
+ ASSERT_TRUE(!substr.is_stable());
+ return true;
+}
+
+static bool testConstructFromCharArray()
+{
+ std::cout << "testConstructFromCharArray()\n";
+ return testFromCharArray(charArray);
+}
+
+static bool testAssignFromCharArray()
+{
+ std::cout << "testAssignFromCharArray()\n";
+ cm::String str;
+ str = charArray;
+ return testFromCharArray(str);
+}
+
+static const char* cstr = "abc";
+
+static bool testFromCStr(cm::String const& str)
+{
+ ASSERT_TRUE(str.data() != cstr);
+ ASSERT_TRUE(str.size() == 3);
+ ASSERT_TRUE(std::strncmp(str.data(), cstr, 3) == 0);
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testConstructFromCStr()
+{
+ std::cout << "testConstructFromCStr()\n";
+ return testFromCStr(cstr);
+}
+
+static bool testAssignFromCStr()
+{
+ std::cout << "testAssignFromCStr()\n";
+ cm::String str;
+ str = cstr;
+ return testFromCStr(str);
+}
+
+static const std::string stdstr = "abc";
+
+static bool testFromStdString(cm::String const& str)
+{
+#if defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI
+ // It would be nice to check this everywhere, but several platforms
+ // still use a CoW implementation even in C++11.
+ ASSERT_TRUE(str.data() != stdstr.data());
+#endif
+ ASSERT_TRUE(str.size() == 3);
+ ASSERT_TRUE(std::strncmp(str.data(), stdstr.data(), 3) == 0);
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testConstructFromStdString()
+{
+ std::cout << "testConstructFromStdString()\n";
+ return testFromStdString(stdstr);
+}
+
+static bool testAssignFromStdString()
+{
+ std::cout << "testAssignFromStdString()\n";
+ cm::String str;
+ str = stdstr;
+ return testFromStdString(str);
+}
+
+static bool testConstructFromView()
+{
+ std::cout << "testConstructFromView()\n";
+ cm::string_view view = cstr;
+ return testFromCStr(cm::String(view));
+}
+
+static bool testAssignFromView()
+{
+ std::cout << "testAssignFromView()\n";
+ cm::string_view view = cstr;
+ cm::String str;
+ str = view;
+ return testFromCStr(str);
+}
+
+static bool testFromChar(cm::String const& str)
+{
+ ASSERT_TRUE(str.size() == 1);
+ ASSERT_TRUE(std::strncmp(str.data(), "a", 1) == 0);
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testConstructFromChar()
+{
+ std::cout << "testConstructFromChar()\n";
+ return testFromChar('a');
+}
+
+static bool testAssignFromChar()
+{
+ std::cout << "testAssignFromChar()\n";
+ cm::String str;
+ str = 'a';
+ return testFromChar(str);
+}
+
+static bool testConstructFromInitList()
+{
+ std::cout << "testConstructFromInitList()\n";
+ cm::String const str{ 'a', 'b', 'c' };
+ ASSERT_TRUE(str.size() == 3);
+ ASSERT_TRUE(std::strncmp(str.data(), "abc", 3) == 0);
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testAssignFromInitList()
+{
+ std::cout << "testAssignFromInitList()\n";
+ cm::String str;
+ str = { 'a', 'b', 'c' };
+ ASSERT_TRUE(str.size() == 3);
+ ASSERT_TRUE(std::strncmp(str.data(), "abc", 3) == 0);
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testConstructFromBuffer()
+{
+ std::cout << "testConstructFromBuffer()\n";
+ cm::String const str(cstr, 3);
+ return testFromCStr(str);
+}
+
+static bool testConstructFromInputIterator()
+{
+ std::cout << "testConstructFromInputIterator()\n";
+ cm::String const str(cstr, cstr + 3);
+ ASSERT_TRUE(str.data() != cstr);
+ ASSERT_TRUE(str.size() == 3);
+ ASSERT_TRUE(std::strncmp(str.data(), cstr, 3) == 0);
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testConstructFromN()
+{
+ std::cout << "testConstructFromN()\n";
+ cm::String const str(3, 'a');
+ ASSERT_TRUE(str.size() == 3);
+ ASSERT_TRUE(std::strncmp(str.data(), "aaa", 3) == 0);
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static const auto staticStringView = "abc"_s;
+
+static bool testFromStaticStringView(cm::String str)
+{
+ cm::String const& str_const = str;
+ ASSERT_TRUE(str_const.data() == staticStringView.data());
+ ASSERT_TRUE(str_const.size() == staticStringView.size());
+ ASSERT_TRUE(!str_const.is_stable());
+ ASSERT_TRUE(str.c_str() == staticStringView);
+ ASSERT_TRUE(!str.is_stable());
+ cm::String substr = str.substr(1);
+ cm::String const& substr_const = substr;
+ ASSERT_TRUE(substr_const.data() == &staticStringView[1]);
+ ASSERT_TRUE(substr_const.size() == 2);
+ ASSERT_TRUE(!substr_const.is_stable());
+ ASSERT_TRUE(substr.c_str() == &staticStringView[1]);
+ ASSERT_TRUE(!substr.is_stable());
+ return true;
+}
+
+static bool testConstructFromStaticStringView()
+{
+ std::cout << "testConstructFromStaticStringView()\n";
+ return testFromStaticStringView(cm::String(staticStringView));
+}
+
+static bool testAssignFromStaticStringView()
+{
+ std::cout << "testAssignFromStaticStringView()\n";
+ cm::String str;
+ str = staticStringView;
+ return testFromStaticStringView(str);
+}
+
+static bool testConstructCopy()
+{
+ std::cout << "testConstructCopy()\n";
+ cm::String s1 = std::string("abc");
+ cm::String s2 = s1;
+ ASSERT_TRUE(s1.data() == s2.data());
+ ASSERT_TRUE(s1.size() == 3);
+ ASSERT_TRUE(s2.size() == 3);
+ ASSERT_TRUE(std::strncmp(s2.data(), "abc", 3) == 0);
+ ASSERT_TRUE(s1.is_stable());
+ ASSERT_TRUE(s2.is_stable());
+ return true;
+}
+
+static bool testConstructMove()
+{
+ std::cout << "testConstructMove()\n";
+ cm::String s1 = std::string("abc");
+ cm::String s2 = std::move(s1);
+ ASSERT_TRUE(s1.data() == nullptr);
+ ASSERT_TRUE(s1.size() == 0);
+ ASSERT_TRUE(s2.size() == 3);
+ ASSERT_TRUE(std::strncmp(s2.data(), "abc", 3) == 0);
+ ASSERT_TRUE(s1.is_stable());
+ ASSERT_TRUE(s2.is_stable());
+ return true;
+}
+
+static bool testAssignCopy()
+{
+ std::cout << "testAssignCopy()\n";
+ cm::String s1 = std::string("abc");
+ cm::String s2;
+ s2 = s1;
+ ASSERT_TRUE(s1.data() == s2.data());
+ ASSERT_TRUE(s1.size() == 3);
+ ASSERT_TRUE(s2.size() == 3);
+ ASSERT_TRUE(std::strncmp(s2.data(), "abc", 3) == 0);
+ ASSERT_TRUE(s1.is_stable());
+ ASSERT_TRUE(s2.is_stable());
+ return true;
+}
+
+static bool testAssignMove()
+{
+ std::cout << "testAssignMove()\n";
+ cm::String s1 = std::string("abc");
+ cm::String s2;
+ s2 = std::move(s1);
+ ASSERT_TRUE(s1.data() == nullptr);
+ ASSERT_TRUE(s1.size() == 0);
+ ASSERT_TRUE(s2.size() == 3);
+ ASSERT_TRUE(std::strncmp(s2.data(), "abc", 3) == 0);
+ ASSERT_TRUE(s1.is_stable());
+ ASSERT_TRUE(s2.is_stable());
+ return true;
+}
+
+static bool testOperatorBool()
+{
+ std::cout << "testOperatorBool()\n";
+ cm::String str;
+ ASSERT_TRUE(!str);
+ str = "";
+ ASSERT_TRUE(str);
+ str = static_cast<const char*>(nullptr);
+ ASSERT_TRUE(!str);
+ str = std::string();
+ ASSERT_TRUE(str);
+ str = nullptr;
+ ASSERT_TRUE(!str);
+ return true;
+}
+
+static bool testOperatorIndex()
+{
+ std::cout << "testOperatorIndex()\n";
+ cm::String str = "abc";
+ ASSERT_TRUE(str[0] == 'a');
+ ASSERT_TRUE(str[1] == 'b');
+ ASSERT_TRUE(str[2] == 'c');
+ return true;
+}
+
+static bool testOperatorPlusEqual()
+{
+ std::cout << "testOperatorPlusEqual()\n";
+ cm::String str = "a";
+ str += "b";
+ {
+ const char* c = "c";
+ str += c;
+ }
+ str += 'd';
+ str += std::string("e");
+ str += cm::string_view("f", 1);
+ str += cm::String("g");
+ ASSERT_TRUE(str.size() == 7);
+ ASSERT_TRUE(std::strncmp(str.data(), "abcdefg", 7) == 0);
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testOperatorCompare()
+{
+ std::cout << "testOperatorCompare()\n";
+ cm::String str = "b";
+ {
+ ASSERT_TRUE(str == "b");
+ ASSERT_TRUE("b" == str);
+ ASSERT_TRUE(str != "a");
+ ASSERT_TRUE("a" != str);
+ ASSERT_TRUE(str < "c");
+ ASSERT_TRUE("a" < str);
+ ASSERT_TRUE(str > "a");
+ ASSERT_TRUE("c" > str);
+ ASSERT_TRUE(str <= "b");
+ ASSERT_TRUE("b" <= str);
+ ASSERT_TRUE(str >= "b");
+ ASSERT_TRUE("b" >= str);
+ }
+ {
+ const char* a = "a";
+ const char* b = "b";
+ const char* c = "c";
+ ASSERT_TRUE(str == b);
+ ASSERT_TRUE(b == str);
+ ASSERT_TRUE(str != a);
+ ASSERT_TRUE(a != str);
+ ASSERT_TRUE(str < c);
+ ASSERT_TRUE(a < str);
+ ASSERT_TRUE(str > a);
+ ASSERT_TRUE(c > str);
+ ASSERT_TRUE(str <= b);
+ ASSERT_TRUE(b <= str);
+ ASSERT_TRUE(str >= b);
+ ASSERT_TRUE(b >= str);
+ }
+ {
+ ASSERT_TRUE(str == 'b');
+ ASSERT_TRUE('b' == str);
+ ASSERT_TRUE(str != 'a');
+ ASSERT_TRUE('a' != str);
+ ASSERT_TRUE(str < 'c');
+ ASSERT_TRUE('a' < str);
+ ASSERT_TRUE(str > 'a');
+ ASSERT_TRUE('c' > str);
+ ASSERT_TRUE(str <= 'b');
+ ASSERT_TRUE('b' <= str);
+ ASSERT_TRUE(str >= 'b');
+ ASSERT_TRUE('b' >= str);
+ }
+ {
+ std::string const a = "a";
+ std::string const b = "b";
+ std::string const c = "c";
+ ASSERT_TRUE(str == b);
+ ASSERT_TRUE(b == str);
+ ASSERT_TRUE(str != a);
+ ASSERT_TRUE(a != str);
+ ASSERT_TRUE(str < c);
+ ASSERT_TRUE(a < str);
+ ASSERT_TRUE(str > a);
+ ASSERT_TRUE(c > str);
+ ASSERT_TRUE(str <= b);
+ ASSERT_TRUE(b <= str);
+ ASSERT_TRUE(str >= b);
+ ASSERT_TRUE(b >= str);
+ }
+ {
+ cm::string_view const a("a", 1);
+ cm::string_view const b("b", 1);
+ cm::string_view const c("c", 1);
+ ASSERT_TRUE(str == b);
+ ASSERT_TRUE(b == str);
+ ASSERT_TRUE(str != a);
+ ASSERT_TRUE(a != str);
+ ASSERT_TRUE(str < c);
+ ASSERT_TRUE(a < str);
+ ASSERT_TRUE(str > a);
+ ASSERT_TRUE(c > str);
+ ASSERT_TRUE(str <= b);
+ ASSERT_TRUE(b <= str);
+ ASSERT_TRUE(str >= b);
+ ASSERT_TRUE(b >= str);
+ }
+ {
+ cm::String const a("a");
+ cm::String const b("b");
+ cm::String const c("c");
+ ASSERT_TRUE(str == b);
+ ASSERT_TRUE(b == str);
+ ASSERT_TRUE(str != a);
+ ASSERT_TRUE(a != str);
+ ASSERT_TRUE(str < c);
+ ASSERT_TRUE(a < str);
+ ASSERT_TRUE(str > a);
+ ASSERT_TRUE(c > str);
+ ASSERT_TRUE(str <= b);
+ ASSERT_TRUE(b <= str);
+ ASSERT_TRUE(str >= b);
+ ASSERT_TRUE(b >= str);
+ }
+ return true;
+}
+
+static bool testOperatorStream()
+{
+ std::cout << "testOperatorStream()\n";
+ std::ostringstream ss;
+ ss << "a" << cm::String("b") << 'c';
+ ASSERT_TRUE(ss.str() == "abc");
+ return true;
+}
+
+static bool testOperatorStdStringPlusEqual()
+{
+ std::cout << "testOperatorStdStringPlusEqual()\n";
+ std::string s = "a";
+ s += cm::String("b");
+ ASSERT_TRUE(s == "ab");
+ return true;
+}
+
+static bool testMethod_borrow()
+{
+ std::cout << "testMethod_borrow()\n";
+ std::string s = "abc";
+ cm::String str = cm::String::borrow(s);
+ ASSERT_TRUE(str.data() == s.data());
+ ASSERT_TRUE(str.size() == s.size());
+ ASSERT_TRUE(str == s);
+ return true;
+}
+
+static bool testMethod_view()
+{
+ std::cout << "testMethod_view()\n";
+ cm::String str;
+ ASSERT_TRUE(str.view().data() == nullptr);
+ ASSERT_TRUE(str.view().size() == 0);
+ str = charArray;
+ ASSERT_TRUE(str.view().data() != charArray);
+ ASSERT_TRUE(str.view().size() == sizeof(charArray) - 1);
+ str = std::string("abc");
+ ASSERT_TRUE(str.view().size() == 3);
+ ASSERT_TRUE(strncmp(str.view().data(), "abc", 3) == 0);
+ return true;
+}
+
+static bool testMethod_empty()
+{
+ std::cout << "testMethod_empty()\n";
+ cm::String str;
+ ASSERT_TRUE(str.empty());
+ str = "";
+ ASSERT_TRUE(str.empty());
+ str = "abc";
+ ASSERT_TRUE(!str.empty());
+ str = std::string();
+ ASSERT_TRUE(str.empty());
+ str = std::string("abc");
+ ASSERT_TRUE(!str.empty());
+ return true;
+}
+
+static bool testMethod_length()
+{
+ std::cout << "testMethod_length()\n";
+ cm::String str;
+ ASSERT_TRUE(str.length() == 0);
+ str = "";
+ ASSERT_TRUE(str.length() == 0);
+ str = "abc";
+ ASSERT_TRUE(str.length() == 3);
+ str = std::string();
+ ASSERT_TRUE(str.length() == 0);
+ str = std::string("abc");
+ ASSERT_TRUE(str.length() == 3);
+ return true;
+}
+
+static bool testMethod_at()
+{
+ std::cout << "testMethod_at()\n";
+ cm::String str = "abc";
+ ASSERT_TRUE(str.at(0) == 'a');
+ ASSERT_TRUE(str.at(1) == 'b');
+ ASSERT_TRUE(str.at(2) == 'c');
+ bool except_out_of_range = false;
+ try {
+ str.at(3);
+ } catch (std::out_of_range&) {
+ except_out_of_range = true;
+ }
+ ASSERT_TRUE(except_out_of_range);
+ return true;
+}
+
+static bool testMethod_front_back()
+{
+ std::cout << "testMethod_front_back()\n";
+ cm::String str = "abc";
+ ASSERT_TRUE(str.front() == 'a');
+ ASSERT_TRUE(str.back() == 'c');
+ return true;
+}
+
+static bool testMethodIterators()
+{
+ std::cout << "testMethodIterators()\n";
+ cm::String str = "abc";
+ ASSERT_TRUE(*str.begin() == 'a');
+ ASSERT_TRUE(*(str.end() - 1) == 'c');
+ ASSERT_TRUE(str.end() - str.begin() == 3);
+ ASSERT_TRUE(*str.cbegin() == 'a');
+ ASSERT_TRUE(*(str.cend() - 1) == 'c');
+ ASSERT_TRUE(str.cend() - str.cbegin() == 3);
+ ASSERT_TRUE(*str.rbegin() == 'c');
+ ASSERT_TRUE(*(str.rend() - 1) == 'a');
+ ASSERT_TRUE(str.rend() - str.rbegin() == 3);
+ ASSERT_TRUE(*str.crbegin() == 'c');
+ ASSERT_TRUE(*(str.crend() - 1) == 'a');
+ ASSERT_TRUE(str.crend() - str.crbegin() == 3);
+ return true;
+}
+
+static bool testMethod_clear()
+{
+ std::cout << "testMethod_clear()\n";
+ cm::String str = "abc";
+ ASSERT_TRUE(!str.empty());
+ str.clear();
+ ASSERT_TRUE(str.empty());
+ return true;
+}
+
+static bool testMethod_insert()
+{
+ std::cout << "testMethod_insert()\n";
+ cm::String str = "abc";
+ str.insert(1, 2, 'd').insert(0, 1, '_');
+ ASSERT_TRUE(str.size() == 6);
+ ASSERT_TRUE(std::strncmp(str.data(), "_addbc", 6) == 0);
+ return true;
+}
+
+static bool testMethod_erase()
+{
+ std::cout << "testMethod_erase()\n";
+ cm::String str = "abcdefg";
+ str.erase(5).erase(1, 2);
+ ASSERT_TRUE(str.size() == 3);
+ ASSERT_TRUE(std::strncmp(str.data(), "ade", 3) == 0);
+ return true;
+}
+
+static bool testMethod_push_back()
+{
+ std::cout << "testMethod_push_back()\n";
+ cm::String str = "abc";
+ str.push_back('d');
+ ASSERT_TRUE(str == "abcd");
+ return true;
+}
+
+static bool testMethod_pop_back()
+{
+ std::cout << "testMethod_pop_back()\n";
+ cm::String str = "abc";
+ str.pop_back();
+ ASSERT_TRUE(str == "ab");
+ return true;
+}
+
+static bool testMethod_replace()
+{
+ std::cout << "testMethod_replace()\n";
+ {
+ cm::String str = "abcd";
+ const char* bc = "bc";
+ ASSERT_TRUE(str.replace(1, 2, "BC") == "aBCd");
+ ASSERT_TRUE(str.replace(1, 2, bc) == "abcd");
+ ASSERT_TRUE(str.replace(1, 2, 'x') == "axd");
+ ASSERT_TRUE(str.replace(1, 1, std::string("bc")) == "abcd");
+ ASSERT_TRUE(str.replace(1, 2, cm::string_view("BC", 2)) == "aBCd");
+ ASSERT_TRUE(str.replace(1, 2, cm::String("bc")) == "abcd");
+ }
+ {
+ cm::String str = "abcd";
+ const char* bc = "bc";
+ ASSERT_TRUE(str.replace(str.begin() + 1, str.begin() + 3, "BC") == "aBCd");
+ ASSERT_TRUE(str.replace(str.begin() + 1, str.begin() + 3, bc) == "abcd");
+ ASSERT_TRUE(str.replace(str.begin() + 1, str.begin() + 3, 'x') == "axd");
+ ASSERT_TRUE(str.replace(str.begin() + 1, str.begin() + 2,
+ std::string("bc")) == "abcd");
+ ASSERT_TRUE(str.replace(str.begin() + 1, str.begin() + 3,
+ cm::string_view("BC", 2)) == "aBCd");
+ ASSERT_TRUE(str.replace(str.begin() + 1, str.begin() + 3,
+ cm::String("bc")) == "abcd");
+ }
+ {
+ cm::String str = "abcd";
+ const char* bc = "_bc";
+ ASSERT_TRUE(str.replace(1, 2, "_BC_", 1, 2) == "aBCd");
+ ASSERT_TRUE(str.replace(1, 2, bc, 1) == "abcd");
+ ASSERT_TRUE(str.replace(1, 2, 'x', 0) == "axd");
+ ASSERT_TRUE(str.replace(1, 1, std::string("_bc_"), 1, 2) == "abcd");
+ ASSERT_TRUE(str.replace(1, 2, cm::string_view("_BC", 3), 1) == "aBCd");
+ ASSERT_TRUE(str.replace(1, 2, cm::String("_bc_"), 1, 2) == "abcd");
+ }
+ {
+ cm::String str = "abcd";
+ const char* bc = "_bc_";
+ ASSERT_TRUE(str.replace(1, 2, 2, 'x') == "axxd");
+ ASSERT_TRUE(str.replace(str.begin() + 1, str.begin() + 3, 2, 'y') ==
+ "ayyd");
+ ASSERT_TRUE(
+ str.replace(str.begin() + 1, str.begin() + 3, bc + 1, bc + 3) == "abcd");
+ }
+ return true;
+}
+
+static bool testMethod_copy()
+{
+ std::cout << "testMethod_copy()\n";
+ cm::String str = "abc";
+ char dest[2];
+ cm::String::size_type n = str.copy(dest, 2, 1);
+ ASSERT_TRUE(n == 2);
+ ASSERT_TRUE(std::strncmp(dest, "bc", 2) == 0);
+ n = str.copy(dest, 2);
+ ASSERT_TRUE(n == 2);
+ ASSERT_TRUE(std::strncmp(dest, "ab", 2) == 0);
+ return true;
+}
+
+static bool testMethod_resize()
+{
+ std::cout << "testMethod_resize()\n";
+ cm::String str = "abc";
+ str.resize(3);
+ ASSERT_TRUE(str == "abc");
+ str.resize(2);
+ ASSERT_TRUE(str == "ab");
+ str.resize(3, 'c');
+ ASSERT_TRUE(str == "abc");
+ return true;
+}
+
+static bool testMethod_swap()
+{
+ std::cout << "testMethod_swap()\n";
+ cm::String str1 = std::string("1");
+ cm::String str2 = std::string("2");
+ str1.swap(str2);
+ ASSERT_TRUE(str1 == "2");
+ ASSERT_TRUE(str2 == "1");
+ return true;
+}
+
+static bool testMethod_substr_AtEnd(cm::String str)
+{
+ cm::String substr = str.substr(1);
+ ASSERT_TRUE(substr.data() == str.data() + 1);
+ ASSERT_TRUE(substr.size() == 2);
+ ASSERT_TRUE(!substr.is_stable());
+
+ // c_str() at the end of the buffer does not internally mutate.
+ ASSERT_TRUE(std::strcmp(substr.c_str(), "bc") == 0);
+ ASSERT_TRUE(substr.c_str() == str.data() + 1);
+ ASSERT_TRUE(substr.data() == str.data() + 1);
+ ASSERT_TRUE(substr.size() == 2);
+ ASSERT_TRUE(!substr.is_stable());
+
+ // str() internally mutates.
+ ASSERT_TRUE(substr.str() == "bc");
+ ASSERT_TRUE(substr.is_stable());
+ ASSERT_TRUE(substr.data() != str.data() + 1);
+ ASSERT_TRUE(substr.size() == 2);
+ ASSERT_TRUE(substr.c_str() != str.data() + 1);
+ ASSERT_TRUE(std::strcmp(substr.c_str(), "bc") == 0);
+ return true;
+}
+
+static bool testMethod_substr_AtEndBorrowed()
+{
+ std::cout << "testMethod_substr_AtEndBorrowed()\n";
+ return testMethod_substr_AtEnd(cm::String("abc"_s));
+}
+
+static bool testMethod_substr_AtEndOwned()
+{
+ std::cout << "testMethod_substr_AtEndOwned()\n";
+ return testMethod_substr_AtEnd(std::string("abc"));
+}
+
+static bool testMethod_substr_AtStart(cm::String str)
+{
+ {
+ cm::String substr = str.substr(0, 2);
+ ASSERT_TRUE(substr.data() == str.data());
+ ASSERT_TRUE(substr.size() == 2);
+
+ // c_str() not at the end of the buffer internally mutates.
+ const char* substr_c = substr.c_str();
+ ASSERT_TRUE(std::strcmp(substr_c, "ab") == 0);
+ ASSERT_TRUE(substr_c != str.data());
+ ASSERT_TRUE(substr.data() != str.data());
+ ASSERT_TRUE(substr.size() == 2);
+ ASSERT_TRUE(substr.is_stable());
+
+ // str() does not need to internally mutate after c_str() did so
+ ASSERT_TRUE(substr.str() == "ab");
+ ASSERT_TRUE(substr.is_stable());
+ ASSERT_TRUE(substr.data() == substr_c);
+ ASSERT_TRUE(substr.size() == 2);
+ ASSERT_TRUE(substr.c_str() == substr_c);
+ }
+
+ {
+ cm::String substr = str.substr(0, 2);
+ ASSERT_TRUE(substr.data() == str.data());
+ ASSERT_TRUE(substr.size() == 2);
+ ASSERT_TRUE(!substr.is_stable());
+
+ // str() internally mutates.
+ ASSERT_TRUE(substr.str() == "ab");
+ ASSERT_TRUE(substr.is_stable());
+ ASSERT_TRUE(substr.data() != str.data());
+ ASSERT_TRUE(substr.size() == 2);
+ ASSERT_TRUE(substr.c_str() != str.data());
+
+ // c_str() does not internally after str() did so
+ const char* substr_c = substr.c_str();
+ ASSERT_TRUE(std::strcmp(substr_c, "ab") == 0);
+ ASSERT_TRUE(substr_c == substr.data());
+ ASSERT_TRUE(substr.size() == 2);
+ ASSERT_TRUE(substr.is_stable());
+ }
+
+ return true;
+}
+
+static bool testMethod_substr_AtStartBorrowed()
+{
+ std::cout << "testMethod_substr_AtStartBorrowed()\n";
+ return testMethod_substr_AtStart(cm::String("abc"_s));
+}
+
+static bool testMethod_substr_AtStartOwned()
+{
+ std::cout << "testMethod_substr_AtStartOwned()\n";
+ return testMethod_substr_AtStart(std::string("abc"));
+}
+
+static bool testMethod_compare()
+{
+ std::cout << "testMethod_compare()\n";
+ cm::String str = "b";
+ ASSERT_TRUE(str.compare("a") > 0);
+ ASSERT_TRUE(str.compare("b") == 0);
+ ASSERT_TRUE(str.compare("c") < 0);
+ {
+ const char* a = "a";
+ const char* b = "b";
+ const char* c = "c";
+ ASSERT_TRUE(str.compare(a) > 0);
+ ASSERT_TRUE(str.compare(b) == 0);
+ ASSERT_TRUE(str.compare(c) < 0);
+ }
+ ASSERT_TRUE(str.compare('a') > 0);
+ ASSERT_TRUE(str.compare('b') == 0);
+ ASSERT_TRUE(str.compare('c') < 0);
+ ASSERT_TRUE(str.compare(std::string("a")) > 0);
+ ASSERT_TRUE(str.compare(std::string("b")) == 0);
+ ASSERT_TRUE(str.compare(std::string("c")) < 0);
+ ASSERT_TRUE(str.compare(cm::string_view("a_", 1)) > 0);
+ ASSERT_TRUE(str.compare(cm::string_view("b_", 1)) == 0);
+ ASSERT_TRUE(str.compare(cm::string_view("c_", 1)) < 0);
+ ASSERT_TRUE(str.compare(cm::String("a")) > 0);
+ ASSERT_TRUE(str.compare(cm::String("b")) == 0);
+ ASSERT_TRUE(str.compare(cm::String("c")) < 0);
+ ASSERT_TRUE(str.compare(0, 1, cm::string_view("a", 1)) > 0);
+ ASSERT_TRUE(str.compare(1, 0, cm::string_view("", 0)) == 0);
+ ASSERT_TRUE(str.compare(0, 1, cm::string_view("ac", 2), 1, 1) < 0);
+ ASSERT_TRUE(str.compare(1, 0, "") == 0);
+ ASSERT_TRUE(str.compare(1, 0, "_", 0) == 0);
+ return true;
+}
+
+static bool testMethod_find()
+{
+ std::cout << "testMethod_find()\n";
+ cm::String str = "abcabc";
+ ASSERT_TRUE(str.find("a") == 0);
+ ASSERT_TRUE(str.find("a", 1) == 3);
+ {
+ const char* a = "a";
+ ASSERT_TRUE(str.find(a) == 0);
+ ASSERT_TRUE(str.find(a, 1) == 3);
+ }
+ ASSERT_TRUE(str.find('a') == 0);
+ ASSERT_TRUE(str.find('a', 1) == 3);
+ ASSERT_TRUE(str.find(std::string("a")) == 0);
+ ASSERT_TRUE(str.find(std::string("a"), 1) == 3);
+ ASSERT_TRUE(str.find(cm::string_view("a_", 1)) == 0);
+ ASSERT_TRUE(str.find(cm::string_view("a_", 1), 1) == 3);
+ ASSERT_TRUE(str.find(cm::String("a")) == 0);
+ ASSERT_TRUE(str.find(cm::String("a"), 1) == 3);
+ ASSERT_TRUE(str.find("ab_", 1, 2) == 3);
+ return true;
+}
+
+static bool testMethod_rfind()
+{
+ std::cout << "testMethod_rfind()\n";
+ cm::String str = "abcabc";
+ ASSERT_TRUE(str.rfind("a") == 3);
+ ASSERT_TRUE(str.rfind("a", 1) == 0);
+ {
+ const char* a = "a";
+ ASSERT_TRUE(str.rfind(a) == 3);
+ ASSERT_TRUE(str.rfind(a, 1) == 0);
+ }
+ ASSERT_TRUE(str.rfind('a') == 3);
+ ASSERT_TRUE(str.rfind('a', 1) == 0);
+ ASSERT_TRUE(str.rfind(std::string("a")) == 3);
+ ASSERT_TRUE(str.rfind(std::string("a"), 1) == 0);
+ ASSERT_TRUE(str.rfind(cm::string_view("a_", 1)) == 3);
+ ASSERT_TRUE(str.rfind(cm::string_view("a_", 1), 1) == 0);
+ ASSERT_TRUE(str.rfind(cm::String("a")) == 3);
+ ASSERT_TRUE(str.rfind(cm::String("a"), 1) == 0);
+ ASSERT_TRUE(str.rfind("ab_", 1, 2) == 0);
+ return true;
+}
+
+static bool testMethod_find_first_of()
+{
+ std::cout << "testMethod_find_first_of()\n";
+ cm::String str = "abcabc";
+ ASSERT_TRUE(str.find_first_of("_a") == 0);
+ ASSERT_TRUE(str.find_first_of("_a", 1) == 3);
+ {
+ const char* a = "_a";
+ ASSERT_TRUE(str.find_first_of(a) == 0);
+ ASSERT_TRUE(str.find_first_of(a, 1) == 3);
+ }
+ ASSERT_TRUE(str.find_first_of('a') == 0);
+ ASSERT_TRUE(str.find_first_of('a', 1) == 3);
+ ASSERT_TRUE(str.find_first_of(std::string("_a")) == 0);
+ ASSERT_TRUE(str.find_first_of(std::string("_a"), 1) == 3);
+ ASSERT_TRUE(str.find_first_of(cm::string_view("ba_", 1)) == 1);
+ ASSERT_TRUE(str.find_first_of(cm::string_view("ba_", 1), 2) == 4);
+ ASSERT_TRUE(str.find_first_of(cm::String("ab")) == 0);
+ ASSERT_TRUE(str.find_first_of(cm::String("ab"), 2) == 3);
+ ASSERT_TRUE(str.find_first_of("_ab", 1, 2) == 3);
+ return true;
+}
+
+static bool testMethod_find_first_not_of()
+{
+ std::cout << "testMethod_find_first_not_of()\n";
+ cm::String str = "abcabc";
+ ASSERT_TRUE(str.find_first_not_of("_a") == 1);
+ ASSERT_TRUE(str.find_first_not_of("_a", 2) == 2);
+ {
+ const char* a = "_a";
+ ASSERT_TRUE(str.find_first_not_of(a) == 1);
+ ASSERT_TRUE(str.find_first_not_of(a, 2) == 2);
+ }
+ ASSERT_TRUE(str.find_first_not_of('a') == 1);
+ ASSERT_TRUE(str.find_first_not_of('a', 2) == 2);
+ ASSERT_TRUE(str.find_first_not_of(std::string("_a")) == 1);
+ ASSERT_TRUE(str.find_first_not_of(std::string("_a"), 2) == 2);
+ ASSERT_TRUE(str.find_first_not_of(cm::string_view("ba_", 1)) == 0);
+ ASSERT_TRUE(str.find_first_not_of(cm::string_view("ba_", 1), 1) == 2);
+ ASSERT_TRUE(str.find_first_not_of(cm::String("_a")) == 1);
+ ASSERT_TRUE(str.find_first_not_of(cm::String("_a"), 2) == 2);
+ ASSERT_TRUE(str.find_first_not_of("_bca", 1, 3) == 3);
+ return true;
+}
+
+static bool testMethod_find_last_of()
+{
+ std::cout << "testMethod_find_last_of()\n";
+ cm::String str = "abcabc";
+ ASSERT_TRUE(str.find_last_of("_a") == 3);
+ ASSERT_TRUE(str.find_last_of("_a", 1) == 0);
+ {
+ const char* a = "_a";
+ ASSERT_TRUE(str.find_last_of(a) == 3);
+ ASSERT_TRUE(str.find_last_of(a, 1) == 0);
+ }
+ ASSERT_TRUE(str.find_last_of('a') == 3);
+ ASSERT_TRUE(str.find_last_of('a', 1) == 0);
+ ASSERT_TRUE(str.find_last_of(std::string("_a")) == 3);
+ ASSERT_TRUE(str.find_last_of(std::string("_a"), 1) == 0);
+ ASSERT_TRUE(str.find_last_of(cm::string_view("ba_", 1)) == 4);
+ ASSERT_TRUE(str.find_last_of(cm::string_view("ba_", 1), 2) == 1);
+ ASSERT_TRUE(str.find_last_of(cm::String("ab")) == 4);
+ ASSERT_TRUE(str.find_last_of(cm::String("ab"), 2) == 1);
+ ASSERT_TRUE(str.find_last_of("_ab", 1, 2) == 0);
+ return true;
+}
+
+static bool testMethod_find_last_not_of()
+{
+ std::cout << "testMethod_find_last_not_of()\n";
+ cm::String str = "abcabc";
+ ASSERT_TRUE(str.find_last_not_of("_a") == 5);
+ ASSERT_TRUE(str.find_last_not_of("_a", 1) == 1);
+ {
+ const char* a = "_a";
+ ASSERT_TRUE(str.find_last_not_of(a) == 5);
+ ASSERT_TRUE(str.find_last_not_of(a, 1) == 1);
+ }
+ ASSERT_TRUE(str.find_last_not_of('a') == 5);
+ ASSERT_TRUE(str.find_last_not_of('a', 1) == 1);
+ ASSERT_TRUE(str.find_last_not_of(std::string("_a")) == 5);
+ ASSERT_TRUE(str.find_last_not_of(std::string("_a"), 1) == 1);
+ ASSERT_TRUE(str.find_last_not_of(cm::string_view("cb_", 1)) == 4);
+ ASSERT_TRUE(str.find_last_not_of(cm::string_view("cb_", 1), 2) == 1);
+ ASSERT_TRUE(str.find_last_not_of(cm::String("_a")) == 5);
+ ASSERT_TRUE(str.find_last_not_of(cm::String("_a"), 1) == 1);
+ ASSERT_TRUE(str.find_last_not_of("cb_", 2, 2) == 0);
+ return true;
+}
+
+static bool testAddition()
+{
+ std::cout << "testAddition()\n";
+ {
+ ASSERT_TRUE(cm::String("a") + "b" == "ab");
+ ASSERT_TRUE("ab" == "a" + cm::String("b"));
+ ASSERT_TRUE("a" + cm::String("b") + "c" == "abc");
+ ASSERT_TRUE("abc" == "a" + cm::String("b") + "c");
+ ASSERT_TRUE("a" + (cm::String("b") + "c") + "d" == "abcd");
+ ASSERT_TRUE("abcd" == "a" + (cm::String("b") + "c") + "d");
+ }
+ {
+ ASSERT_TRUE(cm::String("a"_s) + "b"_s == "ab"_s);
+ ASSERT_TRUE("ab"_s == "a"_s + cm::String("b"_s));
+ ASSERT_TRUE("a"_s + cm::String("b"_s) + "c"_s == "abc"_s);
+ ASSERT_TRUE("abc"_s == "a"_s + cm::String("b"_s) + "c"_s);
+ ASSERT_TRUE("a"_s + (cm::String("b"_s) + "c"_s) + "d"_s == "abcd"_s);
+ ASSERT_TRUE("abcd"_s == "a"_s + (cm::String("b"_s) + "c"_s) + "d"_s);
+ }
+ {
+ const char* a = "a";
+ const char* b = "b";
+ const char* ab = "ab";
+ ASSERT_TRUE(cm::String(a) + b == ab);
+ ASSERT_TRUE(ab == a + cm::String(b));
+ const char* c = "c";
+ const char* abc = "abc";
+ ASSERT_TRUE(a + cm::String(b) + c == abc);
+ ASSERT_TRUE(abc == a + cm::String(b) + c);
+ const char* d = "d";
+ const char* abcd = "abcd";
+ ASSERT_TRUE(a + (cm::String(b) + c) + d == abcd);
+ ASSERT_TRUE(abcd == a + (cm::String(b) + c) + d);
+ }
+ {
+ ASSERT_TRUE(cm::String('a') + 'b' == "ab");
+ ASSERT_TRUE("ab" == 'a' + cm::String('b'));
+ ASSERT_TRUE('a' + cm::String('b') + 'c' == "abc");
+ ASSERT_TRUE("abc" == 'a' + cm::String('b') + 'c');
+ ASSERT_TRUE('a' + (cm::String('b') + 'c') + 'd' == "abcd");
+ ASSERT_TRUE("abcd" == 'a' + (cm::String('b') + 'c') + 'd');
+ }
+ {
+ std::string a = "a";
+ std::string b = "b";
+ std::string ab = "ab";
+ ASSERT_TRUE(cm::String(a) + b == ab);
+ ASSERT_TRUE(ab == a + cm::String(b));
+ std::string c = "c";
+ std::string abc = "abc";
+ ASSERT_TRUE(a + cm::String(b) + c == abc);
+ ASSERT_TRUE(abc == a + cm::String(b) + c);
+ std::string d = "d";
+ std::string abcd = "abcd";
+ ASSERT_TRUE(a + (cm::String(b) + c) + d == abcd);
+ ASSERT_TRUE(abcd == a + (cm::String(b) + c) + d);
+ }
+ {
+ cm::string_view a("a", 1);
+ cm::string_view b("b", 1);
+ cm::string_view ab("ab", 2);
+ ASSERT_TRUE(cm::String(a) + b == ab);
+ ASSERT_TRUE(ab == a + cm::String(b));
+ cm::string_view c("c", 1);
+ cm::string_view abc("abc", 3);
+ ASSERT_TRUE(a + cm::String(b) + c == abc);
+ ASSERT_TRUE(abc == a + cm::String(b) + c);
+ cm::string_view d("d", 1);
+ cm::string_view abcd("abcd", 4);
+ ASSERT_TRUE(a + (cm::String(b) + c) + d == abcd);
+ ASSERT_TRUE(abcd == a + (cm::String(b) + c) + d);
+ }
+ {
+ cm::String a = "a";
+ cm::String b = "b";
+ cm::String ab = "ab";
+ ASSERT_TRUE(a + b == ab);
+ ASSERT_TRUE(ab == a + b);
+ cm::String c = "c";
+ cm::String abc = "abc";
+ ASSERT_TRUE(a + cm::String(b) + c == abc);
+ ASSERT_TRUE(abc == a + cm::String(b) + c);
+ cm::String d = "d";
+ cm::String abcd = "abcd";
+ ASSERT_TRUE(a + (cm::String(b) + c) + d == abcd);
+ ASSERT_TRUE(abcd == a + (cm::String(b) + c) + d);
+ }
+ {
+ cm::String str;
+ str += "a" + cm::String("b") + 'c';
+ ASSERT_TRUE(str == "abc");
+ ASSERT_TRUE(str.is_stable());
+ }
+ {
+ std::string s;
+ s += "a" + cm::String("b") + 'c';
+ ASSERT_TRUE(s == "abc");
+ }
+ {
+ std::ostringstream ss;
+ ss << ("a" + cm::String("b") + 'c');
+ ASSERT_TRUE(ss.str() == "abc");
+ }
+ return true;
+}
+
+static bool testStability()
+{
+ std::cout << "testStability()\n";
+ cm::String str("abc"_s);
+ ASSERT_TRUE(!str.is_stable());
+ ASSERT_TRUE(str.str_if_stable() == nullptr);
+ str.stabilize();
+ ASSERT_TRUE(str.is_stable());
+ std::string const* str_if_stable = str.str_if_stable();
+ ASSERT_TRUE(str_if_stable != nullptr);
+ ASSERT_TRUE(*str_if_stable == "abc");
+ str.stabilize();
+ ASSERT_TRUE(str.is_stable());
+ ASSERT_TRUE(str.str_if_stable() == str_if_stable);
+ return true;
+}
+
+int testString(int /*unused*/, char* /*unused*/ [])
+{
+ if (!testConstructDefault()) {
+ return 1;
+ }
+ if (!testConstructFromNullPtr()) {
+ return 1;
+ }
+ if (!testConstructFromCStrNull()) {
+ return 1;
+ }
+ if (!testConstructFromCharArray()) {
+ return 1;
+ }
+ if (!testConstructFromCStr()) {
+ return 1;
+ }
+ if (!testConstructFromStdString()) {
+ return 1;
+ }
+ if (!testConstructFromView()) {
+ return 1;
+ }
+ if (!testConstructFromChar()) {
+ return 1;
+ }
+ if (!testConstructFromInitList()) {
+ return 1;
+ }
+ if (!testConstructFromBuffer()) {
+ return 1;
+ }
+ if (!testConstructFromInputIterator()) {
+ return 1;
+ }
+ if (!testConstructFromN()) {
+ return 1;
+ }
+ if (!testConstructFromStaticStringView()) {
+ return 1;
+ }
+ if (!testConstructCopy()) {
+ return 1;
+ }
+ if (!testConstructMove()) {
+ return 1;
+ }
+ if (!testAssignCopy()) {
+ return 1;
+ }
+ if (!testAssignMove()) {
+ return 1;
+ }
+ if (!testAssignFromChar()) {
+ return 1;
+ }
+ if (!testAssignFromView()) {
+ return 1;
+ }
+ if (!testAssignFromStdString()) {
+ return 1;
+ }
+ if (!testAssignFromCStr()) {
+ return 1;
+ }
+ if (!testAssignFromCharArray()) {
+ return 1;
+ }
+ if (!testAssignFromCStrNull()) {
+ return 1;
+ }
+ if (!testAssignFromNullPtr()) {
+ return 1;
+ }
+ if (!testAssignFromInitList()) {
+ return 1;
+ }
+ if (!testAssignFromStaticStringView()) {
+ return 1;
+ }
+ if (!testOperatorBool()) {
+ return 1;
+ }
+ if (!testOperatorIndex()) {
+ return 1;
+ }
+ if (!testOperatorPlusEqual()) {
+ return 1;
+ }
+ if (!testOperatorCompare()) {
+ return 1;
+ }
+ if (!testOperatorStream()) {
+ return 1;
+ }
+ if (!testOperatorStdStringPlusEqual()) {
+ return 1;
+ }
+ if (!testMethod_borrow()) {
+ return 1;
+ }
+ if (!testMethod_view()) {
+ return 1;
+ }
+ if (!testMethod_empty()) {
+ return 1;
+ }
+ if (!testMethod_length()) {
+ return 1;
+ }
+ if (!testMethod_at()) {
+ return 1;
+ }
+ if (!testMethod_front_back()) {
+ return 1;
+ }
+ if (!testMethod_clear()) {
+ return 1;
+ }
+ if (!testMethod_insert()) {
+ return 1;
+ }
+ if (!testMethod_erase()) {
+ return 1;
+ }
+ if (!testMethod_push_back()) {
+ return 1;
+ }
+ if (!testMethod_pop_back()) {
+ return 1;
+ }
+ if (!testMethod_replace()) {
+ return 1;
+ }
+ if (!testMethod_copy()) {
+ return 1;
+ }
+ if (!testMethod_resize()) {
+ return 1;
+ }
+ if (!testMethod_swap()) {
+ return 1;
+ }
+ if (!testMethodIterators()) {
+ return 1;
+ }
+ if (!testMethod_substr_AtEndBorrowed()) {
+ return 1;
+ }
+ if (!testMethod_substr_AtEndOwned()) {
+ return 1;
+ }
+ if (!testMethod_substr_AtStartBorrowed()) {
+ return 1;
+ }
+ if (!testMethod_substr_AtStartOwned()) {
+ return 1;
+ }
+ if (!testMethod_compare()) {
+ return 1;
+ }
+ if (!testMethod_find()) {
+ return 1;
+ }
+ if (!testMethod_rfind()) {
+ return 1;
+ }
+ if (!testMethod_find_first_of()) {
+ return 1;
+ }
+ if (!testMethod_find_first_not_of()) {
+ return 1;
+ }
+ if (!testMethod_find_last_of()) {
+ return 1;
+ }
+ if (!testMethod_find_last_not_of()) {
+ return 1;
+ }
+ if (!testAddition()) {
+ return 1;
+ }
+ if (!testStability()) {
+ return 1;
+ }
+ return 0;
+}
diff --git a/Tests/CMakeLib/testStringAlgorithms.cxx b/Tests/CMakeLib/testStringAlgorithms.cxx
new file mode 100644
index 0000000..63826cf
--- /dev/null
+++ b/Tests/CMakeLib/testStringAlgorithms.cxx
@@ -0,0 +1,230 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include <cmConfigure.h> // IWYU pragma: keep
+
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include <cm/string_view>
+
+#include "cmStringAlgorithms.h"
+
+int testStringAlgorithms(int /*unused*/, char* /*unused*/ [])
+{
+ int failed = 0;
+
+ auto assert_ok = [&failed](bool test, cm::string_view title) {
+ if (test) {
+ std::cout << "Passed: " << title << "\n";
+ } else {
+ std::cout << "Failed: " << title << "\n";
+ ++failed;
+ }
+ };
+
+ auto assert_string = [&failed](cm::string_view generated,
+ cm::string_view expected,
+ cm::string_view title) {
+ if (generated == expected) {
+ std::cout << "Passed: " << title << "\n";
+ } else {
+ std::cout << "Failed: " << title << "\n";
+ std::cout << "Expected: " << expected << "\n";
+ std::cout << "Got: " << generated << "\n";
+ ++failed;
+ }
+ };
+
+ // ----------------------------------------------------------------------
+ // Test cmTrimWhitespace
+ {
+ std::string base = "base";
+ std::string spaces = " \f\f\n\n\r\r\t\t\v\v";
+ assert_string(cmTrimWhitespace(spaces + base), base,
+ "cmTrimWhitespace front");
+ assert_string(cmTrimWhitespace(base + spaces), base,
+ "cmTrimWhitespace back");
+ assert_string(cmTrimWhitespace(spaces + base + spaces), base,
+ "cmTrimWhitespace front and back");
+ }
+
+ // ----------------------------------------------------------------------
+ // Test cmRemoveQuotes
+ {
+ auto test = [&assert_string](cm::string_view source,
+ cm::string_view expected,
+ cm::string_view title) {
+ assert_string(cmRemoveQuotes(source), expected, title);
+ };
+
+ test("", "", "cmRemoveQuotes empty");
+ test("\"", "\"", "cmRemoveQuotes single quote");
+ test("\"\"", "", "cmRemoveQuotes double quote");
+ test("\"a", "\"a", "cmRemoveQuotes quote char");
+ test("\"ab", "\"ab", "cmRemoveQuotes quote char char");
+ test("a\"", "a\"", "cmRemoveQuotes char quote");
+ test("ab\"", "ab\"", "cmRemoveQuotes char char quote");
+ test("a", "a", "cmRemoveQuotes single char");
+ test("ab", "ab", "cmRemoveQuotes two chars");
+ test("abc", "abc", "cmRemoveQuotes three chars");
+ test("\"abc\"", "abc", "cmRemoveQuotes quoted chars");
+ test("\"\"abc\"\"", "\"abc\"", "cmRemoveQuotes quoted quoted chars");
+ }
+
+ // ----------------------------------------------------------------------
+ // Test cmEscapeQuotes
+ {
+ assert_string(cmEscapeQuotes("plain"), "plain", "cmEscapeQuotes plain");
+ std::string base = "\"base\"\"";
+ std::string result = "\\\"base\\\"\\\"";
+ assert_string(cmEscapeQuotes(base), result, "cmEscapeQuotes escaped");
+ }
+
+ // ----------------------------------------------------------------------
+ // Test cmJoin
+ {
+ typedef std::string ST;
+ typedef std::vector<std::string> VT;
+ assert_string(cmJoin(ST("abc"), ";"), "a;b;c", "cmJoin std::string");
+ assert_string(cmJoin(VT{}, ";"), "", "cmJoin std::vector empty");
+ assert_string(cmJoin(VT{ "a" }, ";"), "a", "cmJoin std::vector single");
+ assert_string(cmJoin(VT{ "a", "b", "c" }, ";"), "a;b;c",
+ "cmJoin std::vector multiple");
+ assert_string(cmJoin(VT{ "a", "b", "c" }, "<=>"), "a<=>b<=>c",
+ "cmJoin std::vector long sep");
+ }
+
+ // ----------------------------------------------------------------------
+ // Test cmTokenize
+ {
+ typedef std::vector<std::string> VT;
+ assert_ok(cmTokenize("", ";") == VT{ "" }, "cmTokenize empty");
+ assert_ok(cmTokenize(";", ";") == VT{ "" }, "cmTokenize sep");
+ assert_ok(cmTokenize("abc", ";") == VT{ "abc" }, "cmTokenize item");
+ assert_ok(cmTokenize("abc;", ";") == VT{ "abc" }, "cmTokenize item sep");
+ assert_ok(cmTokenize(";abc", ";") == VT{ "abc" }, "cmTokenize sep item");
+ assert_ok(cmTokenize("abc;;efg", ";") == VT{ "abc", "efg" },
+ "cmTokenize item sep sep item");
+ assert_ok(cmTokenize("a1;a2;a3;a4", ";") == VT{ "a1", "a2", "a3", "a4" },
+ "cmTokenize multiple items");
+ }
+
+ // ----------------------------------------------------------------------
+ // Test cmStrCat
+ {
+ int ni = -1100;
+ unsigned int nui = 1100u;
+ long int nli = -12000l;
+ unsigned long int nuli = 12000ul;
+ long long int nlli = -130000ll;
+ unsigned long long int nulli = 130000ull;
+ std::string val =
+ cmStrCat("<test>", ni, ',', nui, ',', nli, ",", nuli, ", ", nlli,
+ std::string(", "), nulli, cm::string_view("</test>"));
+ std::string expect =
+ "<test>-1100,1100,-12000,12000, -130000, 130000</test>";
+ assert_string(val, expect, "cmStrCat strings and integers");
+ }
+ {
+ float const val = 1.5f;
+ float const div = 0.00001f;
+ float f = 0.0f;
+ std::istringstream(cmStrCat("", val)) >> f;
+ f -= val;
+ assert_ok((f < div) && (f > -div), "cmStrCat float");
+ }
+ {
+ double const val = 1.5;
+ double const div = 0.00001;
+ double d = 0.0;
+ std::istringstream(cmStrCat("", val)) >> d;
+ d -= val;
+ assert_ok((d < div) && (d > -div), "cmStrCat double");
+ }
+
+ // ----------------------------------------------------------------------
+ // Test cmWrap
+ {
+ typedef std::vector<std::string> VT;
+ assert_string(cmWrap("<", VT{}, ">", "; "), //
+ "", //
+ "cmWrap empty, string prefix and suffix");
+ assert_string(cmWrap("<", VT{ "abc" }, ">", "; "), //
+ "<abc>", //
+ "cmWrap single, string prefix and suffix");
+ assert_string(cmWrap("<", VT{ "a1", "a2", "a3" }, ">", "; "), //
+ "<a1>; <a2>; <a3>", //
+ "cmWrap multiple, string prefix and suffix");
+
+ assert_string(cmWrap('<', VT{}, '>', "; "), //
+ "", //
+ "cmWrap empty, char prefix and suffix");
+ assert_string(cmWrap('<', VT{ "abc" }, '>', "; "), //
+ "<abc>", //
+ "cmWrap single, char prefix and suffix");
+ assert_string(cmWrap('<', VT{ "a1", "a2", "a3" }, '>', "; "), //
+ "<a1>; <a2>; <a3>", //
+ "cmWrap multiple, char prefix and suffix");
+ }
+
+ // ----------------------------------------------------------------------
+ // Test cmHas(Literal)Prefix and cmHas(Literal)Suffix
+ {
+ std::string str("abc");
+ assert_ok(cmHasPrefix(str, 'a'), "cmHasPrefix char");
+ assert_ok(!cmHasPrefix(str, 'c'), "cmHasPrefix char not");
+ assert_ok(cmHasPrefix(str, "ab"), "cmHasPrefix string");
+ assert_ok(!cmHasPrefix(str, "bc"), "cmHasPrefix string not");
+ assert_ok(cmHasPrefix(str, str), "cmHasPrefix complete string");
+ assert_ok(cmHasLiteralPrefix(str, "ab"), "cmHasLiteralPrefix string");
+ assert_ok(!cmHasLiteralPrefix(str, "bc"), "cmHasLiteralPrefix string not");
+
+ assert_ok(cmHasSuffix(str, 'c'), "cmHasSuffix char");
+ assert_ok(!cmHasSuffix(str, 'a'), "cmHasSuffix char not");
+ assert_ok(cmHasSuffix(str, "bc"), "cmHasSuffix string");
+ assert_ok(!cmHasSuffix(str, "ab"), "cmHasSuffix string not");
+ assert_ok(cmHasSuffix(str, str), "cmHasSuffix complete string");
+ assert_ok(cmHasLiteralSuffix(str, "bc"), "cmHasLiteralSuffix string");
+ assert_ok(!cmHasLiteralSuffix(str, "ab"), "cmHasLiteralPrefix string not");
+ }
+
+ // ----------------------------------------------------------------------
+ // Test cmStrToLong
+ {
+ long value;
+ assert_ok(cmStrToLong("1", &value) && value == 1,
+ "cmStrToLong parses a positive decimal integer.");
+ assert_ok(cmStrToLong(" 1", &value) && value == 1,
+ "cmStrToLong parses a decimal integer after whitespace.");
+
+ assert_ok(cmStrToLong("-1", &value) && value == -1,
+ "cmStrToLong parses a negative decimal integer.");
+ assert_ok(
+ cmStrToLong(" -1", &value) && value == -1,
+ "cmStrToLong parses a negative decimal integer after whitespace.");
+
+ assert_ok(!cmStrToLong("1x", &value),
+ "cmStrToLong rejects trailing content.");
+ }
+
+ // ----------------------------------------------------------------------
+ // Test cmStrToULong
+ {
+ unsigned long value;
+ assert_ok(cmStrToULong("1", &value) && value == 1,
+ "cmStrToULong parses a decimal integer.");
+ assert_ok(cmStrToULong(" 1", &value) && value == 1,
+ "cmStrToULong parses a decimal integer after whitespace.");
+ assert_ok(!cmStrToULong("-1", &value),
+ "cmStrToULong rejects a negative number.");
+ assert_ok(!cmStrToULong(" -1", &value),
+ "cmStrToULong rejects a negative number after whitespace.");
+ assert_ok(!cmStrToULong("1x", &value),
+ "cmStrToULong rejects trailing content.");
+ }
+
+ return failed;
+}
diff --git a/Tests/CMakeLib/testSystemTools.cxx b/Tests/CMakeLib/testSystemTools.cxx
new file mode 100644
index 0000000..92f5275
--- /dev/null
+++ b/Tests/CMakeLib/testSystemTools.cxx
@@ -0,0 +1,99 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include <cmConfigure.h> // IWYU pragma: keep
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include <stddef.h>
+
+#include "cmSystemTools.h"
+
+#define cmPassed(m) std::cout << "Passed: " << (m) << "\n"
+#define cmFailed(m) \
+ std::cout << "FAILED: " << (m) << "\n"; \
+ failed = 1
+
+#define cmAssert(exp, m) \
+ do { \
+ if ((exp)) { \
+ cmPassed(m); \
+ } else { \
+ cmFailed(m); \
+ } \
+ } while (false)
+
+int testSystemTools(int /*unused*/, char* /*unused*/ [])
+{
+ int failed = 0;
+ // ----------------------------------------------------------------------
+ // Test cmSystemTools::UpperCase
+ std::string str = "abc";
+ std::string strupper = "ABC";
+ cmAssert(cmSystemTools::UpperCase(str) == strupper,
+ "cmSystemTools::UpperCase");
+
+ // ----------------------------------------------------------------------
+ // Test cmSystemTools::strverscmp
+ cmAssert(cmSystemTools::strverscmp("", "") == 0, "strverscmp empty string");
+ cmAssert(cmSystemTools::strverscmp("abc", "") > 0,
+ "strverscmp string vs empty string");
+ cmAssert(cmSystemTools::strverscmp("abc", "abc") == 0,
+ "strverscmp same string");
+ cmAssert(cmSystemTools::strverscmp("abd", "abc") > 0,
+ "strverscmp character string");
+ cmAssert(cmSystemTools::strverscmp("abc", "abd") < 0,
+ "strverscmp symmetric");
+ cmAssert(cmSystemTools::strverscmp("12345", "12344") > 0,
+ "strverscmp natural numbers");
+ cmAssert(cmSystemTools::strverscmp("100", "99") > 0,
+ "strverscmp natural numbers different digits");
+ cmAssert(cmSystemTools::strverscmp("12345", "00345") > 0,
+ "strverscmp natural against decimal (same length)");
+ cmAssert(cmSystemTools::strverscmp("99999999999999", "99999999999991") > 0,
+ "strverscmp natural overflow");
+ cmAssert(cmSystemTools::strverscmp("00000000000009", "00000000000001") > 0,
+ "strverscmp decimal precision");
+ cmAssert(cmSystemTools::strverscmp("a.b.c.0", "a.b.c.000") > 0,
+ "strverscmp multiple zeros");
+ cmAssert(cmSystemTools::strverscmp("lib_1.2_10", "lib_1.2_2") > 0,
+ "strverscmp last number ");
+ cmAssert(cmSystemTools::strverscmp("12lib", "2lib") > 0,
+ "strverscmp first number ");
+ cmAssert(cmSystemTools::strverscmp("02lib", "002lib") > 0,
+ "strverscmp first number decimal ");
+ cmAssert(cmSystemTools::strverscmp("10", "9a") > 0,
+ "strverscmp letter filler ");
+ cmAssert(cmSystemTools::strverscmp("000", "0001") > 0,
+ "strverscmp zero and leading zeros ");
+
+ // test sorting using standard strvercmp input
+ std::vector<std::string> testString;
+ testString.push_back("000");
+ testString.push_back("00");
+ testString.push_back("01");
+ testString.push_back("010");
+ testString.push_back("09");
+ testString.push_back("0");
+ testString.push_back("1");
+ testString.push_back("9");
+ testString.push_back("10");
+
+ // test global ordering of input strings
+ for (size_t i = 0; i < testString.size() - 1; i++) {
+ for (size_t j = i + 1; j < testString.size(); j++) {
+ if (cmSystemTools::strverscmp(testString[i], testString[j]) >= 0) {
+ cmFailed("cmSystemTools::strverscmp error in comparing strings " +
+ testString[i] + " " + testString[j]);
+ }
+ }
+ }
+
+ if (!failed) {
+ cmPassed("cmSystemTools::strverscmp working");
+ }
+
+ return failed;
+}
diff --git a/Tests/CMakeLib/testUTF8.cxx b/Tests/CMakeLib/testUTF8.cxx
new file mode 100644
index 0000000..1bf88cf
--- /dev/null
+++ b/Tests/CMakeLib/testUTF8.cxx
@@ -0,0 +1,197 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include <stdio.h>
+
+#include <cm_utf8.h>
+
+typedef char test_utf8_char[5];
+
+static void test_utf8_char_print(test_utf8_char const c)
+{
+ unsigned char const* d = reinterpret_cast<unsigned char const*>(c);
+#ifndef __clang_analyzer__ // somehow thinks arguments are not initialized
+ printf("[0x%02X,0x%02X,0x%02X,0x%02X]", static_cast<int>(d[0]),
+ static_cast<int>(d[1]), static_cast<int>(d[2]),
+ static_cast<int>(d[3]));
+#endif
+}
+
+static void byte_array_print(char const* s)
+{
+ unsigned char const* d = reinterpret_cast<unsigned char const*>(s);
+ bool started = false;
+ printf("[");
+ for (; *d; ++d) {
+ if (started) {
+ printf(",");
+ }
+ started = true;
+ printf("0x%02X", static_cast<int>(*d));
+ }
+ printf("]");
+}
+
+struct test_utf8_entry
+{
+ int n;
+ test_utf8_char str;
+ unsigned int chr;
+};
+
+static test_utf8_entry const good_entry[] = {
+ { 1, "\x20\x00\x00\x00", 0x0020 }, /* Space. */
+ { 2, "\xC2\xA9\x00\x00", 0x00A9 }, /* Copyright. */
+ { 3, "\xE2\x80\x98\x00", 0x2018 }, /* Open-single-quote. */
+ { 3, "\xE2\x80\x99\x00", 0x2019 }, /* Close-single-quote. */
+ { 4, "\xF0\xA3\x8E\xB4", 0x233B4 }, /* Example from RFC 3629. */
+ { 3, "\xED\x80\x80\x00", 0xD000 }, /* Valid 0xED prefixed codepoint. */
+ { 4, "\xF4\x8F\xBF\xBF", 0x10FFFF }, /* Highest valid RFC codepoint. */
+ { 0, { 0, 0, 0, 0, 0 }, 0 }
+};
+
+static test_utf8_char const bad_chars[] = {
+ "\x80\x00\x00\x00", /* Leading continuation byte. */
+ "\xC0\x80\x00\x00", /* Overlong encoding. */
+ "\xC1\x80\x00\x00", /* Overlong encoding. */
+ "\xC2\x00\x00\x00", /* Missing continuation byte. */
+ "\xE0\x00\x00\x00", /* Missing continuation bytes. */
+ "\xE0\x80\x80\x00", /* Overlong encoding. */
+ "\xF0\x80\x80\x80", /* Overlong encoding. */
+ "\xED\xA0\x80\x00", /* UTF-16 surrogate half. */
+ "\xED\xBF\xBF\x00", /* UTF-16 surrogate half. */
+ "\xF4\x90\x80\x80", /* Lowest out-of-range codepoint. */
+ "\xF5\x80\x80\x80", /* Prefix forces out-of-range codepoints. */
+ { 0, 0, 0, 0, 0 }
+};
+
+static char const* good_strings[] = { "", "ASCII", "\xC2\xA9 Kitware", 0 };
+
+static char const* bad_strings[] = {
+ "\xC0\x80", /* Modified UTF-8 for embedded 0-byte. */
+ 0
+};
+
+static void report_good(bool passed, test_utf8_char const c)
+{
+ printf("%s: decoding good ", passed ? "pass" : "FAIL");
+ test_utf8_char_print(c);
+ printf(" (%s) ", c);
+}
+
+static void report_bad(bool passed, test_utf8_char const c)
+{
+ printf("%s: decoding bad ", passed ? "pass" : "FAIL");
+ test_utf8_char_print(c);
+ printf(" ");
+}
+
+static bool decode_good(test_utf8_entry const entry)
+{
+ unsigned int uc;
+ if (const char* e =
+ cm_utf8_decode_character(entry.str, entry.str + 4, &uc)) {
+ int used = static_cast<int>(e - entry.str);
+ if (uc != entry.chr) {
+ report_good(false, entry.str);
+ printf("expected 0x%04X, got 0x%04X\n", entry.chr, uc);
+ return false;
+ }
+ if (used != entry.n) {
+ report_good(false, entry.str);
+ printf("had %d bytes, used %d\n", entry.n, used);
+ return false;
+ }
+ report_good(true, entry.str);
+ printf("got 0x%04X\n", uc);
+ return true;
+ }
+ report_good(false, entry.str);
+ printf("failed\n");
+ return false;
+}
+
+static bool decode_bad(test_utf8_char const s)
+{
+ unsigned int uc = 0xFFFFu;
+ const char* e = cm_utf8_decode_character(s, s + 4, &uc);
+ if (e) {
+ report_bad(false, s);
+ printf("expected failure, got 0x%04X\n", uc);
+ return false;
+ }
+ report_bad(true, s);
+ printf("failed as expected\n");
+ return true;
+}
+
+static void report_valid(bool passed, char const* s)
+{
+ printf("%s: validity good ", passed ? "pass" : "FAIL");
+ byte_array_print(s);
+ printf(" (%s) ", s);
+}
+
+static void report_invalid(bool passed, char const* s)
+{
+ printf("%s: validity bad ", passed ? "pass" : "FAIL");
+ byte_array_print(s);
+ printf(" ");
+}
+
+static bool is_valid(const char* s)
+{
+ bool valid = cm_utf8_is_valid(s) != 0;
+ if (!valid) {
+ report_valid(false, s);
+ printf("expected valid, reported as invalid\n");
+ return false;
+ }
+ report_valid(true, s);
+ printf("valid as expected\n");
+ return true;
+}
+
+static bool is_invalid(const char* s)
+{
+ bool valid = cm_utf8_is_valid(s) != 0;
+ if (valid) {
+ report_invalid(false, s);
+ printf("expected invalid, reported as valid\n");
+ return false;
+ }
+ report_invalid(true, s);
+ printf("invalid as expected\n");
+ return true;
+}
+
+int testUTF8(int /*unused*/, char* /*unused*/ [])
+{
+ int result = 0;
+ for (test_utf8_entry const* e = good_entry; e->n; ++e) {
+ if (!decode_good(*e)) {
+ result = 1;
+ }
+ if (!is_valid(e->str)) {
+ result = 1;
+ }
+ }
+ for (test_utf8_char const* c = bad_chars; (*c)[0]; ++c) {
+ if (!decode_bad(*c)) {
+ result = 1;
+ }
+ if (!is_invalid(*c)) {
+ result = 1;
+ }
+ }
+ for (char const** s = good_strings; *s; ++s) {
+ if (!is_valid(*s)) {
+ result = 1;
+ }
+ }
+ for (char const** s = bad_strings; *s; ++s) {
+ if (!is_invalid(*s)) {
+ result = 1;
+ }
+ }
+ return result;
+}
diff --git a/Tests/CMakeLib/testUVProcessChain.cxx b/Tests/CMakeLib/testUVProcessChain.cxx
new file mode 100644
index 0000000..71a1764
--- /dev/null
+++ b/Tests/CMakeLib/testUVProcessChain.cxx
@@ -0,0 +1,334 @@
+#include <algorithm>
+#include <csignal>
+#include <functional>
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include <cm/memory>
+
+#include "cm_uv.h"
+
+#include "cmGetPipes.h"
+#include "cmUVHandlePtr.h"
+#include "cmUVProcessChain.h"
+#include "cmUVStreambuf.h"
+
+struct ExpectedStatus
+{
+ bool Finished;
+ bool MatchExitStatus;
+ bool MatchTermSignal;
+ cmUVProcessChain::Status Status;
+};
+
+static const std::vector<ExpectedStatus> status1 = {
+ { false, false, false, { 0, 0 } },
+ { false, false, false, { 0, 0 } },
+ { false, false, false, { 0, 0 } },
+};
+
+static const std::vector<ExpectedStatus> status2 = {
+ { true, true, true, { 0, 0 } },
+ { false, false, false, { 0, 0 } },
+ { false, false, false, { 0, 0 } },
+};
+
+static const std::vector<ExpectedStatus> status3 = {
+ { true, true, true, { 0, 0 } },
+ { true, true, true, { 1, 0 } },
+#ifdef _WIN32
+ { true, true, true, { 2, 0 } },
+#else
+ { true, false, true, { 0, SIGABRT } },
+#endif
+};
+
+bool operator==(const cmUVProcessChain::Status* actual,
+ const ExpectedStatus& expected)
+{
+ if (!expected.Finished) {
+ return !actual;
+ } else if (!actual) {
+ return false;
+ }
+ if (expected.MatchExitStatus &&
+ expected.Status.ExitStatus != actual->ExitStatus) {
+ return false;
+ }
+ if (expected.MatchTermSignal &&
+ expected.Status.TermSignal != actual->TermSignal) {
+ return false;
+ }
+ return true;
+}
+
+bool resultsMatch(const std::vector<const cmUVProcessChain::Status*>& actual,
+ const std::vector<ExpectedStatus>& expected)
+{
+ return actual.size() == expected.size() &&
+ std::equal(actual.begin(), actual.end(), expected.begin());
+}
+
+std::string getInput(std::istream& input)
+{
+ char buffer[1024];
+ std::ostringstream str;
+ do {
+ input.read(buffer, 1024);
+ str.write(buffer, input.gcount());
+ } while (input.gcount() > 0);
+ return str.str();
+}
+
+template <typename T>
+std::function<std::ostream&(std::ostream&)> printExpected(bool match,
+ const T& value)
+{
+ return [match, value](std::ostream& stream) -> std::ostream& {
+ if (match) {
+ stream << value;
+ } else {
+ stream << "*";
+ }
+ return stream;
+ };
+}
+
+std::ostream& operator<<(
+ std::ostream& stream,
+ const std::function<std::ostream&(std::ostream&)>& func)
+{
+ return func(stream);
+}
+
+void printResults(const std::vector<const cmUVProcessChain::Status*>& actual,
+ const std::vector<ExpectedStatus>& expected)
+{
+ std::cout << "Expected: " << std::endl;
+ for (auto const& e : expected) {
+ if (e.Finished) {
+ std::cout << " ExitStatus: "
+ << printExpected(e.MatchExitStatus, e.Status.ExitStatus)
+ << ", TermSignal: "
+ << printExpected(e.MatchTermSignal, e.Status.TermSignal)
+ << std::endl;
+ } else {
+ std::cout << " null" << std::endl;
+ }
+ }
+ std::cout << "Actual:" << std::endl;
+ for (auto const& a : actual) {
+ if (a) {
+ std::cout << " ExitStatus: " << a->ExitStatus
+ << ", TermSignal: " << a->TermSignal << std::endl;
+ } else {
+ std::cout << " null" << std::endl;
+ }
+ }
+}
+
+bool checkExecution(cmUVProcessChainBuilder& builder,
+ std::unique_ptr<cmUVProcessChain>& chain)
+{
+ std::vector<const cmUVProcessChain::Status*> status;
+
+ chain = cm::make_unique<cmUVProcessChain>(builder.Start());
+ if (!chain->Valid()) {
+ std::cout << "Valid() returned false, should be true" << std::endl;
+ return false;
+ }
+ status = chain->GetStatus();
+ if (!resultsMatch(status, status1)) {
+ std::cout << "GetStatus() did not produce expected output" << std::endl;
+ printResults(status, status1);
+ return false;
+ }
+
+ if (chain->Wait(6000)) {
+ std::cout << "Wait() returned true, should be false" << std::endl;
+ return false;
+ }
+ status = chain->GetStatus();
+ if (!resultsMatch(status, status2)) {
+ std::cout << "GetStatus() did not produce expected output" << std::endl;
+ printResults(status, status2);
+ return false;
+ }
+
+ if (!chain->Wait()) {
+ std::cout << "Wait() returned false, should be true" << std::endl;
+ return false;
+ }
+ status = chain->GetStatus();
+ if (!resultsMatch(status, status3)) {
+ std::cout << "GetStatus() did not produce expected output" << std::endl;
+ printResults(status, status3);
+ return false;
+ }
+
+ return true;
+}
+
+bool checkOutput(std::istream& outputStream, std::istream& errorStream)
+{
+ std::string output = getInput(outputStream);
+ if (output != "HELO WRD!") {
+ std::cout << "Output was \"" << output << "\", expected \"HELO WRD!\""
+ << std::endl;
+ return false;
+ }
+
+ std::string error = getInput(errorStream);
+ if (error.length() != 3 || error.find('1') == std::string::npos ||
+ error.find('2') == std::string::npos ||
+ error.find('3') == std::string::npos) {
+ std::cout << "Error was \"" << error << "\", expected \"123\""
+ << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+bool testUVProcessChainBuiltin(const char* helperCommand)
+{
+ cmUVProcessChainBuilder builder;
+ std::unique_ptr<cmUVProcessChain> chain;
+ builder.AddCommand({ helperCommand, "echo" })
+ .AddCommand({ helperCommand, "capitalize" })
+ .AddCommand({ helperCommand, "dedup" })
+ .SetBuiltinStream(cmUVProcessChainBuilder::Stream_OUTPUT)
+ .SetBuiltinStream(cmUVProcessChainBuilder::Stream_ERROR);
+
+ if (!checkExecution(builder, chain)) {
+ return false;
+ }
+
+ if (!chain->OutputStream()) {
+ std::cout << "OutputStream() was null, expecting not null" << std::endl;
+ return false;
+ }
+ if (!chain->ErrorStream()) {
+ std::cout << "ErrorStream() was null, expecting not null" << std::endl;
+ return false;
+ }
+
+ if (!checkOutput(*chain->OutputStream(), *chain->ErrorStream())) {
+ return false;
+ }
+
+ return true;
+}
+
+bool testUVProcessChainExternal(const char* helperCommand)
+{
+ cmUVProcessChainBuilder builder;
+ std::unique_ptr<cmUVProcessChain> chain;
+ int outputPipe[2], errorPipe[2];
+ cm::uv_pipe_ptr outputInPipe, outputOutPipe, errorInPipe, errorOutPipe;
+
+ if (cmGetPipes(outputPipe) < 0) {
+ std::cout << "Error creating pipes" << std::endl;
+ return false;
+ }
+ if (cmGetPipes(errorPipe) < 0) {
+ std::cout << "Error creating pipes" << std::endl;
+ return false;
+ }
+
+ builder.AddCommand({ helperCommand, "echo" })
+ .AddCommand({ helperCommand, "capitalize" })
+ .AddCommand({ helperCommand, "dedup" })
+ .SetExternalStream(cmUVProcessChainBuilder::Stream_OUTPUT, outputPipe[1])
+ .SetExternalStream(cmUVProcessChainBuilder::Stream_ERROR, errorPipe[1]);
+
+ if (!checkExecution(builder, chain)) {
+ return false;
+ }
+
+ if (chain->OutputStream()) {
+ std::cout << "OutputStream() was not null, expecting null" << std::endl;
+ return false;
+ }
+ if (chain->ErrorStream()) {
+ std::cout << "ErrorStream() was not null, expecting null" << std::endl;
+ return false;
+ }
+
+ outputOutPipe.init(chain->GetLoop(), 0);
+ uv_pipe_open(outputOutPipe, outputPipe[1]);
+ outputOutPipe.reset();
+
+ errorOutPipe.init(chain->GetLoop(), 0);
+ uv_pipe_open(errorOutPipe, errorPipe[1]);
+ errorOutPipe.reset();
+
+ outputInPipe.init(chain->GetLoop(), 0);
+ uv_pipe_open(outputInPipe, outputPipe[0]);
+ cmUVStreambuf outputBuf;
+ outputBuf.open(outputInPipe);
+ std::istream outputStream(&outputBuf);
+
+ errorInPipe.init(chain->GetLoop(), 0);
+ uv_pipe_open(errorInPipe, errorPipe[0]);
+ cmUVStreambuf errorBuf;
+ errorBuf.open(errorInPipe);
+ std::istream errorStream(&errorBuf);
+
+ if (!checkOutput(outputStream, errorStream)) {
+ return false;
+ }
+
+ return true;
+}
+
+bool testUVProcessChainNone(const char* helperCommand)
+{
+ cmUVProcessChainBuilder builder;
+ std::unique_ptr<cmUVProcessChain> chain;
+ builder.AddCommand({ helperCommand, "echo" })
+ .AddCommand({ helperCommand, "capitalize" })
+ .AddCommand({ helperCommand, "dedup" });
+
+ if (!checkExecution(builder, chain)) {
+ return false;
+ }
+
+ if (chain->OutputStream()) {
+ std::cout << "OutputStream() was not null, expecting null" << std::endl;
+ return false;
+ }
+ if (chain->ErrorStream()) {
+ std::cout << "ErrorStream() was not null, expecting null" << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+int testUVProcessChain(int argc, char** const argv)
+{
+ if (argc < 2) {
+ std::cout << "Invalid arguments.\n";
+ return -1;
+ }
+
+ if (!testUVProcessChainBuiltin(argv[1])) {
+ std::cout << "While executing testUVProcessChainBuiltin().\n";
+ return -1;
+ }
+
+ if (!testUVProcessChainExternal(argv[1])) {
+ std::cout << "While executing testUVProcessChainExternal().\n";
+ return -1;
+ }
+
+ if (!testUVProcessChainNone(argv[1])) {
+ std::cout << "While executing testUVProcessChainNone().\n";
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/Tests/CMakeLib/testUVProcessChainHelper.cxx b/Tests/CMakeLib/testUVProcessChainHelper.cxx
new file mode 100644
index 0000000..9c25834
--- /dev/null
+++ b/Tests/CMakeLib/testUVProcessChainHelper.cxx
@@ -0,0 +1,72 @@
+#include <cctype>
+#include <chrono>
+#include <cstdlib>
+#include <iostream>
+#include <set>
+#include <sstream>
+#include <string>
+#include <thread>
+
+std::string getStdin()
+{
+ char buffer[1024];
+ std::ostringstream str;
+ do {
+ std::cin.read(buffer, 1024);
+ str.write(buffer, std::cin.gcount());
+ } while (std::cin.gcount() > 0);
+ return str.str();
+}
+
+int main(int argc, char** argv)
+{
+ if (argc < 2) {
+ return -1;
+ }
+
+ std::string command = argv[1];
+ if (command == "echo") {
+ std::this_thread::sleep_for(std::chrono::milliseconds(3000));
+ std::cout << "HELLO world!" << std::flush;
+ std::cerr << "1" << std::flush;
+ return 0;
+ }
+ if (command == "capitalize") {
+ std::this_thread::sleep_for(std::chrono::milliseconds(9000));
+ std::string input = getStdin();
+ for (auto& c : input) {
+ c = static_cast<char>(std::toupper(c));
+ }
+ std::cout << input << std::flush;
+ std::cerr << "2" << std::flush;
+ return 1;
+ }
+ if (command == "dedup") {
+ // Use a nested scope to free all resources before aborting below.
+ try {
+ std::string input = getStdin();
+ std::set<char> seen;
+ std::string output;
+ for (auto c : input) {
+ if (!seen.count(c)) {
+ seen.insert(c);
+ output += c;
+ }
+ }
+ std::cout << output << std::flush;
+ std::cerr << "3" << std::flush;
+ } catch (...) {
+ }
+
+ // On Windows, the exit code of abort() is different between debug and
+ // release builds, and does not yield a term_signal in libuv in either
+ // case. For the sake of simplicity, we just return another non-zero code.
+#ifdef _WIN32
+ return 2;
+#else
+ std::abort();
+#endif
+ }
+
+ return -1;
+}
diff --git a/Tests/CMakeLib/testUVRAII.cxx b/Tests/CMakeLib/testUVRAII.cxx
new file mode 100644
index 0000000..cb05ace
--- /dev/null
+++ b/Tests/CMakeLib/testUVRAII.cxx
@@ -0,0 +1,230 @@
+#include <chrono>
+#include <iostream>
+#include <thread>
+#include <utility>
+
+#include "cm_uv.h"
+
+#include "cmUVHandlePtr.h"
+
+static void signal_reset_fn(uv_async_t* handle)
+{
+ auto ptr = static_cast<cm::uv_async_ptr*>(handle->data);
+ ptr->reset();
+}
+
+// A common pattern is to use an async signal to shutdown the server.
+static bool testAsyncShutdown()
+{
+ uv_loop_t Loop;
+ auto err = uv_loop_init(&Loop);
+ if (err != 0) {
+ std::cerr << "Could not init loop" << std::endl;
+ return false;
+ }
+
+ {
+ cm::uv_async_ptr signal;
+ signal.init(Loop, &signal_reset_fn, &signal);
+
+ std::thread([&] {
+ std::this_thread::sleep_for(std::chrono::seconds(2));
+ signal.send();
+ })
+ .detach();
+
+ if (uv_run(&Loop, UV_RUN_DEFAULT) != 0) {
+ std::cerr << "Unclean exit state in testAsyncDtor" << std::endl;
+ return false;
+ }
+
+ if (signal.get()) {
+ std::cerr << "Loop exited with signal not being cleaned up" << std::endl;
+ return false;
+ }
+ }
+
+ uv_loop_close(&Loop);
+
+ return true;
+}
+
+static void signal_fn(uv_async_t*)
+{
+}
+
+// Async dtor is sort of a pain; since it locks a mutex we must be sure its
+// dtor always calls reset otherwise the mutex is deleted then locked.
+static bool testAsyncDtor()
+{
+ uv_loop_t Loop;
+ auto err = uv_loop_init(&Loop);
+ if (err != 0) {
+ std::cerr << "Could not init loop" << std::endl;
+ return false;
+ }
+
+ {
+ cm::uv_async_ptr signal;
+ signal.init(Loop, signal_fn);
+ }
+
+ if (uv_run(&Loop, UV_RUN_DEFAULT) != 0) {
+ std::cerr << "Unclean exit state in testAsyncDtor" << std::endl;
+ return false;
+ }
+
+ uv_loop_close(&Loop);
+
+ return true;
+}
+
+// Async needs a relatively stateful deleter; make sure that is properly
+// accounted for and doesn't try to hold on to invalid state when it is
+// moved
+static bool testAsyncMove()
+{
+ uv_loop_t Loop;
+ auto err = uv_loop_init(&Loop);
+ if (err != 0) {
+ std::cerr << "Could not init loop" << std::endl;
+ return false;
+ }
+
+ {
+ cm::uv_async_ptr signal;
+ {
+ cm::uv_async_ptr signalTmp;
+ signalTmp.init(Loop, signal_fn);
+ signal = std::move(signalTmp);
+ }
+ }
+
+ if (uv_run(&Loop, UV_RUN_DEFAULT) != 0) {
+ std::cerr << "Unclean exit state in testAsyncDtor" << std::endl;
+ return false;
+ }
+
+ uv_loop_close(&Loop);
+ return true;
+}
+
+// When a type is castable to another uv type (pipe -> stream) here,
+// and the deleter is convertible as well, we should allow moves from
+// one type to the other.
+static bool testCrossAssignment()
+{
+ uv_loop_t Loop;
+ auto err = uv_loop_init(&Loop);
+ if (err != 0) {
+ std::cerr << "Could not init loop" << std::endl;
+ return false;
+ }
+
+ {
+ cm::uv_pipe_ptr pipe;
+ pipe.init(Loop, 0);
+
+ cm::uv_stream_ptr stream = std::move(pipe);
+ if (pipe.get()) {
+ std::cerr << "Move should be sure to invalidate the previous ptr"
+ << std::endl;
+ return false;
+ }
+ cm::uv_handle_ptr handle = std::move(stream);
+ if (stream.get()) {
+ std::cerr << "Move should be sure to invalidate the previous ptr"
+ << std::endl;
+ return false;
+ }
+ }
+
+ if (uv_run(&Loop, UV_RUN_DEFAULT) != 0) {
+ std::cerr << "Unclean exit state in testCrossAssignment" << std::endl;
+ return false;
+ }
+
+ uv_loop_close(&Loop);
+ return true;
+}
+
+// This test can't fail at run time; but this makes sure we have all our move
+// ctors created correctly.
+static bool testAllMoves()
+{
+ using namespace cm;
+ struct allTypes
+ {
+ uv_stream_ptr _7;
+ uv_timer_ptr _8;
+ uv_tty_ptr _9;
+ uv_process_ptr _11;
+ uv_pipe_ptr _12;
+ uv_async_ptr _13;
+ uv_signal_ptr _14;
+ uv_handle_ptr _15;
+ };
+
+ allTypes a;
+ allTypes b(std::move(a));
+ allTypes c = std::move(b);
+ return true;
+};
+
+static bool testLoopReset()
+{
+ bool closed = false;
+ cm::uv_loop_ptr loop;
+ loop.init();
+
+ uv_timer_t timer;
+ uv_timer_init(loop, &timer);
+ timer.data = &closed;
+ uv_close(reinterpret_cast<uv_handle_t*>(&timer), [](uv_handle_t* handle) {
+ auto closedPtr = static_cast<bool*>(handle->data);
+ *closedPtr = true;
+ });
+
+ loop.reset();
+ if (!closed) {
+ std::cerr << "uv_loop_ptr did not finish" << std::endl;
+ return false;
+ }
+
+ return true;
+};
+
+static bool testLoopDestructor()
+{
+ bool closed = false;
+
+ uv_timer_t timer;
+ {
+ cm::uv_loop_ptr loop;
+ loop.init();
+
+ uv_timer_init(loop, &timer);
+ timer.data = &closed;
+ uv_close(reinterpret_cast<uv_handle_t*>(&timer), [](uv_handle_t* handle) {
+ auto closedPtr = static_cast<bool*>(handle->data);
+ *closedPtr = true;
+ });
+ }
+
+ if (!closed) {
+ std::cerr << "uv_loop_ptr did not finish" << std::endl;
+ return false;
+ }
+
+ return true;
+};
+
+int testUVRAII(int, char** const)
+{
+ if ((testAsyncShutdown() &&
+ testAsyncDtor() & testAsyncMove() & testCrossAssignment() &
+ testAllMoves() & testLoopReset() & testLoopDestructor()) == 0) {
+ return -1;
+ }
+ return 0;
+}
diff --git a/Tests/CMakeLib/testUVStreambuf.cxx b/Tests/CMakeLib/testUVStreambuf.cxx
new file mode 100644
index 0000000..cd9c9d4
--- /dev/null
+++ b/Tests/CMakeLib/testUVStreambuf.cxx
@@ -0,0 +1,455 @@
+#include <cstring>
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include <stdint.h>
+
+#include "cm_uv.h"
+
+#include "cmGetPipes.h"
+#include "cmUVHandlePtr.h"
+#include "cmUVStreambuf.h"
+
+#define TEST_STR_LINE_1 "This string must be exactly 128 characters long so"
+#define TEST_STR_LINE_2 "that we can test CMake's std::streambuf integration"
+#define TEST_STR_LINE_3 "with libuv's uv_stream_t."
+#define TEST_STR TEST_STR_LINE_1 "\n" TEST_STR_LINE_2 "\n" TEST_STR_LINE_3
+
+bool writeDataToStreamPipe(uv_loop_t& loop, cm::uv_pipe_ptr& inputPipe,
+ char* outputData, unsigned int outputDataLength,
+ const char* /* unused */)
+{
+ int err;
+
+ // Create the pipe
+ int pipeHandles[2];
+ if (cmGetPipes(pipeHandles) < 0) {
+ std::cout << "Could not open pipe" << std::endl;
+ return false;
+ }
+
+ cm::uv_pipe_ptr outputPipe;
+ inputPipe.init(loop, 0);
+ outputPipe.init(loop, 0);
+ uv_pipe_open(inputPipe, pipeHandles[0]);
+ uv_pipe_open(outputPipe, pipeHandles[1]);
+
+ // Write data for reading
+ uv_write_t writeReq;
+ struct WriteCallbackData
+ {
+ bool Finished = false;
+ int Status;
+ } writeData;
+ writeReq.data = &writeData;
+ uv_buf_t outputBuf;
+ outputBuf.base = outputData;
+ outputBuf.len = outputDataLength;
+ if ((err = uv_write(&writeReq, outputPipe, &outputBuf, 1,
+ [](uv_write_t* req, int status) {
+ auto data = static_cast<WriteCallbackData*>(req->data);
+ data->Finished = true;
+ data->Status = status;
+ })) < 0) {
+ std::cout << "Could not write to pipe: " << uv_strerror(err) << std::endl;
+ return false;
+ }
+ while (!writeData.Finished) {
+ uv_run(&loop, UV_RUN_ONCE);
+ }
+ if (writeData.Status < 0) {
+ std::cout << "Status is " << uv_strerror(writeData.Status)
+ << ", should be 0" << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+bool writeDataToStreamProcess(uv_loop_t& loop, cm::uv_pipe_ptr& inputPipe,
+ char* outputData, unsigned int /* unused */,
+ const char* cmakeCommand)
+{
+ int err;
+
+ inputPipe.init(loop, 0);
+ std::vector<std::string> arguments = { cmakeCommand, "-E", "echo_append",
+ outputData };
+ std::vector<const char*> processArgs;
+ for (auto const& arg : arguments) {
+ processArgs.push_back(arg.c_str());
+ }
+ processArgs.push_back(nullptr);
+ std::vector<uv_stdio_container_t> stdio(3);
+ stdio[0].flags = UV_IGNORE;
+ stdio[0].data.stream = nullptr;
+ stdio[1].flags =
+ static_cast<uv_stdio_flags>(UV_CREATE_PIPE | UV_WRITABLE_PIPE);
+ stdio[1].data.stream = inputPipe;
+ stdio[2].flags = UV_IGNORE;
+ stdio[2].data.stream = nullptr;
+
+ struct ProcessExitData
+ {
+ bool Finished = false;
+ int64_t ExitStatus;
+ int TermSignal;
+ } exitData;
+ cm::uv_process_ptr process;
+ auto options = uv_process_options_t();
+ options.file = cmakeCommand;
+ options.args = const_cast<char**>(processArgs.data());
+ options.flags = UV_PROCESS_WINDOWS_HIDE;
+ options.stdio = stdio.data();
+ options.stdio_count = static_cast<int>(stdio.size());
+ options.exit_cb = [](uv_process_t* handle, int64_t exitStatus,
+ int termSignal) {
+ auto data = static_cast<ProcessExitData*>(handle->data);
+ data->Finished = true;
+ data->ExitStatus = exitStatus;
+ data->TermSignal = termSignal;
+ };
+ if ((err = process.spawn(loop, options, &exitData)) < 0) {
+ std::cout << "Could not spawn process: " << uv_strerror(err) << std::endl;
+ return false;
+ }
+ while (!exitData.Finished) {
+ uv_run(&loop, UV_RUN_ONCE);
+ }
+ if (exitData.ExitStatus != 0) {
+ std::cout << "Process exit status is " << exitData.ExitStatus
+ << ", should be 0" << std::endl;
+ return false;
+ }
+ if (exitData.TermSignal != 0) {
+ std::cout << "Process term signal is " << exitData.TermSignal
+ << ", should be 0" << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+bool testUVStreambufRead(
+ bool (*cb)(uv_loop_t& loop, cm::uv_pipe_ptr& inputPipe, char* outputData,
+ unsigned int outputDataLength, const char* cmakeCommand),
+ const char* cmakeCommand)
+{
+ char outputData[] = TEST_STR;
+ bool success = false;
+ cm::uv_loop_ptr loop;
+ loop.init();
+ cm::uv_pipe_ptr inputPipe;
+ std::vector<char> inputData(128);
+ std::streamsize readLen;
+ std::string line;
+ cm::uv_timer_ptr timer;
+
+ // Create the streambuf
+ cmUVStreambuf inputBuf(64);
+ std::istream inputStream(&inputBuf);
+ if (inputBuf.is_open()) {
+ std::cout << "is_open() is true, should be false" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+
+ // Perform first read test - read all the data
+ if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) {
+ goto end;
+ }
+ inputBuf.open(inputPipe);
+ if (!inputBuf.is_open()) {
+ std::cout << "is_open() is false, should be true" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 128) {
+ std::cout << "sgetn() returned " << readLen << ", should be 128"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if (std::memcmp(inputData.data(), outputData, 128)) {
+ std::cout << "Read data does not match write data" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+ inputData.assign(128, char{});
+ inputBuf.close();
+ if (inputBuf.is_open()) {
+ std::cout << "is_open() is true, should be false" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+
+ // Perform second read test - read some data and then close
+ if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) {
+ goto end;
+ }
+ inputBuf.open(inputPipe);
+ if (!inputBuf.is_open()) {
+ std::cout << "is_open() is false, should be true" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 64)) != 64) {
+ std::cout << "sgetn() returned " << readLen << ", should be 64"
+ << std::endl;
+ goto end;
+ }
+ if (std::memcmp(inputData.data(), outputData, 64)) {
+ std::cout << "Read data does not match write data" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 8) {
+ std::cout << "in_avail() returned " << readLen << ", should be 8"
+ << std::endl;
+ goto end;
+ }
+ inputData.assign(128, char{});
+ inputBuf.close();
+ if (inputBuf.is_open()) {
+ std::cout << "is_open() is true, should be false" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+
+ // Perform third read test - read line by line
+ if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) {
+ goto end;
+ }
+ inputBuf.open(inputPipe);
+ if (!inputBuf.is_open()) {
+ std::cout << "is_open() is false, should be true" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+
+ if (!std::getline(inputStream, line)) {
+ std::cout << "getline returned false, should be true" << std::endl;
+ goto end;
+ }
+ if (line != TEST_STR_LINE_1) {
+ std::cout << "Line 1 is \"" << line
+ << "\", should be \"" TEST_STR_LINE_1 "\"" << std::endl;
+ goto end;
+ }
+
+ if (!std::getline(inputStream, line)) {
+ std::cout << "getline returned false, should be true" << std::endl;
+ goto end;
+ }
+ if (line != TEST_STR_LINE_2) {
+ std::cout << "Line 2 is \"" << line
+ << "\", should be \"" TEST_STR_LINE_2 "\"" << std::endl;
+ goto end;
+ }
+
+ if (!std::getline(inputStream, line)) {
+ std::cout << "getline returned false, should be true" << std::endl;
+ goto end;
+ }
+ if (line != TEST_STR_LINE_3) {
+ std::cout << "Line 3 is \"" << line
+ << "\", should be \"" TEST_STR_LINE_3 "\"" << std::endl;
+ goto end;
+ }
+
+ if (std::getline(inputStream, line)) {
+ std::cout << "getline returned true, should be false" << std::endl;
+ goto end;
+ }
+
+ inputBuf.close();
+ if (inputBuf.is_open()) {
+ std::cout << "is_open() is true, should be false" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+
+ // Perform fourth read test - run the event loop outside of underflow()
+ if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) {
+ goto end;
+ }
+ inputBuf.open(inputPipe);
+ if (!inputBuf.is_open()) {
+ std::cout << "is_open() is false, should be true" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ uv_run(loop, UV_RUN_DEFAULT);
+ if ((readLen = inputBuf.in_avail()) != 72) {
+ std::cout << "in_avail() returned " << readLen << ", should be 72"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 128) {
+ std::cout << "sgetn() returned " << readLen << ", should be 128"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 128"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+
+ inputBuf.close();
+ if (inputBuf.is_open()) {
+ std::cout << "is_open() is true, should be false" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+
+ // Perform fifth read test - close the streambuf in the middle of a read
+ timer.init(*loop, &inputBuf);
+ if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) {
+ goto end;
+ }
+ inputBuf.open(inputPipe);
+ if (!inputBuf.is_open()) {
+ std::cout << "is_open() is false, should be true" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ uv_timer_start(timer,
+ [](uv_timer_t* handle) {
+ auto buf = static_cast<cmUVStreambuf*>(handle->data);
+ buf->close();
+ },
+ 0, 0);
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if (inputBuf.is_open()) {
+ std::cout << "is_open() is true, should be false" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+
+ success = true;
+
+end:
+ return success;
+}
+
+int testUVStreambuf(int argc, char** const argv)
+{
+ if (argc < 2) {
+ std::cout << "Invalid arguments.\n";
+ return -1;
+ }
+
+ if (!testUVStreambufRead(writeDataToStreamPipe, argv[1])) {
+ std::cout << "While executing testUVStreambufRead() with pipe.\n";
+ return -1;
+ }
+
+ if (!testUVStreambufRead(writeDataToStreamProcess, argv[1])) {
+ std::cout << "While executing testUVStreambufRead() with process.\n";
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser.cxx b/Tests/CMakeLib/testVisualStudioSlnParser.cxx
new file mode 100644
index 0000000..3c06960
--- /dev/null
+++ b/Tests/CMakeLib/testVisualStudioSlnParser.cxx
@@ -0,0 +1,195 @@
+#include "testVisualStudioSlnParser.h"
+
+#include <iostream>
+
+#include "cmVisualStudioSlnData.h"
+#include "cmVisualStudioSlnParser.h"
+
+static bool parsedRight(cmVisualStudioSlnParser& parser,
+ const std::string& file, cmSlnData& data,
+ cmVisualStudioSlnParser::ParseResult expected =
+ cmVisualStudioSlnParser::ResultOK)
+{
+ if (parser.ParseFile(SOURCE_DIR "/testVisualStudioSlnParser_data/" + file +
+ "." SLN_EXTENSION,
+ data, cmVisualStudioSlnParser::DataGroupProjects)) {
+ if (expected == cmVisualStudioSlnParser::ResultOK) {
+ return true;
+ }
+ } else {
+ if (parser.GetParseResult() == expected) {
+ return true;
+ }
+ }
+ std::cerr << "cmVisualStudioSlnParser mis-parsed " << file
+ << "." SLN_EXTENSION << "; expected result " << expected
+ << ", got " << parser.GetParseResult() << std::endl;
+ return false;
+}
+
+int testVisualStudioSlnParser(int, char* [])
+{
+ cmVisualStudioSlnParser parser;
+
+ // Test clean parser
+ if (parser.GetParseResult() != cmVisualStudioSlnParser::ResultOK) {
+ std::cerr << "cmVisualStudioSlnParser initialisation failed" << std::endl;
+ return 1;
+ }
+
+ // Test parsing valid sln
+ {
+ cmSlnData data;
+ if (!parsedRight(parser, "valid", data)) {
+ return 1;
+ }
+ const std::vector<cmSlnProjectEntry>& projects = data.GetProjects();
+ const char* const names[] = {
+ "3rdParty",
+ "ALL_BUILD",
+ "CMakeLib",
+ "CMakeLibTests",
+ "CMakePredefinedTargets",
+ "CPackLib",
+ "CTestDashboardTargets",
+ "CTestLib",
+ "Continuous",
+ "Documentation",
+ "Experimental",
+ "INSTALL",
+ "KWSys",
+ "LIBCURL",
+ "Nightly",
+ "NightlyMemoryCheck",
+ "PACKAGE",
+ "RUN_TESTS",
+ "Tests",
+ "Utilities",
+ "Win9xCompat",
+ "ZERO_CHECK",
+ "cmIML_test",
+ "cmake",
+ "cmbzip2",
+ "cmcldeps",
+ "cmcompress",
+ "cmcurl",
+ "cmexpat",
+ "cmlibarchive",
+ "cmsys",
+ "cmsysEncodeExecutable",
+ "cmsysProcessFwd9x",
+ "cmsysTestDynload",
+ "cmsysTestProcess",
+ "cmsysTestSharedForward",
+ "cmsysTestsC",
+ "cmsysTestsCxx",
+ "cmsys_c",
+ "cmw9xcom",
+ "cmzlib",
+ "cpack",
+ "ctest",
+ "documentation",
+ "memcheck_fail",
+ "pseudo_BC",
+ "pseudo_purify",
+ "pseudo_valgrind",
+ "test_clean",
+ "uninstall"
+ /* clang-format needs this comment to break after the opening brace */
+ };
+ const size_t expectedProjectCount = sizeof(names) / sizeof(*names);
+ if (projects.size() != expectedProjectCount) {
+ std::cerr << "cmVisualStudioSlnParser returned bad number of "
+ << "projects (" << projects.size() << " instead of "
+ << expectedProjectCount << ')' << std::endl;
+ return 1;
+ }
+ for (size_t idx = 0; idx < expectedProjectCount; ++idx) {
+ if (projects[idx].GetName() != names[idx]) {
+ std::cerr << "cmVisualStudioSlnParser returned bad project #" << idx
+ << "; expected \"" << names[idx] << "\", got \""
+ << projects[idx].GetName() << '"' << std::endl;
+ return 1;
+ }
+ }
+ if (projects[0].GetRelativePath() != "Utilities\\3rdParty") {
+ std::cerr << "cmVisualStudioSlnParser returned bad relative path of "
+ << "project 3rdParty; expected \"Utilities\\3rdParty\", "
+ << "got \"" << projects[0].GetRelativePath() << '"'
+ << std::endl;
+ return 1;
+ }
+ if (projects[2].GetGUID() != "{59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}") {
+ std::cerr << "cmVisualStudioSlnParser returned bad relative path of "
+ << "project CMakeLib; expected "
+ << "\"{59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}\", "
+ << "got \"" << projects[2].GetGUID() << '"' << std::endl;
+ return 1;
+ }
+ }
+
+ // Test BOM parsing
+ {
+ cmSlnData data;
+
+ if (!parsedRight(parser, "bom", data)) {
+ return 1;
+ }
+ if (!parser.GetParseHadBOM()) {
+ std::cerr << "cmVisualStudioSlnParser didn't find BOM in bom."
+ << SLN_EXTENSION << std::endl;
+ return 1;
+ }
+
+ if (!parsedRight(parser, "nobom", data)) {
+ return 1;
+ }
+ if (parser.GetParseHadBOM()) {
+ std::cerr << "cmVisualStudioSlnParser found BOM in nobom."
+ << SLN_EXTENSION << std::endl;
+ return 1;
+ }
+ }
+
+ // Test invalid sln
+ {
+ {
+ cmSlnData data;
+ if (!parsedRight(parser, "err-nonexistent", data,
+ cmVisualStudioSlnParser::ResultErrorOpeningInput)) {
+ return 1;
+ }
+ }
+ {
+ cmSlnData data;
+ if (!parsedRight(parser, "err-empty", data,
+ cmVisualStudioSlnParser::ResultErrorReadingInput)) {
+ return 1;
+ }
+ }
+ const char* const files[] = {
+ "header", "projectArgs", "topLevel", "projectContents",
+ "projectSection", "global", "unclosed", "strayQuote",
+ "strayParen", "strayQuote2"
+ /* clang-format needs this comment to break after the opening brace */
+ };
+ for (size_t idx = 0; idx < sizeof(files) / sizeof(files[0]); ++idx) {
+ cmSlnData data;
+ if (!parsedRight(parser, std::string("err-structure-") + files[idx],
+ data,
+ cmVisualStudioSlnParser::ResultErrorInputStructure)) {
+ return 1;
+ }
+ }
+ {
+ cmSlnData data;
+ if (!parsedRight(parser, "err-data", data,
+ cmVisualStudioSlnParser::ResultErrorInputData)) {
+ return 1;
+ }
+ }
+ }
+
+ // All is well
+ return 0;
+}
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser.h.in b/Tests/CMakeLib/testVisualStudioSlnParser.h.in
new file mode 100644
index 0000000..62c3f4d
--- /dev/null
+++ b/Tests/CMakeLib/testVisualStudioSlnParser.h.in
@@ -0,0 +1,7 @@
+#ifndef testVisualStudioSlnParser_h
+#define testVisualStudioSlnParser_h
+
+#define SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@"
+#define SLN_EXTENSION "sln-file"
+
+#endif
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/.gitattributes b/Tests/CMakeLib/testVisualStudioSlnParser_data/.gitattributes
new file mode 100644
index 0000000..08b4ac4
--- /dev/null
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/.gitattributes
@@ -0,0 +1 @@
+*.sln-file eol=crlf
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/bom.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/bom.sln-file
new file mode 100644
index 0000000..f8c432f
--- /dev/null
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/bom.sln-file
@@ -0,0 +1,2 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-data.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-data.sln-file
new file mode 100644
index 0000000..4656046
--- /dev/null
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-data.sln-file
@@ -0,0 +1,6 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+EndProject
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-empty.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-empty.sln-file
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-empty.sln-file
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-global.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-global.sln-file
new file mode 100644
index 0000000..d65d82a
--- /dev/null
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-global.sln-file
@@ -0,0 +1,9 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Global
+EndGlobalSection
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-header.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-header.sln-file
new file mode 100644
index 0000000..cc6d1b8
--- /dev/null
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-header.sln-file
@@ -0,0 +1,4 @@
+Microsoft Visual Studio Solution2 File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+EndProject
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectArgs.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectArgs.sln-file
new file mode 100644
index 0000000..31ed7b8
--- /dev/null
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectArgs.sln-file
@@ -0,0 +1,4 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj"
+EndProject
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectContents.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectContents.sln-file
new file mode 100644
index 0000000..a2eb7ba
--- /dev/null
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectContents.sln-file
@@ -0,0 +1,6 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous2", "Continuous2.vcxproj", "{E5071091-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+ EndProject
+EndProject
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectSection.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectSection.sln-file
new file mode 100644
index 0000000..8688e75
--- /dev/null
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectSection.sln-file
@@ -0,0 +1,11 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZERO_CHECK", "ZERO_CHECK.vcxproj", "{90BC31D7-A3E8-4F04-8049-2236C239A044}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProject
+EndProject
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayParen.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayParen.sln-file
new file mode 100644
index 0000000..f2a3ea1
--- /dev/null
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayParen.sln-file
@@ -0,0 +1,4 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}" = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+EndProject
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayQuote.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayQuote.sln-file
new file mode 100644
index 0000000..b91dae3
--- /dev/null
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayQuote.sln-file
@@ -0,0 +1,4 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}
+EndProject
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayQuote2.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayQuote2.sln-file
new file mode 100644
index 0000000..1d01fda
--- /dev/null
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayQuote2.sln-file
@@ -0,0 +1,4 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}) = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+EndProject
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-topLevel.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-topLevel.sln-file
new file mode 100644
index 0000000..c406974
--- /dev/null
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-topLevel.sln-file
@@ -0,0 +1,4 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+GlobalSection(ExtensibilityGlobals) = postSolution
+EndGlobalSection
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-unclosed.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-unclosed.sln-file
new file mode 100644
index 0000000..d814bf4
--- /dev/null
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-unclosed.sln-file
@@ -0,0 +1,5 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Global
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/nobom.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/nobom.sln-file
new file mode 100644
index 0000000..8168b6b
--- /dev/null
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/nobom.sln-file
@@ -0,0 +1,2 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/valid.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/valid.sln-file
new file mode 100644
index 0000000..395b953
--- /dev/null
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/valid.sln-file
@@ -0,0 +1,680 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ALL_BUILD", "ALL_BUILD.vcxproj", "{BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}"
+ ProjectSection(ProjectDependencies) = postProject
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
+ {B025BD09-8389-4D9F-9150-F33418A664B1} = {B025BD09-8389-4D9F-9150-F33418A664B1}
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8} = {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8} = {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}
+ {0283B293-0067-4D02-ADA6-892704398F48} = {0283B293-0067-4D02-ADA6-892704398F48}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B} = {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8} = {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
+ {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84} = {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE} = {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996} = {29D5FCAF-20D0-4DEF-8529-F035C249E996}
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591} = {A0421DCA-AC3E-42D0-94AC-379A21A1E591}
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E} = {C6AF7E57-CE57-4462-AE1D-BF520701480E}
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7} = {F2CAAAB3-9568-4284-B8E3-13955183A6D7}
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0} = {D8294E4A-03C5-43D7-AE35-15603F502DC0}
+ {A4921D15-411F-436A-B6F3-F8381652A8E1} = {A4921D15-411F-436A-B6F3-F8381652A8E1}
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C} = {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C} = {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5} = {0E9E295F-3854-415B-AE9F-7B62F17932F5}
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644} = {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}
+ {F77AD922-B4BC-43D7-B268-865312085495} = {F77AD922-B4BC-43D7-B268-865312085495}
+ {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88} = {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}
+ {1DFA0599-77CC-4768-B47A-107EEE86C20C} = {1DFA0599-77CC-4768-B47A-107EEE86C20C}
+ {0E45A3EF-8636-46CF-94A3-7B5CE875DE48} = {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}
+ {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C} = {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CMakeLib", "Source\CMakeLib.vcxproj", "{59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CMakeLibTests", "Tests\CMakeLib\CMakeLibTests.vcxproj", "{B025BD09-8389-4D9F-9150-F33418A664B1}"
+ ProjectSection(ProjectDependencies) = postProject
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CPackLib", "Source\CPackLib.vcxproj", "{94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}"
+ ProjectSection(ProjectDependencies) = postProject
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CTestLib", "Source\CTestLib.vcxproj", "{1002C8FC-7242-4A69-AF51-C59BB10BA6D8}"
+ ProjectSection(ProjectDependencies) = postProject
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Experimental", "Experimental.vcxproj", "{B28E8445-DFD2-46EA-BA6C-C2A1864F2FB1}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "INSTALL", "INSTALL.vcxproj", "{3B126B2D-DEAA-4CDF-9F44-28D3600F5754}"
+ ProjectSection(ProjectDependencies) = postProject
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C} = {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LIBCURL", "Utilities\cmcurl\LIBCURL.vcxproj", "{0283B293-0067-4D02-ADA6-892704398F48}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Nightly", "Nightly.vcxproj", "{7BAF09E0-DCD4-4567-9486-79E1E5F18333}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NightlyMemoryCheck", "NightlyMemoryCheck.vcxproj", "{D0413FDA-31C5-41C2-A53A-C1B87061EC96}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PACKAGE", "PACKAGE.vcxproj", "{4C488FF0-7C06-47FE-A8FD-67DAD51A3E85}"
+ ProjectSection(ProjectDependencies) = postProject
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C} = {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RUN_TESTS", "RUN_TESTS.vcxproj", "{D87B08A8-638E-43FA-96C2-404B41363D3B}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZERO_CHECK", "ZERO_CHECK.vcxproj", "{90BC31D7-A3E8-4F04-8049-2236C239A044}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmIML_test", "Utilities\KWIML\test\cmIML_test.vcxproj", "{48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmake", "Source\cmake.vcxproj", "{6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}"
+ ProjectSection(ProjectDependencies) = postProject
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmbzip2", "Utilities\cmbzip2\cmbzip2.vcxproj", "{1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmcldeps", "Source\cmcldeps.vcxproj", "{A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}"
+ ProjectSection(ProjectDependencies) = postProject
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmcompress", "Utilities\cmcompress\cmcompress.vcxproj", "{561AD1BB-6DD3-466D-B270-3696DEE8C26C}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmcurl", "Utilities\cmcurl\cmcurl.vcxproj", "{1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmexpat", "Utilities\cmexpat\cmexpat.vcxproj", "{459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmlibarchive", "Utilities\cmlibarchive\libarchive\cmlibarchive.vcxproj", "{25A91A7A-9C4E-420C-98BD-2D1F0165DA54}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsys", "Source\kwsys\cmsys.vcxproj", "{BDB424DC-15B3-4A06-A1E2-3D61380F359F}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE} = {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996} = {29D5FCAF-20D0-4DEF-8529-F035C249E996}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysEncodeExecutable", "Source\kwsys\cmsysEncodeExecutable.vcxproj", "{4810B052-899E-4CA5-A0BC-2E383F8AEFAE}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysProcessFwd9x", "Source\kwsys\cmsysProcessFwd9x.vcxproj", "{29D5FCAF-20D0-4DEF-8529-F035C249E996}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysTestDynload", "Source\kwsys\cmsysTestDynload.vcxproj", "{A0421DCA-AC3E-42D0-94AC-379A21A1E591}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysTestProcess", "Source\kwsys\cmsysTestProcess.vcxproj", "{C6AF7E57-CE57-4462-AE1D-BF520701480E}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C} = {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysTestSharedForward", "Source\kwsys\cmsysTestSharedForward.vcxproj", "{F2CAAAB3-9568-4284-B8E3-13955183A6D7}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C} = {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysTestsC", "Source\kwsys\cmsysTestsC.vcxproj", "{D8294E4A-03C5-43D7-AE35-15603F502DC0}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C} = {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysTestsCxx", "Source\kwsys\cmsysTestsCxx.vcxproj", "{A4921D15-411F-436A-B6F3-F8381652A8E1}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsys_c", "Source\kwsys\cmsys_c.vcxproj", "{60BEB3AF-B4EF-4363-8747-C40177BC2D9C}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE} = {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996} = {29D5FCAF-20D0-4DEF-8529-F035C249E996}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmw9xcom", "Source\cmw9xcom.vcxproj", "{ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}"
+ ProjectSection(ProjectDependencies) = postProject
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmzlib", "Utilities\cmzlib\cmzlib.vcxproj", "{0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpack", "Source\cpack.vcxproj", "{0E9E295F-3854-415B-AE9F-7B62F17932F5}"
+ ProjectSection(ProjectDependencies) = postProject
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8} = {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ctest", "Source\ctest.vcxproj", "{4BFA4D7C-C6F7-4270-9E87-B922DCE05644}"
+ ProjectSection(ProjectDependencies) = postProject
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8} = {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "documentation", "Utilities\documentation.vcxproj", "{F77AD922-B4BC-43D7-B268-865312085495}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8} = {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5} = {0E9E295F-3854-415B-AE9F-7B62F17932F5}
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644} = {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "memcheck_fail", "Tests\CTestTestMemcheck\memcheck_fail.vcxproj", "{8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pseudo_BC", "Tests\CTestTestMemcheck\pseudo_BC.vcxproj", "{1DFA0599-77CC-4768-B47A-107EEE86C20C}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pseudo_purify", "Tests\CTestTestMemcheck\pseudo_purify.vcxproj", "{0E45A3EF-8636-46CF-94A3-7B5CE875DE48}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pseudo_valgrind", "Tests\CTestTestMemcheck\pseudo_valgrind.vcxproj", "{CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_clean", "Tests\test_clean.vcxproj", "{02D16A66-6D59-4A0E-ABB3-BD12926934FE}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uninstall", "uninstall.vcxproj", "{B5A9B8B7-53AC-46D7-9ADE-76F708A7189C}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CMakePredefinedTargets", "CMakePredefinedTargets", "{31CE49D7-85CA-41E2-83D2-CC6962519DB6}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CTestDashboardTargets", "CTestDashboardTargets", "{BD073C58-BAED-420E-80EA-DC9F52E21AF7}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documentation", "Documentation", "{8ECAB3CD-B434-426B-B63A-115919D393BC}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{964DC7DE-990A-4CA4-8395-10D9F9CB2A23}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utilities", "Utilities", "{7E002D15-21D1-4927-B486-82E496444441}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3rdParty", "Utilities\3rdParty", "{0984A63C-130E-4B62-9A94-AAC28A88C137}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "KWSys", "Utilities\KWSys", "{EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Win9xCompat", "Utilities\Win9xCompat", "{2485E202-B981-41E0-98CA-CF363437A4E4}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Release|x64 = Release|x64
+ MinSizeRel|x64 = MinSizeRel|x64
+ RelWithDebInfo|x64 = RelWithDebInfo|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.Debug|x64.ActiveCfg = Debug|x64
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.Debug|x64.Build.0 = Debug|x64
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.Release|x64.ActiveCfg = Release|x64
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.Release|x64.Build.0 = Release|x64
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.Debug|x64.ActiveCfg = Debug|x64
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.Debug|x64.Build.0 = Debug|x64
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.Release|x64.ActiveCfg = Release|x64
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.Release|x64.Build.0 = Release|x64
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {B025BD09-8389-4D9F-9150-F33418A664B1}.Debug|x64.ActiveCfg = Debug|x64
+ {B025BD09-8389-4D9F-9150-F33418A664B1}.Debug|x64.Build.0 = Debug|x64
+ {B025BD09-8389-4D9F-9150-F33418A664B1}.Release|x64.ActiveCfg = Release|x64
+ {B025BD09-8389-4D9F-9150-F33418A664B1}.Release|x64.Build.0 = Release|x64
+ {B025BD09-8389-4D9F-9150-F33418A664B1}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {B025BD09-8389-4D9F-9150-F33418A664B1}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {B025BD09-8389-4D9F-9150-F33418A664B1}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {B025BD09-8389-4D9F-9150-F33418A664B1}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.Debug|x64.ActiveCfg = Debug|x64
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.Debug|x64.Build.0 = Debug|x64
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.Release|x64.ActiveCfg = Release|x64
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.Release|x64.Build.0 = Release|x64
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.Debug|x64.ActiveCfg = Debug|x64
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.Debug|x64.Build.0 = Debug|x64
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.Release|x64.ActiveCfg = Release|x64
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.Release|x64.Build.0 = Release|x64
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}.Debug|x64.ActiveCfg = Debug|x64
+ {E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}.Release|x64.ActiveCfg = Release|x64
+ {E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {B28E8445-DFD2-46EA-BA6C-C2A1864F2FB1}.Debug|x64.ActiveCfg = Debug|x64
+ {B28E8445-DFD2-46EA-BA6C-C2A1864F2FB1}.Release|x64.ActiveCfg = Release|x64
+ {B28E8445-DFD2-46EA-BA6C-C2A1864F2FB1}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {B28E8445-DFD2-46EA-BA6C-C2A1864F2FB1}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {3B126B2D-DEAA-4CDF-9F44-28D3600F5754}.Debug|x64.ActiveCfg = Debug|x64
+ {3B126B2D-DEAA-4CDF-9F44-28D3600F5754}.Release|x64.ActiveCfg = Release|x64
+ {3B126B2D-DEAA-4CDF-9F44-28D3600F5754}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {3B126B2D-DEAA-4CDF-9F44-28D3600F5754}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {0283B293-0067-4D02-ADA6-892704398F48}.Debug|x64.ActiveCfg = Debug|x64
+ {0283B293-0067-4D02-ADA6-892704398F48}.Debug|x64.Build.0 = Debug|x64
+ {0283B293-0067-4D02-ADA6-892704398F48}.Release|x64.ActiveCfg = Release|x64
+ {0283B293-0067-4D02-ADA6-892704398F48}.Release|x64.Build.0 = Release|x64
+ {0283B293-0067-4D02-ADA6-892704398F48}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {0283B293-0067-4D02-ADA6-892704398F48}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {0283B293-0067-4D02-ADA6-892704398F48}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {0283B293-0067-4D02-ADA6-892704398F48}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {7BAF09E0-DCD4-4567-9486-79E1E5F18333}.Debug|x64.ActiveCfg = Debug|x64
+ {7BAF09E0-DCD4-4567-9486-79E1E5F18333}.Release|x64.ActiveCfg = Release|x64
+ {7BAF09E0-DCD4-4567-9486-79E1E5F18333}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {7BAF09E0-DCD4-4567-9486-79E1E5F18333}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {D0413FDA-31C5-41C2-A53A-C1B87061EC96}.Debug|x64.ActiveCfg = Debug|x64
+ {D0413FDA-31C5-41C2-A53A-C1B87061EC96}.Release|x64.ActiveCfg = Release|x64
+ {D0413FDA-31C5-41C2-A53A-C1B87061EC96}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {D0413FDA-31C5-41C2-A53A-C1B87061EC96}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {4C488FF0-7C06-47FE-A8FD-67DAD51A3E85}.Debug|x64.ActiveCfg = Debug|x64
+ {4C488FF0-7C06-47FE-A8FD-67DAD51A3E85}.Release|x64.ActiveCfg = Release|x64
+ {4C488FF0-7C06-47FE-A8FD-67DAD51A3E85}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {4C488FF0-7C06-47FE-A8FD-67DAD51A3E85}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {D87B08A8-638E-43FA-96C2-404B41363D3B}.Debug|x64.ActiveCfg = Debug|x64
+ {D87B08A8-638E-43FA-96C2-404B41363D3B}.Release|x64.ActiveCfg = Release|x64
+ {D87B08A8-638E-43FA-96C2-404B41363D3B}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {D87B08A8-638E-43FA-96C2-404B41363D3B}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {90BC31D7-A3E8-4F04-8049-2236C239A044}.Debug|x64.ActiveCfg = Debug|x64
+ {90BC31D7-A3E8-4F04-8049-2236C239A044}.Debug|x64.Build.0 = Debug|x64
+ {90BC31D7-A3E8-4F04-8049-2236C239A044}.Release|x64.ActiveCfg = Release|x64
+ {90BC31D7-A3E8-4F04-8049-2236C239A044}.Release|x64.Build.0 = Release|x64
+ {90BC31D7-A3E8-4F04-8049-2236C239A044}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {90BC31D7-A3E8-4F04-8049-2236C239A044}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {90BC31D7-A3E8-4F04-8049-2236C239A044}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {90BC31D7-A3E8-4F04-8049-2236C239A044}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.Debug|x64.ActiveCfg = Debug|x64
+ {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.Debug|x64.Build.0 = Debug|x64
+ {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.Release|x64.ActiveCfg = Release|x64
+ {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.Release|x64.Build.0 = Release|x64
+ {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.Debug|x64.ActiveCfg = Debug|x64
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.Debug|x64.Build.0 = Debug|x64
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.Release|x64.ActiveCfg = Release|x64
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.Release|x64.Build.0 = Release|x64
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.Debug|x64.ActiveCfg = Debug|x64
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.Debug|x64.Build.0 = Debug|x64
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.Release|x64.ActiveCfg = Release|x64
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.Release|x64.Build.0 = Release|x64
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.Debug|x64.ActiveCfg = Debug|x64
+ {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.Debug|x64.Build.0 = Debug|x64
+ {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.Release|x64.ActiveCfg = Release|x64
+ {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.Release|x64.Build.0 = Release|x64
+ {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.Debug|x64.ActiveCfg = Debug|x64
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.Debug|x64.Build.0 = Debug|x64
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.Release|x64.ActiveCfg = Release|x64
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.Release|x64.Build.0 = Release|x64
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.Debug|x64.ActiveCfg = Debug|x64
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.Debug|x64.Build.0 = Debug|x64
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.Release|x64.ActiveCfg = Release|x64
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.Release|x64.Build.0 = Release|x64
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.Debug|x64.ActiveCfg = Debug|x64
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.Debug|x64.Build.0 = Debug|x64
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.Release|x64.ActiveCfg = Release|x64
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.Release|x64.Build.0 = Release|x64
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.Debug|x64.ActiveCfg = Debug|x64
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.Debug|x64.Build.0 = Debug|x64
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.Release|x64.ActiveCfg = Release|x64
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.Release|x64.Build.0 = Release|x64
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.Debug|x64.ActiveCfg = Debug|x64
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.Debug|x64.Build.0 = Debug|x64
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.Release|x64.ActiveCfg = Release|x64
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.Release|x64.Build.0 = Release|x64
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.Debug|x64.ActiveCfg = Debug|x64
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.Debug|x64.Build.0 = Debug|x64
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.Release|x64.ActiveCfg = Release|x64
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.Release|x64.Build.0 = Release|x64
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996}.Debug|x64.ActiveCfg = Debug|x64
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996}.Debug|x64.Build.0 = Debug|x64
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996}.Release|x64.ActiveCfg = Release|x64
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996}.Release|x64.Build.0 = Release|x64
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.Debug|x64.ActiveCfg = Debug|x64
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.Debug|x64.Build.0 = Debug|x64
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.Release|x64.ActiveCfg = Release|x64
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.Release|x64.Build.0 = Release|x64
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E}.Debug|x64.ActiveCfg = Debug|x64
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E}.Debug|x64.Build.0 = Debug|x64
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E}.Release|x64.ActiveCfg = Release|x64
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E}.Release|x64.Build.0 = Release|x64
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.Debug|x64.ActiveCfg = Debug|x64
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.Debug|x64.Build.0 = Debug|x64
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.Release|x64.ActiveCfg = Release|x64
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.Release|x64.Build.0 = Release|x64
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0}.Debug|x64.ActiveCfg = Debug|x64
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0}.Debug|x64.Build.0 = Debug|x64
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0}.Release|x64.ActiveCfg = Release|x64
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0}.Release|x64.Build.0 = Release|x64
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {A4921D15-411F-436A-B6F3-F8381652A8E1}.Debug|x64.ActiveCfg = Debug|x64
+ {A4921D15-411F-436A-B6F3-F8381652A8E1}.Debug|x64.Build.0 = Debug|x64
+ {A4921D15-411F-436A-B6F3-F8381652A8E1}.Release|x64.ActiveCfg = Release|x64
+ {A4921D15-411F-436A-B6F3-F8381652A8E1}.Release|x64.Build.0 = Release|x64
+ {A4921D15-411F-436A-B6F3-F8381652A8E1}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {A4921D15-411F-436A-B6F3-F8381652A8E1}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {A4921D15-411F-436A-B6F3-F8381652A8E1}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {A4921D15-411F-436A-B6F3-F8381652A8E1}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.Debug|x64.ActiveCfg = Debug|x64
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.Debug|x64.Build.0 = Debug|x64
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.Release|x64.ActiveCfg = Release|x64
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.Release|x64.Build.0 = Release|x64
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.Debug|x64.ActiveCfg = Debug|x64
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.Debug|x64.Build.0 = Debug|x64
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.Release|x64.ActiveCfg = Release|x64
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.Release|x64.Build.0 = Release|x64
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.Debug|x64.ActiveCfg = Debug|x64
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.Debug|x64.Build.0 = Debug|x64
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.Release|x64.ActiveCfg = Release|x64
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.Release|x64.Build.0 = Release|x64
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5}.Debug|x64.ActiveCfg = Debug|x64
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5}.Debug|x64.Build.0 = Debug|x64
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5}.Release|x64.ActiveCfg = Release|x64
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5}.Release|x64.Build.0 = Release|x64
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.Debug|x64.ActiveCfg = Debug|x64
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.Debug|x64.Build.0 = Debug|x64
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.Release|x64.ActiveCfg = Release|x64
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.Release|x64.Build.0 = Release|x64
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {F77AD922-B4BC-43D7-B268-865312085495}.Debug|x64.ActiveCfg = Debug|x64
+ {F77AD922-B4BC-43D7-B268-865312085495}.Debug|x64.Build.0 = Debug|x64
+ {F77AD922-B4BC-43D7-B268-865312085495}.Release|x64.ActiveCfg = Release|x64
+ {F77AD922-B4BC-43D7-B268-865312085495}.Release|x64.Build.0 = Release|x64
+ {F77AD922-B4BC-43D7-B268-865312085495}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {F77AD922-B4BC-43D7-B268-865312085495}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {F77AD922-B4BC-43D7-B268-865312085495}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {F77AD922-B4BC-43D7-B268-865312085495}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.Debug|x64.ActiveCfg = Debug|x64
+ {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.Debug|x64.Build.0 = Debug|x64
+ {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.Release|x64.ActiveCfg = Release|x64
+ {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.Release|x64.Build.0 = Release|x64
+ {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {1DFA0599-77CC-4768-B47A-107EEE86C20C}.Debug|x64.ActiveCfg = Debug|x64
+ {1DFA0599-77CC-4768-B47A-107EEE86C20C}.Debug|x64.Build.0 = Debug|x64
+ {1DFA0599-77CC-4768-B47A-107EEE86C20C}.Release|x64.ActiveCfg = Release|x64
+ {1DFA0599-77CC-4768-B47A-107EEE86C20C}.Release|x64.Build.0 = Release|x64
+ {1DFA0599-77CC-4768-B47A-107EEE86C20C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {1DFA0599-77CC-4768-B47A-107EEE86C20C}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {1DFA0599-77CC-4768-B47A-107EEE86C20C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {1DFA0599-77CC-4768-B47A-107EEE86C20C}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.Debug|x64.ActiveCfg = Debug|x64
+ {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.Debug|x64.Build.0 = Debug|x64
+ {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.Release|x64.ActiveCfg = Release|x64
+ {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.Release|x64.Build.0 = Release|x64
+ {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.Debug|x64.ActiveCfg = Debug|x64
+ {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.Debug|x64.Build.0 = Debug|x64
+ {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.Release|x64.ActiveCfg = Release|x64
+ {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.Release|x64.Build.0 = Release|x64
+ {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {02D16A66-6D59-4A0E-ABB3-BD12926934FE}.Debug|x64.ActiveCfg = Debug|x64
+ {02D16A66-6D59-4A0E-ABB3-BD12926934FE}.Release|x64.ActiveCfg = Release|x64
+ {02D16A66-6D59-4A0E-ABB3-BD12926934FE}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {02D16A66-6D59-4A0E-ABB3-BD12926934FE}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {B5A9B8B7-53AC-46D7-9ADE-76F708A7189C}.Debug|x64.ActiveCfg = Debug|x64
+ {B5A9B8B7-53AC-46D7-9ADE-76F708A7189C}.Release|x64.ActiveCfg = Release|x64
+ {B5A9B8B7-53AC-46D7-9ADE-76F708A7189C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {B5A9B8B7-53AC-46D7-9ADE-76F708A7189C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {3B126B2D-DEAA-4CDF-9F44-28D3600F5754} = {31CE49D7-85CA-41E2-83D2-CC6962519DB6}
+ {4C488FF0-7C06-47FE-A8FD-67DAD51A3E85} = {31CE49D7-85CA-41E2-83D2-CC6962519DB6}
+ {D87B08A8-638E-43FA-96C2-404B41363D3B} = {31CE49D7-85CA-41E2-83D2-CC6962519DB6}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {31CE49D7-85CA-41E2-83D2-CC6962519DB6}
+ {E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89} = {BD073C58-BAED-420E-80EA-DC9F52E21AF7}
+ {B28E8445-DFD2-46EA-BA6C-C2A1864F2FB1} = {BD073C58-BAED-420E-80EA-DC9F52E21AF7}
+ {7BAF09E0-DCD4-4567-9486-79E1E5F18333} = {BD073C58-BAED-420E-80EA-DC9F52E21AF7}
+ {D0413FDA-31C5-41C2-A53A-C1B87061EC96} = {BD073C58-BAED-420E-80EA-DC9F52E21AF7}
+ {F77AD922-B4BC-43D7-B268-865312085495} = {8ECAB3CD-B434-426B-B63A-115919D393BC}
+ {B025BD09-8389-4D9F-9150-F33418A664B1} = {964DC7DE-990A-4CA4-8395-10D9F9CB2A23}
+ {0984A63C-130E-4B62-9A94-AAC28A88C137} = {7E002D15-21D1-4927-B486-82E496444441}
+ {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54} = {7E002D15-21D1-4927-B486-82E496444441}
+ {2485E202-B981-41E0-98CA-CF363437A4E4} = {7E002D15-21D1-4927-B486-82E496444441}
+ {0283B293-0067-4D02-ADA6-892704398F48} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
+ {A4921D15-411F-436A-B6F3-F8381652A8E1} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C} = {2485E202-B981-41E0-98CA-CF363437A4E4}
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/Tests/CMakeLib/testXMLParser.cxx b/Tests/CMakeLib/testXMLParser.cxx
new file mode 100644
index 0000000..8617cc1
--- /dev/null
+++ b/Tests/CMakeLib/testXMLParser.cxx
@@ -0,0 +1,16 @@
+#include "testXMLParser.h"
+
+#include <iostream>
+
+#include "cmXMLParser.h"
+
+int testXMLParser(int /*unused*/, char* /*unused*/ [])
+{
+ // TODO: Derive from parser and check attributes.
+ cmXMLParser parser;
+ if (!parser.ParseFile(SOURCE_DIR "/testXMLParser.xml")) {
+ std::cerr << "cmXMLParser failed!" << std::endl;
+ return 1;
+ }
+ return 0;
+}
diff --git a/Tests/CMakeLib/testXMLParser.h.in b/Tests/CMakeLib/testXMLParser.h.in
new file mode 100644
index 0000000..da0b275
--- /dev/null
+++ b/Tests/CMakeLib/testXMLParser.h.in
@@ -0,0 +1,6 @@
+#ifndef testXMLParser_h
+#define testXMLParser_h
+
+#define SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@"
+
+#endif
diff --git a/Tests/CMakeLib/testXMLParser.xml b/Tests/CMakeLib/testXMLParser.xml
new file mode 100644
index 0000000..5a13f07
--- /dev/null
+++ b/Tests/CMakeLib/testXMLParser.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Document>
+ <Element attr="1"/>
+</Document>
diff --git a/Tests/CMakeLib/testXMLSafe.cxx b/Tests/CMakeLib/testXMLSafe.cxx
new file mode 100644
index 0000000..dc62eb9
--- /dev/null
+++ b/Tests/CMakeLib/testXMLSafe.cxx
@@ -0,0 +1,42 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <sstream>
+#include <string>
+
+#include <stdio.h>
+
+#include "cmXMLSafe.h"
+
+struct test_pair
+{
+ const char* in;
+ const char* out;
+};
+
+static test_pair const pairs[] = {
+ { "copyright \xC2\xA9", "copyright \xC2\xA9" },
+ { "form-feed \f", "form-feed [NON-XML-CHAR-0xC]" },
+ { "angles <>", "angles &lt;&gt;" },
+ { "ampersand &", "ampersand &amp;" },
+ { "bad-byte \x80", "bad-byte [NON-UTF-8-BYTE-0x80]" },
+ { nullptr, nullptr }
+};
+
+int testXMLSafe(int /*unused*/, char* /*unused*/ [])
+{
+ int result = 0;
+ for (test_pair const* p = pairs; p->in; ++p) {
+ cmXMLSafe xs(p->in);
+ std::ostringstream oss;
+ oss << xs;
+ std::string out = oss.str();
+ if (out != p->out) {
+ printf("expected [%s], got [%s]\n", p->out, out.c_str());
+ result = 1;
+ }
+ }
+ return result;
+}