diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4bf04d7..22ee695 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,6 +37,7 @@ jobs: generator: "" build_args: "--config Release" exe_path: build/bin/Release/ASWIniTests.exe + gui_exe_path: build/bin/Release/ASWIniTests_Win32_GUI.exe # cl takes -MP as well as /MP; Git Bash would turn "/MP" into a path when it starts CMake. cxxflags: -MP # A multi-config generator, so the package check builds and installs both into the same prefix (the Debug @@ -48,6 +49,7 @@ jobs: generator: "MinGW Makefiles" build_args: "" exe_path: build/bin/ASWIniTests.exe + gui_exe_path: build/bin/ASWIniTests_Win32_GUI.exe sanitize: "" - name: Linux (GCC) os: ubuntu-latest @@ -183,6 +185,54 @@ jobs: path: junit-results.xml if-no-files-found: error + - name: Run unit tests in the Win32 GUI + # Windows jobs only: the Win32 GUI runner (tests/cmake builds it on Windows) opens its window, runs every test + # (--run), writes the same JUnit report as the console runner, then closes and exits with the console runner's + # exit code (--exit). Bash waits for a GUI program to end, unlike a Windows command prompt. The step's own + # timeout ends a GUI left waiting on a dialog that nobody can close, rather than leaving it to the job's. + if: matrix.gui_exe_path != '' + id: gui_tests + timeout-minutes: 3 + shell: bash + run: | + if [ ! -f "${{ matrix.gui_exe_path }}" ]; then + echo "ERROR: Executable not found at ${{ matrix.gui_exe_path }}" + exit 1 + fi + ./${{ matrix.gui_exe_path }} --project-name "ASWIni-CI-Win32GUI" --run --exit --layout-ignore \ + --report-junit gui-results.xml --test-timeout-seconds 60 --catch-crashes + + - name: Check the Win32 GUI's report + # The GUI ran the same tests as the console runner, so both reports list the same number. + if: matrix.gui_exe_path != '' + shell: bash + run: | + console=$(grep -o '`, the tests of `ASWIni_`) and shared test helpers (`UT_Helper_`) in `tests/tests/`, their CMake project in `tests/cmake/`, their RAD Studio console project in `tests/rad370/`, and their RAD Studio VCL GUI runner project in `tests/vcl/gui/rad370/` (built from the submodule's `vcl/gui/src`). `tests/package/` is a project that builds against an installed ASWIni with `find_package` (CI installs the library and runs it). +- `tests/` contains the unit tests: test modules (`Test_ASWIni_`, the tests of `ASWIni_`) and shared test helpers (`UT_Helper_`) in `tests/tests/`, their CMake project in `tests/cmake/` (the console runner, and on Windows also the Win32 GUI runner), their RAD Studio console project in `tests/rad370/`, their RAD Studio VCL GUI runner project in `tests/vcl/gui/rad370/` (built from the submodule's `gui/src` and `vcl/gui/src`), and their RAD Studio Win32 GUI runner project in `tests/win32/gui/rad370/` (built from the submodule's `gui/src` and `win32/gui/src`). `tests/package/` is a project that builds against an installed ASWIni with `find_package` (CI installs the library and runs it). - `example/` contains the example program, one portable file (`example/src/main.cpp`) that returns 0 only when every step did what it shows, its CMake project in `example/cmake/` (also built by the root project with `ASWINI_BUILD_EXAMPLE`), and its RAD Studio project for Win32 and Win64x in `example/rad370/`, which lists the library's sources. - `docs/` contains the documentation for application developers: `Format.md`, `Options.md`, `Settings.md` and `Guarantees.md`. Keep them in line with the code, and compile each snippet in them (the README's quick start too) when it is written or changed. - `CMakeLists.txt` (the root) defines the `ASWIni::ASWIni` library target and its install rules; `cmake/ASWIniConfig.cmake.in` is the template of the installed package file. The project version is read from `ASWIni/ASWIni_Version.h`. - `third_party/asw-unit-tests/` is the ASWUnitTests framework, a git submodule pinned to a release tag. Never edit files in it. -- `.github/workflows/ci.yml` builds and runs the unit tests on Windows (MSVC, MinGW) and Linux (GCC, Clang) at C++20, on Linux GCC at C++17, plus Linux Clang builds with ThreadSanitizer and with AddressSanitizer + UBSan (`ASWINI_SANITIZE`); every job also builds and runs the example, and the non-sanitizer jobs check the installed CMake package (`tests/package/`). A Linux GCC coverage job (informational, it never fails the run) shows the library's line coverage on its summary page and uploads an HTML report. +- `.github/workflows/ci.yml` builds and runs the unit tests on Windows (MSVC, MinGW) and Linux (GCC, Clang) at C++20, on Linux GCC at C++17, plus Linux Clang builds with ThreadSanitizer and with AddressSanitizer + UBSan (`ASWINI_SANITIZE`); every job also builds and runs the example, the non-sanitizer jobs check the installed CMake package (`tests/package/`), and the Windows jobs also run the tests in the Win32 GUI runner. A Linux GCC coverage job (informational, it never fails the run) shows the library's line coverage on its summary page and uploads an HTML report. - `Deploy.bat` copies the library sources, build files, docs and example to a folder; it lists every file explicitly. - `README.md` contains repo details: features, quick start, project setup, API overview, links to the docs, versions and tests. - `CHANGELOG.md` records notable changes per release (see Changelog below). @@ -78,9 +78,9 @@ The unit tests use the ASWUnitTests framework from the `third_party/asw-unit-tes - Each test group derives from `TAutoTestGroup`, is named `"ASWIni__Tests"` (or `"ASWIni__Tests"` for one of several groups of a unit, e.g. `"ASWIni_ReadingOptions_Tests"`) in its constructor, and defines each test with `ASW_TEST(ClassName, TestName)` in the group's `.cpp`, declared as a public `void Test_TestName();` in its header (in a `public: // Test methods, each defined with ASW_TEST` section, alphabetical), with no `RegisterTest()` call. Use `Test_ASWIni_Version.cpp/h` as the template. - Pass `__func__, __LINE__` to every check (e.g. `CheckEquals(expected, actual, __func__, __LINE__, "message")`). bcc32c has no `std::source_location`, so the overloads without them don't exist in its build. -- When a unit's tests are clearer as several groups (e.g. one per struct, as in `Test_ASWIni_Options`), keep them in the unit's one `.cpp`/`.h`, each class with its own banner, and register each with `ASW_REGISTER_TEST_GROUP_IN_SUITE(ClassName, "")`, so `--filter ".*"` runs them all and the GUI runner shows them under one node. A unit with one group isn't put in a suite. +- When a unit's tests are clearer as several groups (e.g. one per struct, as in `Test_ASWIni_Options`), keep them in the unit's one `.cpp`/`.h`, each class with its own banner, and register each with `ASW_REGISTER_TEST_GROUP_IN_SUITE(ClassName, "")`, so `--filter ".*"` runs them all and the GUI runners show them under one node. A unit with one group isn't put in a suite. - Structure a test with `// Arrange`, `// Act` and `// Assert` comments, each on its own line (combined as `// Act & Assert` or `// Arrange & Act & Assert` when the steps are interleaved), with any explanation on the line after the comment, and write each check's message as what should be true. -- When adding a test module or a test helper, add its `.cpp`/`.h` to `tests/cmake/CMakeLists.txt`, `tests/rad370/ASWIniTests.cbproj`, and `tests/vcl/gui/rad370/ASWIniTests_VCL_GUI.cbproj`, and keep their include paths in sync. When adding a library source file, add it to the root `CMakeLists.txt`, both RAD Studio test projects, the RAD Studio example project (`example/rad370/ASWIniExample.cbproj`), and `Deploy.bat`. +- When adding a test module or a test helper, add its `.cpp`/`.h` to `tests/cmake/CMakeLists.txt` (its `ASWINI_TEST_SOURCES` list, compiled once for both CMake runners), `tests/rad370/ASWIniTests.cbproj`, `tests/vcl/gui/rad370/ASWIniTests_VCL_GUI.cbproj`, and `tests/win32/gui/rad370/ASWIniTests_Win32_GUI.cbproj`, and keep their include paths in sync. When adding a library source file, add it to the root `CMakeLists.txt`, the three RAD Studio test projects, the RAD Studio example project (`example/rad370/ASWIniExample.cbproj`), and `Deploy.bat`. - Never open the GUI's main form (`ASWUnitTests_GUI_MainForm`) in the RAD Studio designer and save it, since that writes into the submodule. ## Building and Testing @@ -92,9 +92,9 @@ cmake -S tests/cmake -B tests/cmake/build cmake --build tests/cmake/build --config Release ``` -and with `-DASWINI_CXX_STANDARD=17` in a second build folder for a C++17 build. The executable is written to `tests/cmake/build/bin` (in a `Release` sub folder for multi-config generators). +and with `-DASWINI_CXX_STANDARD=17` in a second build folder for a C++17 build. The executable is written to `tests/cmake/build/bin` (in a `Release` sub folder for multi-config generators); on Windows, the Win32 GUI runner, `ASWIniTests_Win32_GUI.exe`, is written next to it. -The RAD Studio scripts need the `Rad370` environment variable to point to the RAD Studio installation: `tests/rad370/Build_Win32_Debug.bat`, `Build_Win32_Release.bat`, `Build_Win64x_Debug.bat` and `Build_Win64x_Release.bat` build the console tests into `tests/build/bin///`. The Debug configurations pass `--pause` when run from the IDE. The VCL GUI runner builds with the scripts of the same names in `tests/vcl/gui/rad370/` into the same output folders. To run every test in it without interaction, use `start /wait ASWIniTests_VCL_GUI.exe --run --exit --layout-ignore --report-junit results.xml`; its exit code matches the console runner's. +The RAD Studio scripts need the `Rad370` environment variable to point to the RAD Studio installation: `tests/rad370/Build_Win32_Debug.bat`, `Build_Win32_Release.bat`, `Build_Win64x_Debug.bat` and `Build_Win64x_Release.bat` build the console tests into `tests/build/bin///`. The Debug configurations pass `--pause` when run from the IDE. The VCL GUI runner builds with the scripts of the same names in `tests/vcl/gui/rad370/`, and the Win32 GUI runner with those in `tests/win32/gui/rad370/`, into the same output folders. To run every test in a GUI runner without interaction, use e.g. `start /wait ASWIniTests_VCL_GUI.exe --run --exit --layout-ignore --report-junit results.xml`; its exit code matches the console runner's. Tests should be run outside the debugger unless debugging an expected exception is intentional. Before considering a change complete: diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f6fc8c..2bec7e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added + +- Win32 GUI test runner, the ASWUnitTests 1.5.0 GUI runner built on the Windows API alone: on + Windows, the CMake test build also makes `ASWIniTests_Win32_GUI.exe`, next to `ASWIniTests.exe`, + and `tests/win32/gui/rad370/ASWIniTests_Win32_GUI.cbproj` builds it with RAD Studio for Win32 and + Win64x. CI's Windows jobs run the tests in it too. Both GUI runners have ASWUnitTests 1.5.0's + light and dark themes, and every test runner has the ASWUnitTests icon. + ## [1.0.0] - 2026-10-21 The first release. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dff8ff4..2855066 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,9 +26,10 @@ depends only on the C++ standard library and the operating system's APIs; third- 3. Add or update focused tests in `tests/tests/` for the behavior change, including error and platform-specific cases where applicable. Define a new test with `ASW_TEST(ClassName, TestName)` and declare its `Test_TestName()` method public in the group's header; it registers itself. A new - test file goes into `tests/cmake/CMakeLists.txt`, `tests/rad370/ASWIniTests.cbproj`, and - `tests/vcl/gui/rad370/ASWIniTests_VCL_GUI.cbproj`. A new library source file goes into the root - `CMakeLists.txt`, the RAD Studio test projects, the RAD Studio example project + test file goes into `tests/cmake/CMakeLists.txt`, `tests/rad370/ASWIniTests.cbproj`, + `tests/vcl/gui/rad370/ASWIniTests_VCL_GUI.cbproj`, and + `tests/win32/gui/rad370/ASWIniTests_Win32_GUI.cbproj`. A new library source file goes into the + root `CMakeLists.txt`, the RAD Studio test projects, the RAD Studio example project (`example/rad370/ASWIniExample.cbproj`), and `Deploy.bat`. 4. Build the affected configuration and run the unit-test executable, at C++17 and at C++20. See [README.md](README.md#unit-tests) for the CMake build commands, and the `Build_Win32_*.bat` @@ -37,9 +38,9 @@ depends only on the C++ standard library and the operating system's APIs; third- 6. If you touched platform-specific code (`#if defined(_WIN32)` or similar), validate both the Windows and the portable path if you can. CI builds and runs the tests on Windows (MSVC, MinGW) and Linux (GCC, Clang, and GCC at C++17), plus Linux builds with ThreadSanitizer and with - AddressSanitizer + UBSan, and runs the example program (`example/`) in each of them; a pull - request should pass all of them. [README.md](README.md#unit-tests) shows how to run a sanitizer - build yourself. + AddressSanitizer + UBSan, and runs the example program (`example/`) in each of them, and the + tests in the Win32 GUI runner on Windows; a pull request should pass all of them. + [README.md](README.md#unit-tests) shows how to run a sanitizer build yourself. 7. Keep `.cpp` and `.h` files ASCII-only. MSVC reads a source file without a BOM in the system's code page, so other characters can change meaning. In tests, write non-ASCII text with escapes (e.g. `"\xCE\xBB"` for UTF-8 bytes, or `L"\x03BB"` for a Windows path). diff --git a/README.md b/README.md index 208c200..163cb3c 100644 --- a/README.md +++ b/README.md @@ -340,13 +340,22 @@ CI also measures which lines of the library the tests run (a Linux GCC build wit by gcovr): the "Linux (GCC, coverage)" job shows a table on its summary page and keeps an HTML report as the `coverage-report` artifact. It is informational and never fails the run. -On Windows with RAD Studio, the tests can also run in the ASWUnitTests VCL GUI runner, a window for -choosing tests and reading their results: build `tests/vcl/gui/rad370/ASWIniTests_VCL_GUI.cbproj` -(or its `Build_*.bat` scripts), which writes `ASWIniTests_VCL_GUI.exe` to -`tests/build/bin//`. `ASWIniTests_Group.groupproj` in the same folder opens it -together with the console test project. The GUI takes the console runner's command line options -plus a few of its own, e.g. `--run --exit` to run every test and exit with the console runner's exit -code; see the ASWUnitTests README's "VCL GUI Runner" section. +On Windows, the tests can also run in an ASWUnitTests GUI runner, a window for choosing tests and +reading their results, with a light and a dark theme (**View > Theme**). The GUI runners take the +console runner's command line options plus a few of their own, e.g. `--run --exit` to run every test +and exit with the console runner's exit code; see the ASWUnitTests README's "GUI Runners" section. + +- The Win32 GUI runner uses only the Windows API. The CMake build makes it on Windows as + `ASWIniTests_Win32_GUI.exe`, next to the console runner, and CI runs it in the Windows jobs. For + RAD Studio, use `tests/win32/gui/rad370/ASWIniTests_Win32_GUI.cbproj` or its `Build_*.bat` + scripts. +- The VCL GUI runner needs RAD Studio: use `tests/vcl/gui/rad370/ASWIniTests_VCL_GUI.cbproj` or its + `Build_*.bat` scripts. + +Like the console tests, the RAD Studio builds of both GUI runners are for Win32 (C++17) and Win64x +(C++20), and write `ASWIniTests_Win32_GUI.exe` and `ASWIniTests_VCL_GUI.exe` to +`tests/build/bin//`. `tests/vcl/gui/rad370/ASWIniTests_Group.groupproj` opens both +GUI projects together with the console test project. # Coding Standards diff --git a/tests/cmake/CMakeLists.txt b/tests/cmake/CMakeLists.txt index d499f81..ca90a73 100644 --- a/tests/cmake/CMakeLists.txt +++ b/tests/cmake/CMakeLists.txt @@ -38,8 +38,9 @@ if(NOT TARGET ASWIni::ASWIni) add_subdirectory("${ASWINI_ROOT}" aswini) endif() -add_executable(ASWIniTests - ${ASWUNITTESTS_SOURCES} +# The test modules and helpers, which both the console runner and, on Windows, the Win32 GUI runner run (see +# ASWIniTestObjects below). +set(ASWINI_TEST_SOURCES "${ASWINI_TESTS_DIR}/Test_ASWIni_Base.cpp" "${ASWINI_TESTS_DIR}/Test_ASWIni_Converters.cpp" "${ASWINI_TESTS_DIR}/Test_ASWIni_Document.cpp" @@ -56,30 +57,67 @@ add_executable(ASWIniTests "${ASWINI_TESTS_DIR}/UT_Helper_Threads.cpp" ) -target_include_directories(ASWIniTests PRIVATE +# ASWUnitTests' --test-timeout-seconds uses std::thread/std::future, which needs an explicit threading library on +# Linux and some MinGW-w64 distributions. +find_package(Threads REQUIRED) + +# The warnings the tests and the test runners compile with. +function(aswini_set_test_warnings target) + if(MSVC) + target_compile_options(${target} PRIVATE /W4 /Zc:__cplusplus) + else() + target_compile_options(${target} PRIVATE -Wall -Wextra -Wpedantic) + endif() +endfunction() + +# The tests, compiled once for both test runners. An object library, whose object files are all linked into each +# runner, rather than a static library, from which a linker only takes the object files something refers to: nothing +# refers to a test module, since each registers itself, so every test would be left out. +add_library(ASWIniTestObjects OBJECT ${ASWINI_TEST_SOURCES}) + +target_include_directories(ASWIniTestObjects PRIVATE "${ASWUNITTESTS_SOURCE_DIR}" "${ASWINI_TESTS_DIR}" ) -target_link_libraries(ASWIniTests PRIVATE ASWIni::ASWIni) +# PUBLIC, so the runners link them too, and compile their own sources with ASWIni's options (ASWINI_SANITIZE's). +target_link_libraries(ASWIniTestObjects PUBLIC ASWIni::ASWIni Threads::Threads) +aswini_set_test_warnings(ASWIniTestObjects) -# ASWUnitTests' --test-timeout-seconds uses std::thread/std::future, which needs an explicit threading library on -# Linux and some MinGW-w64 distributions. -find_package(Threads REQUIRED) -target_link_libraries(ASWIniTests PRIVATE Threads::Threads) +# The settings both test runners share. +function(aswini_configure_test_runner target) + target_link_libraries(${target} PRIVATE ASWIniTestObjects) + aswini_set_test_warnings(${target}) -if(MSVC) - target_compile_options(ASWIniTests PRIVATE /W4 /Zc:__cplusplus) -else() - target_compile_options(ASWIniTests PRIVATE -Wall -Wextra -Wpedantic) -endif() + if(MINGW) + # Statically link the MinGW runtime so the executable launches without MinGW's bin directory on PATH (e.g. on + # a CI runner). + target_link_options(${target} PRIVATE -static-libgcc -static-libstdc++ -static) + endif() -if(MINGW) - # Statically link the MinGW runtime so the executable launches without MinGW's bin directory on PATH (e.g. on a - # CI runner). - target_link_options(ASWIniTests PRIVATE -static-libgcc -static-libstdc++ -static) -endif() + set_target_properties(${target} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" + ) +endfunction() -set_target_properties(ASWIniTests PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" -) +add_executable(ASWIniTests ${ASWUNITTESTS_SOURCES}) + +target_include_directories(ASWIniTests PRIVATE "${ASWUNITTESTS_SOURCE_DIR}") +aswini_configure_test_runner(ASWIniTests) + +if(WIN32) + # The ASWUnitTests icon, which the resource compiler finds through the include path. + target_sources(ASWIniTests PRIVATE "${ASWUNITTESTS_ROOT}/resource/ASWUnitTests_Icon.rc") + target_include_directories(ASWIniTests PRIVATE "${ASWUNITTESTS_ROOT}/resource") + + # The Win32 GUI runner: the same tests in a window. Its WinMain takes the place of the console runner's main.cpp, + # and its sources list has the icon. + include("${ASWUNITTESTS_ROOT}/win32/gui/src/ASWUnitTests_Win32GUI_Sources.cmake") + + add_executable(ASWIniTests_Win32_GUI WIN32 ${ASWUNITTESTS_WIN32_GUI_SOURCES}) + + target_include_directories(ASWIniTests_Win32_GUI PRIVATE ${ASWUNITTESTS_WIN32_GUI_INCLUDE_DIRS}) + target_link_libraries(ASWIniTests_Win32_GUI PRIVATE ${ASWUNITTESTS_WIN32_GUI_LIBRARIES}) + target_link_options(ASWIniTests_Win32_GUI PRIVATE ${ASWUNITTESTS_WIN32_GUI_LINK_OPTIONS}) + aswini_configure_test_runner(ASWIniTests_Win32_GUI) +endif() diff --git a/tests/rad370/ASWIniTests.cbproj b/tests/rad370/ASWIniTests.cbproj index 96779ba..8924546 100644 --- a/tests/rad370/ASWIniTests.cbproj +++ b/tests/rad370/ASWIniTests.cbproj @@ -65,6 +65,7 @@ true $(BDSLIB)\$(PLATFORM)\release\$(LANGDIR);$(ILINK_TranslatedLibraryPath) CppConsoleApplication + ..\..\third_party\asw-unit-tests\resource\ASWUnitTests.ico System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) true ASWIniTests diff --git a/tests/tests/Test_ASWIni_Base.cpp b/tests/tests/Test_ASWIni_Base.cpp index e2b7070..22c96ea 100644 --- a/tests/tests/Test_ASWIni_Base.cpp +++ b/tests/tests/Test_ASWIni_Base.cpp @@ -368,7 +368,7 @@ ASW_TEST(TTest_ASWIni_BaseAccess, Edits_FailureChangesNothing) CheckEquals(EIniCode::InvalidArgument, setText.Code, __func__, __LINE__, "an invalid key should fail"); CheckEquals(EIniCode::InvalidArgument, addSection.Code, __func__, __LINE__, "an invalid section name should fail"); CheckEquals(EIniCode::NotFound, sectionComment.Code, __func__, __LINE__, "a missing section should fail"); - CheckEquals(std::string(SampleText), ini.ToText(), __func__, __LINE__, "the text should be unchanged"); + CheckEquals(SampleText, ini.ToText(), __func__, __LINE__, "the text should be unchanged"); CheckFalse(ini.IsModified(), __func__, __LINE__, "the object shouldn't be modified"); } //--------------------------------------------------------------------------- @@ -433,7 +433,7 @@ ASW_TEST(TTest_ASWIni_BaseAccess, GetDocument_IsACopy) "the copy should have the document's lines"); std::string width; CheckTrue(ini.TryGetText("Window", "Width", width), __func__, __LINE__, "the key should exist"); - CheckEquals(std::string("640"), width, __func__, __LINE__, "editing the copy shouldn't change the object"); + CheckEquals("640", width, __func__, __LINE__, "editing the copy shouldn't change the object"); CheckFalse(ini.IsModified(), __func__, __LINE__, "the object shouldn't be modified"); } //--------------------------------------------------------------------------- @@ -472,7 +472,7 @@ ASW_TEST(TTest_ASWIni_BaseAccess, LoadText_ReplacesTheDocument) // Assert CheckTrue(result.IsOk(), __func__, __LINE__, "the text should be loaded"); - CheckEquals(std::string(SampleText), ini.ToText(), __func__, __LINE__, "the text should be written back as it is"); + CheckEquals(SampleText, ini.ToText(), __func__, __LINE__, "the text should be written back as it is"); CheckFalse(ini.HasSection("Old"), __func__, __LINE__, "the old document should be gone"); CheckFalse(ini.IsModified(), __func__, __LINE__, "a loaded document shouldn't be modified"); CheckEquals(std::string(), ini.GetFilePath(), __func__, __LINE__, "there should still be no file path"); @@ -499,7 +499,7 @@ ASW_TEST(TTest_ASWIni_BaseAccess, LoadText_UsesTheOptions) // Assert std::string name; CheckTrue(ini.TryGetText("General", "Name", name), __func__, __LINE__, "the key should exist"); - CheckEquals(std::string("My App"), name, __func__, __LINE__, "the text should be read with the object's options"); + CheckEquals("My App", name, __func__, __LINE__, "the text should be read with the object's options"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_BaseAccess, Locks_WorkLikeStandardMutexes) @@ -606,14 +606,14 @@ ASW_TEST(TTest_ASWIni_BaseAccess, Lookups_MatchTheDocument) "the section names with a prefix should be the document's"); CheckEquals(document.GetFileComment(), ini.GetFileComment(), __func__, __LINE__, "the file comment should be the document's"); - CheckEquals(std::string("The main window"), ini.GetSectionComment("Window"), __func__, __LINE__, + CheckEquals("The main window", ini.GetSectionComment("Window"), __func__, __LINE__, "the section comment should be the document's"); - CheckEquals(std::string("In pixels"), ini.GetKeyComment("Window", "Height"), __func__, __LINE__, + CheckEquals("In pixels", ini.GetKeyComment("Window", "Height"), __func__, __LINE__, "the key comment should be the document's"); CheckFalse(ini.TryGetText("Window", "Depth", text), __func__, __LINE__, "a missing key should have no text"); - CheckEquals(std::string("unchanged"), text, __func__, __LINE__, "the text should stay as it was"); + CheckEquals("unchanged", text, __func__, __LINE__, "the text should stay as it was"); CheckTrue(ini.TryGetText("General", "Name", text), __func__, __LINE__, "the key should have a text"); - CheckEquals(std::string("My App ; not a comment"), text, __func__, __LINE__, "the text should be the value's"); + CheckEquals("My App ; not a comment", text, __func__, __LINE__, "the text should be the value's"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_BaseAccess, New_IsEmptyWithTheDefaultOptions) @@ -634,7 +634,7 @@ ASW_TEST(TTest_ASWIni_BaseAccess, New_IsEmptyWithTheDefaultOptions) "the options should be the defaults"); CheckTrue(ini.GetValueOptions().BoolFormat == EBoolFormat::TrueFalse, __func__, __LINE__, "the value options should be the defaults"); - CheckEquals(std::string(ASWIni::Version), std::string(ini.GetVersionStr()), __func__, __LINE__, + CheckEquals(ASWIni::Version, std::string(ini.GetVersionStr()), __func__, __LINE__, "the version should be the library's"); } //--------------------------------------------------------------------------- @@ -673,9 +673,9 @@ ASW_TEST(TTest_ASWIni_BaseAccess, OutOfMemory_EditChangesNothing) CheckTrue(failed, __func__, __LINE__, "the edit should only fail when an allocation fails" + which); CheckEquals(EIniCode::UnexpectedException, result.Code, __func__, __LINE__, "a failed allocation should be UnexpectedException" + which); - CheckStartsWith(result.Message, std::string("An unexpected exception was thrown: "), __func__, __LINE__, + CheckStartsWith(result.Message, "An unexpected exception was thrown: ", __func__, __LINE__, "the message should say what was thrown" + which); - CheckEquals(std::string(SampleText), ini.ToText(), __func__, __LINE__, + CheckEquals(SampleText, ini.ToText(), __func__, __LINE__, "a failed edit should change nothing" + which); CheckFalse(ini.IsModified(), __func__, __LINE__, "a failed edit shouldn't set the modified flag" + which); } @@ -713,7 +713,7 @@ ASW_TEST(TTest_ASWIni_BaseAccess, OutOfMemory_LoadTextChangesNothing) if (result.IsOk()) { - CheckEquals(std::string(SampleText), ini.ToText(), __func__, __LINE__, + CheckEquals(SampleText, ini.ToText(), __func__, __LINE__, "a load that succeeded should have loaded the text" + which); CheckFalse(ini.IsModified(), __func__, __LINE__, "a loaded document shouldn't be modified" + which); } @@ -774,7 +774,7 @@ ASW_TEST(TTest_ASWIni_BaseAccess, OutOfMemory_SetOptionsChangesNothing) "a failed allocation should be UnexpectedException" + which); CheckFalse(ini.GetOptions().Reading.InlineComments, __func__, __LINE__, "a failed SetOptions() should keep the options" + which); - CheckEquals(std::string("My App ; not a comment"), name, __func__, __LINE__, + CheckEquals("My App ; not a comment", name, __func__, __LINE__, "a failed SetOptions() should keep the lines as they were read" + which); } @@ -824,7 +824,7 @@ ASW_TEST(TTest_ASWIni_BaseAccess, SetOptions_InvalidOptionsChangeNothing) CheckEquals(TASWIniOptions().Reading.Separators, ini.GetOptions().Reading.Separators, __func__, __LINE__, "the options should be unchanged"); CheckFalse(ini.GetOptions().Reading.InlineComments, __func__, __LINE__, "the options should be unchanged"); - CheckEquals(std::string(SampleText), ini.ToText(), __func__, __LINE__, "the text should be unchanged"); + CheckEquals(SampleText, ini.ToText(), __func__, __LINE__, "the text should be unchanged"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_BaseAccess, SetOptions_ReadsTheTextAgain) @@ -848,7 +848,7 @@ ASW_TEST(TTest_ASWIni_BaseAccess, SetOptions_ReadsTheTextAgain) CheckTrue(ini.GetValueOptions().BoolFormat == EBoolFormat::YesNo, __func__, __LINE__, "the value options should be the new ones"); CheckTrue(ini.TryGetText("General", "Name", name), __func__, __LINE__, "the key should exist"); - CheckEquals(std::string("My App"), name, __func__, __LINE__, "the text should be read again with the new options"); + CheckEquals("My App", name, __func__, __LINE__, "the text should be read again with the new options"); CheckEquals(before, ini.ToText(), __func__, __LINE__, "the text should be unchanged"); CheckTrue(ini.IsModified(), __func__, __LINE__, "the modified flag should be kept"); } @@ -967,10 +967,10 @@ ASW_TEST(TTest_ASWIni_BaseCallback, Callback_MayCallTheObject) CheckEquals(std::size_t(5), seen.size(), __func__, __LINE__, "the callback should have run three times"); if (seen.size() == 5) { - CheckEquals(std::string("1"), seen[1], __func__, __LINE__, "the callback should see the loaded document"); + CheckEquals("1", seen[1], __func__, __LINE__, "the callback should see the loaded document"); CheckEquals(seen[0], seen[2], __func__, __LINE__, "the callback's SetOptions() should report the warning again, inside the callback"); - CheckContains(seen[3], std::string("[Callback]"), __func__, __LINE__, + CheckContains(seen[3], "[Callback]", __func__, __LINE__, "the callback's edit should be in the document"); CheckEquals(failed.Message, seen[4], __func__, __LINE__, "the failed rename should be reported"); } @@ -1054,7 +1054,7 @@ ASW_TEST(TTest_ASWIni_BaseCallback, Callback_MayLoadAndSave) CheckEquals(std::size_t(4), messagesOfSave, __func__, __LINE__, "Save() should report its warning, and the callback's Load() the file's three"); CheckTrue(ReadTestFile(file, contents), __func__, __LINE__, "the file should be readable"); - CheckEquals(std::string(WarningsText), contents, __func__, __LINE__, "the saves should write the text as it was"); + CheckEquals(WarningsText, contents, __func__, __LINE__, "the saves should write the text as it was"); CheckFalse(ini.IsModified(), __func__, __LINE__, "the loaded document shouldn't be modified"); } //--------------------------------------------------------------------------- @@ -1129,9 +1129,9 @@ ASW_TEST(TTest_ASWIni_BaseCallback, GetValue_WarningIsReported) { CheckEquals(ESeverity::Warning, messages[0].Severity, __func__, __LINE__, "the message should be a Warning"); CheckEquals(EIniCode::InvalidValue, messages[0].Code, __func__, __LINE__, "the message should be InvalidValue"); - CheckEquals(std::string("Window.Tools"), messages[0].Section, __func__, __LINE__, + CheckEquals("Window.Tools", messages[0].Section, __func__, __LINE__, "the message should name the section"); - CheckEquals(std::string("Visible"), messages[0].Key, __func__, __LINE__, "the message should name the key"); + CheckEquals("Visible", messages[0].Key, __func__, __LINE__, "the message should name the key"); } } //--------------------------------------------------------------------------- @@ -1411,7 +1411,7 @@ ASW_TEST(TTest_ASWIni_BaseFile, FileOperations_DontOverlap) CheckTrue(loaded.IsOk() && saved.IsOk(), __func__, __LINE__, "the file should be loaded and saved"); CheckTrue(saveWaited, __func__, __LINE__, "a save should wait for a load to finish"); CheckTrue(loadWaited, __func__, __LINE__, "a load should wait for a save to finish"); - CheckEquals(std::string("app.ini"), ini.GetFilePath(), __func__, __LINE__, "the file path should be set"); + CheckEquals("app.ini", ini.GetFilePath(), __func__, __LINE__, "the file path should be set"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_BaseFile, Load_FileErrorsChangeNothing) @@ -1556,7 +1556,7 @@ ASW_TEST(TTest_ASWIni_BaseFile, Load_ReadsTheFile) // Assert CheckTrue(result.IsOk(), __func__, __LINE__, "the file should be loaded: " + result.Message); CheckEquals(std::string(), result.FilePath, __func__, __LINE__, "a result that is Ok should be only that"); - CheckEquals(std::string(WarningsText), ini.ToText(), __func__, __LINE__, + CheckEquals(WarningsText, ini.ToText(), __func__, __LINE__, "the document should have the file's text"); CheckFalse(ini.IsModified(), __func__, __LINE__, "a loaded document shouldn't be modified"); CheckEquals(path, ini.GetFilePath(), __func__, __LINE__, "the file path should be the path as it was given"); @@ -1598,10 +1598,10 @@ ASW_TEST(TTest_ASWIni_BaseFile, Load_ReadsWithoutTheLock) // Assert CheckTrue(result.IsOk(), __func__, __LINE__, "the file should be loaded: " + result.Message); - CheckEquals(std::string("640"), widthDuringLoad, __func__, __LINE__, + CheckEquals("640", widthDuringLoad, __func__, __LINE__, "a lookup during the load should see the old document"); CheckTrue(editDuringLoad.IsOk(), __func__, __LINE__, "an edit during the load should succeed"); - CheckEquals(std::string("[Loaded]\nKey = 1\n"), ini.ToText(), __func__, __LINE__, + CheckEquals("[Loaded]\nKey = 1\n", ini.ToText(), __func__, __LINE__, "the loaded file should replace the edited document"); CheckFalse(ini.IsModified(), __func__, __LINE__, "a loaded document shouldn't be modified"); } @@ -1638,7 +1638,7 @@ ASW_TEST(TTest_ASWIni_BaseFile, OutOfMemory_LoadChangesNothing) if (result.IsOk()) { - CheckEquals(std::string(SampleText), ini.ToText(), __func__, __LINE__, + CheckEquals(SampleText, ini.ToText(), __func__, __LINE__, "a load that succeeded should have loaded the file" + which); CheckEquals(path, ini.GetFilePath(), __func__, __LINE__, "a load that succeeded should set the file path" + which); @@ -1707,7 +1707,7 @@ ASW_TEST(TTest_ASWIni_BaseFile, OutOfMemory_SaveChangesNothing) CheckTrue(failed, __func__, __LINE__, "the save should only fail when an allocation fails" + which); CheckEquals(EIniCode::UnexpectedException, result.Code, __func__, __LINE__, "a failed allocation should be UnexpectedException" + which); - CheckEquals(std::string(SampleText), contents, __func__, __LINE__, + CheckEquals(SampleText, contents, __func__, __LINE__, "a failed save should leave the file as it was" + which); CheckTrue(ini.IsModified(), __func__, __LINE__, "a failed save should keep the modified flag" + which); } @@ -1854,7 +1854,7 @@ ASW_TEST(TTest_ASWIni_BaseFile, Save_EditDuringSaveKeepsTheModifiedFlag) CheckTrue(ini.IsModified(), __func__, __LINE__, "a key set during the save should keep the modified flag"); CheckTrue(ReadTestFile(file, contents), __func__, __LINE__, "the file should exist"); CheckEquals(textOfFirstSave, contents, __func__, __LINE__, "the file should have the text before the edit"); - CheckEquals(std::string("600"), ini.GetValue("Window", "Height", ""), __func__, __LINE__, + CheckEquals("600", ini.GetValue("Window", "Height", ""), __func__, __LINE__, "the document should have the edit"); // Act @@ -1944,7 +1944,7 @@ ASW_TEST(TTest_ASWIni_BaseFile, Save_ReadOnlyFileChangesNothing) CheckEquals(static_cast(ERROR_ACCESS_DENIED), result.SystemError, __func__, __LINE__, "the system error should be access denied"); CheckTrue(read, __func__, __LINE__, "the file should still be readable"); - CheckEquals(std::string(SampleText), contents, __func__, __LINE__, "the file should be unchanged"); + CheckEquals(SampleText, contents, __func__, __LINE__, "the file should be unchanged"); CheckTrue(ini.IsModified(), __func__, __LINE__, "the modified flag should be unchanged"); CheckEquals(path, ini.GetFilePath(), __func__, __LINE__, "the file path should be unchanged"); CheckEquals(std::size_t(1), messages.size(), __func__, __LINE__, "the failure should be reported"); @@ -1981,9 +1981,9 @@ ASW_TEST(TTest_ASWIni_BaseFile, Save_RoundTripsByteForByte) CheckTrue(savedAs.IsOk(), __func__, __LINE__, "the copy should be saved: " + savedAs.Message); CheckTrue(ReadTestFile(source, sourceContents), __func__, __LINE__, "the file should be readable"); CheckTrue(ReadTestFile(copy, copyContents), __func__, __LINE__, "the copy should be readable"); - CheckEquals(std::string(TrickyText), sourceContents, __func__, __LINE__, + CheckEquals(TrickyText, sourceContents, __func__, __LINE__, "the saved file should have the bytes it was loaded from"); - CheckEquals(std::string(TrickyText), copyContents, __func__, __LINE__, + CheckEquals(TrickyText, copyContents, __func__, __LINE__, "the copy should have the bytes the file was loaded from"); } //--------------------------------------------------------------------------- @@ -2070,7 +2070,7 @@ ASW_TEST(TTest_ASWIni_BaseFile, Save_WritesAndClearsTheModifiedFlag) CheckFalse(ini.IsModified(), __func__, __LINE__, "a saved document shouldn't be modified"); CheckTrue(ReadTestFile(file, contents), __func__, __LINE__, "the file should be readable"); CheckEquals(ini.ToText(), contents, __func__, __LINE__, "the file should have the document's text"); - CheckContains(contents, std::string("Width = 800"), __func__, __LINE__, "the file should have the edit"); + CheckContains(contents, "Width = 800", __func__, __LINE__, "the file should have the edit"); // Act // A document that isn't modified is saved too @@ -2110,7 +2110,7 @@ ASW_TEST(TTest_ASWIni_BaseFile, Seams_ExceptionIsUnexpectedException) // Assert CheckEquals(EIniCode::UnexpectedException, load.Code, __func__, __LINE__, "an exception from ReadFile() should be UnexpectedException"); - CheckContains(load.Message, std::string("The disk is gone."), __func__, __LINE__, + CheckContains(load.Message, "The disk is gone.", __func__, __LINE__, "the message should say what was thrown"); CheckEquals(EIniCode::UnexpectedException, saveAs.Code, __func__, __LINE__, "an exception from WriteFile() should be UnexpectedException"); @@ -2155,27 +2155,27 @@ ASW_TEST(TTest_ASWIni_BaseFile, Seams_FailuresChangeNothing) // Assert CheckEquals(EIniCode::WriteFailed, writeFailed.Code, __func__, __LINE__, "Save() should fail as WriteFile() did"); - CheckEquals(std::string("app.ini"), writeFailed.FilePath, __func__, __LINE__, + CheckEquals("app.ini", writeFailed.FilePath, __func__, __LINE__, "the failed Save() should name the file path"); CheckEquals(EIniCode::ReplaceFailed, replaceFailed.Code, __func__, __LINE__, "SaveAs() should fail as WriteFile() did"); - CheckEquals(std::string("app.ini.tmp"), replaceFailed.FilePath, __func__, __LINE__, + CheckEquals("app.ini.tmp", replaceFailed.FilePath, __func__, __LINE__, "a failure that names a file should keep it"); CheckEquals(EIniCode::ReadFailed, readFailed.Code, __func__, __LINE__, "Load() should fail as ReadFile() did"); - CheckEquals(std::string("other.ini"), readFailed.FilePath, __func__, __LINE__, + CheckEquals("other.ini", readFailed.FilePath, __func__, __LINE__, "the failed Load() should name the file it read"); CheckEquals(before, ini.ToText(), __func__, __LINE__, "the document should be unchanged"); CheckTrue(ini.IsModified(), __func__, __LINE__, "the modified flag should be unchanged"); - CheckEquals(std::string("app.ini"), ini.GetFilePath(), __func__, __LINE__, "the file path should be unchanged"); + CheckEquals("app.ini", ini.GetFilePath(), __func__, __LINE__, "the file path should be unchanged"); CheckEquals(std::size_t(3), messages.size(), __func__, __LINE__, "each failure should be reported"); if (messages.size() == 3) { - CheckEquals(std::string("app.ini"), messages[0].FilePath, __func__, __LINE__, + CheckEquals("app.ini", messages[0].FilePath, __func__, __LINE__, "the failed Save() should be reported with the file path"); - CheckEquals(std::string("app.ini.tmp"), messages[1].FilePath, __func__, __LINE__, + CheckEquals("app.ini.tmp", messages[1].FilePath, __func__, __LINE__, "the failed SaveAs() should be reported with the file it names"); CheckEquals(5, messages[1].SystemError, __func__, __LINE__, "the system error should be reported"); - CheckEquals(std::string("other.ini"), messages[2].FilePath, __func__, __LINE__, + CheckEquals("other.ini", messages[2].FilePath, __func__, __LINE__, "the failed Load() should be reported with the file it read, not the file path"); } } @@ -2202,13 +2202,13 @@ ASW_TEST(TTest_ASWIni_BaseFile, Seams_FileNotFoundIsAMissingFile) // Assert CheckEquals(EIniCode::FileNotFound, result.Code, __func__, __LINE__, "Load() should fail as ReadFile() did"); CheckEquals(std::string(), ini.ToText(), __func__, __LINE__, "the document should be emptied"); - CheckEquals(std::string("app.ini"), ini.GetFilePath(), __func__, __LINE__, + CheckEquals("app.ini", ini.GetFilePath(), __func__, __LINE__, "the file Load() was given should become the file path"); CheckEquals(std::size_t(1), messages.size(), __func__, __LINE__, "the missing file should be reported once"); if (messages.size() == 1) { CheckEquals(ESeverity::Warning, messages[0].Severity, __func__, __LINE__, "a missing file should be a Warning"); - CheckEquals(std::string("elsewhere.ini"), messages[0].FilePath, __func__, __LINE__, + CheckEquals("elsewhere.ini", messages[0].FilePath, __func__, __LINE__, "the warning should name the file ReadFile() named"); CheckEquals(2, messages[0].SystemError, __func__, __LINE__, "the warning should have the system error"); } @@ -2255,9 +2255,9 @@ ASW_TEST(TTest_ASWIni_BaseFile, Seams_GetTheirArguments) // Assert CheckTrue(loaded.IsOk() && saved.IsOk(), __func__, __LINE__, "the file should be loaded and saved"); - CheckEquals(std::string("Folder/app.ini"), readPath, __func__, __LINE__, "ReadFile() should get the path as given"); + CheckEquals("Folder/app.ini", readPath, __func__, __LINE__, "ReadFile() should get the path as given"); CheckEquals(std::size_t(1000), readMaxSize, __func__, __LINE__, "ReadFile() should get MaxFileSize"); - CheckEquals(std::string("Folder/app.ini"), writePath, __func__, __LINE__, "WriteFile() should get the file path"); + CheckEquals("Folder/app.ini", writePath, __func__, __LINE__, "WriteFile() should get the file path"); CheckEquals(ini.ToText(), writeText, __func__, __LINE__, "WriteFile() should get the document's text"); CheckTrue(writeOptions.Backup && !writeOptions.AtomicSave && writeOptions.BackupSuffix == ".old", __func__, __LINE__, "WriteFile() should get the saving options"); @@ -2722,7 +2722,7 @@ ASW_TEST(TTest_ASWIni_BaseThreads, SetOptions_LookupsSeeTheOldOrTheNewOptions) CheckEquals(std::string(), failures.Summary(), __func__, __LINE__, "no thread should find a problem"); CheckFalse(ini.GetOptions().Reading.InlineComments, __func__, __LINE__, "the last options set should be kept"); CheckTrue(ini.TryGetText("Values", "Name", name), __func__, __LINE__, "the key should exist"); - CheckEquals(std::string("My App ; note"), name, __func__, __LINE__, + CheckEquals("My App ; note", name, __func__, __LINE__, "the text should be read with the last options"); CheckEquals(iterations, ini.GetValue("Values", WriterKey(0), -1), __func__, __LINE__, "the key should have the writer's last value"); diff --git a/tests/tests/Test_ASWIni_Converters.cpp b/tests/tests/Test_ASWIni_Converters.cpp index 8db41bf..fcb7316 100644 --- a/tests/tests/Test_ASWIni_Converters.cpp +++ b/tests/tests/Test_ASWIni_Converters.cpp @@ -846,7 +846,7 @@ ASW_TEST(TTest_ASWIni_BoolConverter, FromText_RejectsOtherTexts) // The message says what a bool can be bool value = false; TASWIniResult const result = TASWIniConverter::FromText("maybe", value, TASWIniValueOptions()); - CheckEquals(std::string("The value \"maybe\" isn't a bool: it must be true, false, yes, no, on, off, 1 or 0."), + CheckEquals("The value \"maybe\" isn't a bool: it must be true, false, yes, no, on, off, 1 or 0.", result.Message, __func__, __LINE__, "the message should name the text and the forms"); } //--------------------------------------------------------------------------- @@ -891,8 +891,8 @@ ASW_TEST(TTest_ASWIni_BoolConverter, ToText_UnknownFormatWritesTrueFalse) // Assert CheckTrue(yesResult.IsOk() && noResult.IsOk(), __func__, __LINE__, "writing a bool should never fail"); - CheckEquals(std::string("true"), yes, __func__, __LINE__, "true with an unknown format"); - CheckEquals(std::string("false"), no, __func__, __LINE__, "false with an unknown format"); + CheckEquals("true", yes, __func__, __LINE__, "true with an unknown format"); + CheckEquals("false", no, __func__, __LINE__, "false with an unknown format"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_BoolConverter, ToText_WritesTheFormatsForm) @@ -921,12 +921,12 @@ ASW_TEST(TTest_ASWIni_BoolConverter, ToText_WritesTheFormatsForm) std::string text = "old"; TASWIniResult result = TASWIniConverter::ToText(true, text, options); CheckTrue(result.IsOk(), __func__, __LINE__, format + ": writing true should succeed"); - CheckEquals(std::string(c.True), text, __func__, __LINE__, format + ": true"); + CheckEquals(c.True, text, __func__, __LINE__, format + ": true"); text = "old"; result = TASWIniConverter::ToText(false, text, options); CheckTrue(result.IsOk(), __func__, __LINE__, format + ": writing false should succeed"); - CheckEquals(std::string(c.False), text, __func__, __LINE__, format + ": false"); + CheckEquals(c.False, text, __func__, __LINE__, format + ": false"); } } //--------------------------------------------------------------------------- @@ -1101,15 +1101,15 @@ ASW_TEST(TTest_ASWIni_EnumConverter, Messages_NameTheProblem) // Assert // The names listed are those written: a second name of a value, or a nullptr one, isn't - CheckEquals(std::string("The value \"Purple\" isn't a name of the enum: it must be Red, Green or Blue."), + CheckEquals("The value \"Purple\" isn't a name of the enum: it must be Red, Green or Blue.", colorRead.Message, __func__, __LINE__, "the message should list the names written, without Lime"); - CheckEquals(std::string("The value \"Giant\" isn't a name of the enum: it must be Small, Medium or Large."), + CheckEquals("The value \"Giant\" isn't a name of the enum: it must be Small, Medium or Large.", sizeRead.Message, __func__, __LINE__, "the message should list each value's name once"); - CheckEquals(std::string("The value \"Min\" isn't a name of the enum: it must be Normal or Maximized."), + CheckEquals("The value \"Min\" isn't a name of the enum: it must be Normal or Maximized.", stateRead.Message, __func__, __LINE__, "the message should list two names with \"or\""); - CheckEquals(std::string("The value \"Only\" isn't a name of the enum: it has no names."), emptyRead.Message, + CheckEquals("The value \"Only\" isn't a name of the enum: it has no names.", emptyRead.Message, __func__, __LINE__, "the message should say that the enum has no names"); - CheckEquals(std::string("The value \"7\" has no name in the enum's ASWIniEnumNames(), so it can't be written."), + CheckEquals("The value \"7\" has no name in the enum's ASWIniEnumNames(), so it can't be written.", written.Message, __func__, __LINE__, "the message should name the value's number"); } //--------------------------------------------------------------------------- @@ -1153,22 +1153,22 @@ ASW_TEST(TTest_ASWIni_EnumConverter, ToText_UnnamedValueIsInvalid) std::string text = "old"; TASWIniResult const result = TASWIniConverter::ToText(EColor::Unlisted, text, TASWIniValueOptions()); CheckEquals(EIniCode::InvalidValue, result.Code, __func__, __LINE__, "an unnamed value should be InvalidValue"); - CheckEquals(std::string("old"), text, __func__, __LINE__, "an unnamed value should leave the text as it was"); + CheckEquals("old", text, __func__, __LINE__, "an unnamed value should leave the text as it was"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_EnumConverter, ToText_WritesTheFirstName) { // Act & Assert // Written() starts from "old", so these also check that the text is replaced - CheckEquals(std::string("Red"), Written(EColor::Red), __func__, __LINE__, "Red"); - CheckEquals(std::string("Green"), Written(EColor::Green), __func__, __LINE__, "Green, not its second name Lime"); - CheckEquals(std::string("Blue"), Written(EColor::Blue), __func__, __LINE__, "Blue"); - CheckEquals(std::string("Medium"), Written(ESize::Medium), __func__, __LINE__, + CheckEquals("Red", Written(EColor::Red), __func__, __LINE__, "Red"); + CheckEquals("Green", Written(EColor::Green), __func__, __LINE__, "Green, not its second name Lime"); + CheckEquals("Blue", Written(EColor::Blue), __func__, __LINE__, "Blue"); + CheckEquals("Medium", Written(ESize::Medium), __func__, __LINE__, "Medium, whose first entry has no name"); - CheckEquals(std::string("Large"), Written(ESize::Large), __func__, __LINE__, "Large"); - CheckEquals(std::string("Manual"), Written(EMode::Manual), __func__, __LINE__, "Manual, from a std::vector"); - CheckEquals(std::string("Two"), Written(PlainTwo), __func__, __LINE__, "PlainTwo, of an unscoped enum"); - CheckEquals(std::string("Maximized"), Written(TWindow::EState::Maximized), __func__, __LINE__, + CheckEquals("Large", Written(ESize::Large), __func__, __LINE__, "Large"); + CheckEquals("Manual", Written(EMode::Manual), __func__, __LINE__, "Manual, from a std::vector"); + CheckEquals("Two", Written(PlainTwo), __func__, __LINE__, "PlainTwo, of an unscoped enum"); + CheckEquals("Maximized", Written(TWindow::EState::Maximized), __func__, __LINE__, "Maximized, from a friend function"); } //--------------------------------------------------------------------------- @@ -1185,10 +1185,10 @@ ASW_TEST(TTest_ASWIni_EnumConverter, WithoutNames_ConvertsAsTheUnderlyingType) CheckReads("0", ESwitch::Off, __func__, __LINE__); CheckReads("65535", static_cast(65535), __func__, __LINE__); - CheckEquals(std::string("5"), Written(static_cast(5)), __func__, __LINE__, "flags that are no enumerator"); - CheckEquals(std::string("-128"), Written(ESmall::Low), __func__, __LINE__, "a std::int8_t enum, as a number"); - CheckEquals(std::string("1"), Written(ESwitch::On), __func__, __LINE__, "a bool enum, as a number"); - CheckEquals(std::string("65"), Written(static_cast(65)), __func__, __LINE__, "a char16_t enum, as a number"); + CheckEquals("5", Written(static_cast(5)), __func__, __LINE__, "flags that are no enumerator"); + CheckEquals("-128", Written(ESmall::Low), __func__, __LINE__, "a std::int8_t enum, as a number"); + CheckEquals("1", Written(ESwitch::On), __func__, __LINE__, "a bool enum, as a number"); + CheckEquals("65", Written(static_cast(65)), __func__, __LINE__, "a char16_t enum, as a number"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_EnumConverter, WithoutNames_RejectsWhatTheUnderlyingTypeRejects) @@ -1208,7 +1208,7 @@ ASW_TEST(TTest_ASWIni_EnumConverter, WithoutNames_RejectsWhatTheUnderlyingTypeRe ESwitch value = ESwitch::Off; TASWIniResult const result = TASWIniConverter::FromText("2", value, TASWIniValueOptions()); - CheckEquals(std::string("The value \"2\" is out of range: it must be 0 to 1."), result.Message, __func__, + CheckEquals("The value \"2\" is out of range: it must be 0 to 1.", result.Message, __func__, __LINE__, "the message should name the underlying type's range"); } //--------------------------------------------------------------------------- @@ -1408,8 +1408,8 @@ ASW_TEST(TTest_ASWIni_FloatConverter, Converters_UseTheDefaultConversion) CheckTrue(numberRead.IsOk() && number == 0.1, __func__, __LINE__, "\"0.1\" should read as the double 0.1"); CheckTrue(singleRead.IsOk() && single == 0.1f, __func__, __LINE__, "\"0.1\" should read as the float 0.1"); CheckTrue(numberWritten.IsOk() && singleWritten.IsOk(), __func__, __LINE__, "writing should succeed"); - CheckEquals(std::string("0.1"), numberText, __func__, __LINE__, "the double 0.1"); - CheckEquals(std::string("0.1"), singleText, __func__, __LINE__, "the float 0.1"); + CheckEquals("0.1", numberText, __func__, __LINE__, "the double 0.1"); + CheckEquals("0.1", singleText, __func__, __LINE__, "the float 0.1"); CheckEquals(EIniCode::InvalidValue, invalid.Code, __func__, __LINE__, "\"abc\" should be InvalidValue"); CheckTrue(invalidNumber == 2.5, __func__, __LINE__, "a failed read should leave the value as it was"); } @@ -1566,12 +1566,12 @@ ASW_TEST(TTest_ASWIni_FloatConverter, Messages_NameTheProblem) TASWIniResult const floatTooLarge = TASWIniConverter::FromText("1e39", single, TASWIniValueOptions()); // Assert - CheckEquals(std::string("The value \"1,5\" isn't a number: it must be digits with an optional '.' and exponent, " - "after an optional sign (e.g. 1.5, -2e-3), or inf or nan."), invalid.Message, __func__, __LINE__, + CheckEquals("The value \"1,5\" isn't a number: it must be digits with an optional '.' and exponent, " + "after an optional sign (e.g. 1.5, -2e-3), or inf or nan.", invalid.Message, __func__, __LINE__, "a text that isn't a number"); - CheckEquals(std::string("The value \"1e400\" is out of range: it must be -1.7976931348623157e+308 to " - "1.7976931348623157e+308."), tooLarge.Message, __func__, __LINE__, "a number too large for a double"); - CheckEquals(std::string("The value \"1e39\" is out of range: it must be -3.4028235e+38 to 3.4028235e+38."), + CheckEquals("The value \"1e400\" is out of range: it must be -1.7976931348623157e+308 to " + "1.7976931348623157e+308.", tooLarge.Message, __func__, __LINE__, "a number too large for a double"); + CheckEquals("The value \"1e39\" is out of range: it must be -3.4028235e+38 to 3.4028235e+38.", floatTooLarge.Message, __func__, __LINE__, "a number too large for a float"); } //--------------------------------------------------------------------------- @@ -1845,12 +1845,12 @@ ASW_TEST(TTest_ASWIni_IntegerConverter, Messages_NameTheProblem) TASWIniResult const invalid = TASWIniConverter::FromText("abc", number, TASWIniValueOptions()); // Assert - CheckEquals(std::string("The value \"300\" is out of range: it must be 0 to 255."), above.Message, __func__, + CheckEquals("The value \"300\" is out of range: it must be 0 to 255.", above.Message, __func__, __LINE__, "a number above the range"); - CheckEquals(std::string("The value \"-129\" is out of range: it must be -128 to 127."), below.Message, __func__, + CheckEquals("The value \"-129\" is out of range: it must be -128 to 127.", below.Message, __func__, __LINE__, "a number below the range"); - CheckEquals(std::string("The value \"abc\" isn't a whole number: it must be decimal digits, or 0x and hex digits, " - "after an optional sign."), invalid.Message, __func__, __LINE__, "a text that isn't a number"); + CheckEquals("The value \"abc\" isn't a whole number: it must be decimal digits, or 0x and hex digits, " + "after an optional sign.", invalid.Message, __func__, __LINE__, "a text that isn't a number"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_IntegerConverter, RoundTrip_EveryType) @@ -1873,15 +1873,15 @@ ASW_TEST(TTest_ASWIni_IntegerConverter, ToText_WritesDecimal) { // Act & Assert // Written() starts from "old", so these also check that the text is replaced - CheckEquals(std::string("0"), Written(0), __func__, __LINE__, "0"); - CheckEquals(std::string("-42"), Written(-42), __func__, __LINE__, "a negative int"); - CheckEquals(std::string("-128"), Written(static_cast(-128)), __func__, __LINE__, + CheckEquals("0", Written(0), __func__, __LINE__, "0"); + CheckEquals("-42", Written(-42), __func__, __LINE__, "a negative int"); + CheckEquals("-128", Written(static_cast(-128)), __func__, __LINE__, "std::int8_t's smallest value, as a number"); - CheckEquals(std::string("255"), Written(static_cast(255)), __func__, __LINE__, + CheckEquals("255", Written(static_cast(255)), __func__, __LINE__, "std::uint8_t's largest value, as a number"); - CheckEquals(std::string("-9223372036854775808"), Written(std::numeric_limits::min()), __func__, + CheckEquals("-9223372036854775808", Written(std::numeric_limits::min()), __func__, __LINE__, "std::int64_t's smallest value"); - CheckEquals(std::string("18446744073709551615"), Written(std::numeric_limits::max()), __func__, + CheckEquals("18446744073709551615", Written(std::numeric_limits::max()), __func__, __LINE__, "std::uint64_t's largest value"); } //--------------------------------------------------------------------------- @@ -2068,8 +2068,8 @@ ASW_TEST(TTest_ASWIni_ListConverter, FromText_FailingItemFailsTheList) // The message names the item, and gives its own message std::vector value; TASWIniResult const result = TASWIniConverter >::FromText("1, x, 3", value, m_Options); - CheckEquals(std::string("The value \"1, x, 3\" can't be read: item 2: The value \"x\" isn't a whole number: it " - "must be decimal digits, or 0x and hex digits, after an optional sign."), result.Message, __func__, __LINE__, + CheckEquals("The value \"1, x, 3\" can't be read: item 2: The value \"x\" isn't a whole number: it " + "must be decimal digits, or 0x and hex digits, after an optional sign.", result.Message, __func__, __LINE__, "the message should name the item that failed"); } //--------------------------------------------------------------------------- @@ -2112,10 +2112,10 @@ ASW_TEST(TTest_ASWIni_ListConverter, FromText_RejectsBadQuoting) std::vector value; TASWIniResult const unclosed = TASWIniConverter >::FromText("x, \"y", value, m_Options); TASWIniResult const after = TASWIniConverter >::FromText("\"a\"b", value, m_Options); - CheckEquals(std::string("The value \"x, \"y\" isn't a list: its item 2 starts with a '\"' that isn't closed."), + CheckEquals("The value \"x, \"y\" isn't a list: its item 2 starts with a '\"' that isn't closed.", unclosed.Message, __func__, __LINE__, "an unclosed quote"); - CheckEquals(std::string("The value \"\"a\"b\" isn't a list: its item 1 has more than blanks after its closing " - "'\"'."), after.Message, __func__, __LINE__, "text after a closing quote"); + CheckEquals("The value \"\"a\"b\" isn't a list: its item 1 has more than blanks after its closing " + "'\"'.", after.Message, __func__, __LINE__, "text after a closing quote"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_ListConverter, FromText_SplitsAtTheDelimiter) @@ -2194,10 +2194,10 @@ ASW_TEST(TTest_ASWIni_ListConverter, ToText_FailingItemFailsTheList) // Assert CheckEquals(EIniCode::InvalidValue, result.Code, __func__, __LINE__, "the item's code should be the list's"); - CheckEquals(std::string("The list can't be written: item 2: The value \"7\" has no name in the enum's " - "ASWIniEnumNames(), so it can't be written."), result.Message, __func__, __LINE__, + CheckEquals("The list can't be written: item 2: The value \"7\" has no name in the enum's " + "ASWIniEnumNames(), so it can't be written.", result.Message, __func__, __LINE__, "the message should name the item that failed"); - CheckEquals(std::string("old"), text, __func__, __LINE__, "the text should be left as it was"); + CheckEquals("old", text, __func__, __LINE__, "the text should be left as it was"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_ListConverter, ToText_JoinsWithTheDelimiterAndASpace) @@ -2397,7 +2397,7 @@ ASW_TEST(TTest_ASWIni_TextConverter, Path_ToTextRejectsWhatWouldNotReadBack) "a path that wouldn't read back should be InvalidValue"); CheckContains(result.Message, "is a path that isn't valid Unicode, so it can't be written to read back the " "same.", __func__, __LINE__, "the message should say why"); - CheckEquals(std::string("old"), text, __func__, __LINE__, "the text should be left as it was"); + CheckEquals("old", text, __func__, __LINE__, "the text should be left as it was"); } } //--------------------------------------------------------------------------- @@ -2797,9 +2797,9 @@ ASW_TEST(TTest_ASWIni_Converters, MessageText_CutsLongTextsBetweenSequences) ASW_TEST(TTest_ASWIni_Converters, MessageText_QuotesTheText) { // Act & Assert - CheckEquals(std::string("\"abc\""), ASWIni::Detail::MessageText("abc"), __func__, __LINE__, "a text"); - CheckEquals(std::string("\"\""), ASWIni::Detail::MessageText(""), __func__, __LINE__, "an empty text"); - CheckEquals(std::string("\" \xC3\xA9 \""), ASWIni::Detail::MessageText(" \xC3\xA9 "), __func__, __LINE__, + CheckEquals("\"abc\"", ASWIni::Detail::MessageText("abc"), __func__, __LINE__, "a text"); + CheckEquals("\"\"", ASWIni::Detail::MessageText(""), __func__, __LINE__, "an empty text"); + CheckEquals("\" \xC3\xA9 \"", ASWIni::Detail::MessageText(" \xC3\xA9 "), __func__, __LINE__, "blanks and UTF-8 should stay"); } //--------------------------------------------------------------------------- @@ -2812,7 +2812,7 @@ ASW_TEST(TTest_ASWIni_Converters, MessageText_ReplacesControlCharacters) std::string const message = ASWIni::Detail::MessageText(text); // Assert - CheckEquals(std::string("\"a?b?c?d???\""), message, __func__, __LINE__, + CheckEquals("\"a?b?c?d???\"", message, __func__, __LINE__, "each control character should be '?', so a message stays one line of text"); } //--------------------------------------------------------------------------- @@ -2824,7 +2824,7 @@ ASW_TEST(TTest_ASWIni_Converters, ValueFailure_MakesTheMessage) // Assert CheckEquals(EIniCode::ValueOutOfRange, result.Code, __func__, __LINE__, "the code"); - CheckEquals(std::string("The value \"300\" is out of range: it must be 0 to 255."), result.Message, __func__, + CheckEquals("The value \"300\" is out of range: it must be 0 to 255.", result.Message, __func__, __LINE__, "the message should quote the text, then name the problem"); } //--------------------------------------------------------------------------- diff --git a/tests/tests/Test_ASWIni_Document.cpp b/tests/tests/Test_ASWIni_Document.cpp index ef1dec7..df89629 100644 --- a/tests/tests/Test_ASWIni_Document.cpp +++ b/tests/tests/Test_ASWIni_Document.cpp @@ -890,12 +890,12 @@ ASW_TEST(TTest_ASWIni_DocumentModel, Document_CopyIsIndependent) // Assert AssertEquals(2, static_cast(copy.GetSections().size()), __func__, __LINE__, "the copy should keep its preamble and section"); - CheckEquals(std::string("General"), std::string(copy.GetSections()[1].GetName()), __func__, __LINE__, + CheckEquals("General", std::string(copy.GetSections()[1].GetName()), __func__, __LINE__, "the copy should keep its section's name"); - CheckEquals(std::string("640"), std::string(copy.GetSections()[1].GetLines()[1].GetValue()), __func__, __LINE__, + CheckEquals("640", std::string(copy.GetSections()[1].GetLines()[1].GetValue()), __func__, __LINE__, "the copy should keep its value"); CheckTrue(copy.GetOptions().Reading.CaseSensitive, __func__, __LINE__, "the copy should keep its options"); - CheckEquals(std::string("Other"), std::string(original.GetSections()[1].GetName()), __func__, __LINE__, + CheckEquals("Other", std::string(original.GetSections()[1].GetName()), __func__, __LINE__, "the original should hold what it parsed last"); CheckFalse(original.GetOptions().Reading.CaseSensitive, __func__, __LINE__, "the original should have the options it parsed with last"); @@ -995,7 +995,7 @@ ASW_TEST(TTest_ASWIni_DocumentModel, Reset_EmptiesTheDocumentWithNewOptions) "a reset document should get the platform's line break"); CheckTrue(document.GetOptions().Reading.CaseSensitive, __func__, __LINE__, "a reset document should have the new reading options"); - CheckEquals(std::string("="), document.GetOptions().Writing.Separator, __func__, __LINE__, + CheckEquals("=", document.GetOptions().Writing.Separator, __func__, __LINE__, "a reset document should have the new writing options"); CheckEquals(std::string(), document.ToText(), __func__, __LINE__, "a reset document should be an empty text"); } @@ -1042,9 +1042,9 @@ ASW_TEST(TTest_ASWIni_DocumentModel, Reset_WithItsOwnOptionsOnlyEmptiesIt) CheckEquals(0, static_cast(document.GetLineCount()), __func__, __LINE__, "the document should be empty"); AssertEquals(1, static_cast(document.GetOptions().Reading.CommentPrefixes.size()), __func__, __LINE__, "the document should keep its comment prefixes"); - CheckEquals(std::string("//"), document.GetOptions().Reading.CommentPrefixes[0], __func__, __LINE__, + CheckEquals("//", document.GetOptions().Reading.CommentPrefixes[0], __func__, __LINE__, "the document should keep its comment prefix"); - CheckEquals(std::string("// "), document.GetOptions().Writing.CommentPrefix, __func__, __LINE__, + CheckEquals("// ", document.GetOptions().Writing.CommentPrefix, __func__, __LINE__, "the document should keep its written comment prefix"); } //--------------------------------------------------------------------------- @@ -1080,7 +1080,7 @@ ASW_TEST(TTest_ASWIni_DocumentModel, SetOptions_InvalidOptionsChangeNothing) // Assert CheckEquals(EIniCode::InvalidOptions, result.Code, __func__, __LINE__, "the options should be rejected"); CheckFalse(result.Message.empty(), __func__, __LINE__, "the result should describe the problem"); - CheckEquals(std::string("[A]\nk=1\n"), document.ToText(), __func__, __LINE__, "the document should keep its text"); + CheckEquals("[A]\nk=1\n", document.ToText(), __func__, __LINE__, "the document should keep its text"); CheckTrue(document.FindKey("A", "k") != nullptr, __func__, __LINE__, "the document should keep its key"); CheckTrue(document.GetOptions().Reading.CaseSensitive, __func__, __LINE__, "the document should keep its options"); @@ -1105,7 +1105,7 @@ ASW_TEST(TTest_ASWIni_DocumentModel, SetOptions_KeepsLineBreaksAndTheModifiedFla // Assert AssertTrue(result.IsOk(), __func__, __LINE__, "the options should be set: " + result.Message); - CheckEquals(std::string("\xEF\xBB\xBF[A]\rk=1\rx = 1\r\ny = 1\r\nz = 1\r\n"), document.ToText(), __func__, + CheckEquals("\xEF\xBB\xBF[A]\rk=1\rx = 1\r\ny = 1\r\nz = 1\r\n", document.ToText(), __func__, __LINE__, "each line should keep its own line break, and the text its byte order mark"); CheckTrue(document.HasBom(), __func__, __LINE__, "the document should keep its byte order mark"); CheckEquals(ELineBreak::CR, document.GetLineBreak(), __func__, __LINE__, @@ -1132,7 +1132,7 @@ ASW_TEST(TTest_ASWIni_DocumentModel, SetOptions_KeepsTheBytesOfAByteOrderMarkInA // Assert AssertTrue(result.IsOk(), __func__, __LINE__, "the options should be set: " + result.Message); CheckFalse(document.HasBom(), __func__, __LINE__, "the document should still have no byte order mark"); - CheckEquals(std::string("\xEF\xBB\xBFx=2\n"), document.ToText(), __func__, __LINE__, + CheckEquals("\xEF\xBB\xBFx=2\n", document.ToText(), __func__, __LINE__, "the line should keep the mark's bytes"); CheckTrue(document.FindKey("", "\xEF\xBB\xBFx") != nullptr, __func__, __LINE__, "the key should keep the mark's bytes"); @@ -1167,7 +1167,7 @@ ASW_TEST(TTest_ASWIni_DocumentModel, SetOptions_RereadsTheTextWithNewOptions) CheckEquals(text, document.ToText(), __func__, __LINE__, "the text should stay byte for byte"); TASWIniDocumentLine const* const url = document.FindKey("A", "url"); AssertTrue(url != nullptr, __func__, __LINE__, "the line with ':' should be a key"); - CheckEquals(std::string("x"), std::string(url->GetValue()), __func__, __LINE__, "the key's value"); + CheckEquals("x", std::string(url->GetValue()), __func__, __LINE__, "the key's value"); CheckTrue(document.FindKey("A", "// c") == nullptr, __func__, __LINE__, "the line that starts with \"//\" shouldn't be a key"); AssertEquals(4, static_cast(document.GetSections()[1].GetLines().size()), __func__, __LINE__, @@ -1176,9 +1176,9 @@ ASW_TEST(TTest_ASWIni_DocumentModel, SetOptions_RereadsTheTextWithNewOptions) "the line that starts with \"//\" should be a comment"); TASWIniDocumentLine const* const k = document.FindKey("A", "k"); AssertTrue(k != nullptr, __func__, __LINE__, "the key with an inline comment should be found"); - CheckEquals(std::string("v"), std::string(k->GetValue()), __func__, __LINE__, + CheckEquals("v", std::string(k->GetValue()), __func__, __LINE__, "the inline comment shouldn't be part of the value"); - CheckEquals(std::string("note"), std::string(k->GetComment()), __func__, __LINE__, "the inline comment"); + CheckEquals("note", std::string(k->GetComment()), __func__, __LINE__, "the inline comment"); CheckTrue(document.GetOptions().Reading.InlineComments, __func__, __LINE__, "the document should have the new options"); CheckFalse(document.IsModified(), __func__, __LINE__, "the modified flag should stay clear"); @@ -1202,7 +1202,7 @@ ASW_TEST(TTest_ASWIni_DocumentModel, SetOptions_StrictParsingFailureChangesNothi // Assert CheckEquals(EIniCode::ParseFailed, result.Code, __func__, __LINE__, "the malformed line should fail the options"); CheckEquals(2, static_cast(result.Line), __func__, __LINE__, "the result should name the malformed line"); - CheckEquals(std::string("[A]\nbad\nk=2\n"), document.ToText(), __func__, __LINE__, + CheckEquals("[A]\nbad\nk=2\n", document.ToText(), __func__, __LINE__, "the document should keep its text"); CheckFalse(document.GetOptions().Reading.StrictParsing, __func__, __LINE__, "the document should keep its options"); @@ -1227,29 +1227,29 @@ ASW_TEST(TTest_ASWIni_DocumentModel, SetOptions_WithItsOwnOptionsKeepsTheDocumen // Assert AssertTrue(result.IsOk(), __func__, __LINE__, "the options should be set: " + result.Message); - CheckEquals(std::string("// c\n[A]\nk=1\n"), document.ToText(), __func__, __LINE__, + CheckEquals("// c\n[A]\nk=1\n", document.ToText(), __func__, __LINE__, "the document should keep its text"); AssertEquals(1, static_cast(document.GetOptions().Reading.CommentPrefixes.size()), __func__, __LINE__, "the document should keep its comment prefixes"); - CheckEquals(std::string("//"), document.GetOptions().Reading.CommentPrefixes[0], __func__, __LINE__, + CheckEquals("//", document.GetOptions().Reading.CommentPrefixes[0], __func__, __LINE__, "the document should keep its comment prefix"); - CheckEquals(std::string("c"), document.GetSectionComment("A"), __func__, __LINE__, + CheckEquals("c", document.GetSectionComment("A"), __func__, __LINE__, "the comment should still be read with the comment prefix"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_DocumentModel, ToString_LineKindNames) { - CheckEquals(std::string("Blank"), std::string(ASWIni::ToString(ELineKind::Blank)), __func__, __LINE__, + CheckEquals("Blank", ASWIni::ToString(ELineKind::Blank), __func__, __LINE__, "Blank's name"); - CheckEquals(std::string("Comment"), std::string(ASWIni::ToString(ELineKind::Comment)), __func__, __LINE__, + CheckEquals("Comment", ASWIni::ToString(ELineKind::Comment), __func__, __LINE__, "Comment's name"); - CheckEquals(std::string("Section"), std::string(ASWIni::ToString(ELineKind::Section)), __func__, __LINE__, + CheckEquals("Section", ASWIni::ToString(ELineKind::Section), __func__, __LINE__, "Section's name"); - CheckEquals(std::string("KeyValue"), std::string(ASWIni::ToString(ELineKind::KeyValue)), __func__, __LINE__, + CheckEquals("KeyValue", ASWIni::ToString(ELineKind::KeyValue), __func__, __LINE__, "KeyValue's name"); - CheckEquals(std::string("Raw"), std::string(ASWIni::ToString(ELineKind::Raw)), __func__, __LINE__, + CheckEquals("Raw", ASWIni::ToString(ELineKind::Raw), __func__, __LINE__, "Raw's name"); - CheckEquals(std::string("Unknown"), std::string(ASWIni::ToString(static_cast(99))), __func__, + CheckEquals("Unknown", ASWIni::ToString(static_cast(99)), __func__, __LINE__, "a value that isn't an ELineKind should be \"Unknown\""); } //--------------------------------------------------------------------------- @@ -1325,9 +1325,9 @@ ASW_TEST(TTest_ASWIni_DocumentParse, Bom_IsDetectedAndNotPartOfALine) CheckTrue(withContent.HasBom(), __func__, __LINE__, "a text with a UTF-8 byte order mark should have one"); std::vector const lines = AllLines(withContent); AssertEquals(2, static_cast(lines.size()), __func__, __LINE__, "the text should have two lines"); - CheckEquals(std::string("[S]"), lines[0].GetText(), __func__, __LINE__, + CheckEquals("[S]", lines[0].GetText(), __func__, __LINE__, "the byte order mark shouldn't be part of the first line"); - CheckEquals(std::string("S"), std::string(lines[0].GetSectionName()), __func__, __LINE__, + CheckEquals("S", std::string(lines[0].GetSectionName()), __func__, __LINE__, "the first line should still be the section header"); CheckTrue(bomOnly.HasBom(), __func__, __LINE__, "a text of only a byte order mark should have one"); CheckEquals(0, static_cast(bomOnly.GetLineCount()), __func__, __LINE__, @@ -1348,12 +1348,12 @@ ASW_TEST(TTest_ASWIni_DocumentParse, CommentPrefixes_AreConfigurable) // Assert AssertEquals(4, static_cast(lines.size()), __func__, __LINE__, "the text should have four lines"); CheckEquals(ELineKind::Comment, lines[0].GetKind(), __func__, __LINE__, "\"// note\" should be a comment"); - CheckEquals(std::string("note"), std::string(lines[0].GetComment()), __func__, __LINE__, + CheckEquals("note", std::string(lines[0].GetComment()), __func__, __LINE__, "the comment's text should follow the \"//\""); CheckEquals(ELineKind::Comment, lines[1].GetKind(), __func__, __LINE__, "\"//x=1\" should be a comment, since comments come before keys"); CheckKeyValue(lines[2], "#x", "1", __func__, __LINE__, "\"#x=1\" without '#' as a prefix"); - CheckEquals(std::string("double"), std::string(lines[3].GetComment()), __func__, __LINE__, + CheckEquals("double", std::string(lines[3].GetComment()), __func__, __LINE__, "the longest prefix that matches should be the comment's prefix"); } //--------------------------------------------------------------------------- @@ -1374,13 +1374,13 @@ ASW_TEST(TTest_ASWIni_DocumentParse, Comments_KeepTheirText) CheckTrue(line.HasComment(), __func__, __LINE__, "\"" + line.GetText() + "\" should have a comment"); } - CheckEquals(std::string("first"), std::string(lines[0].GetComment()), __func__, __LINE__, "a ';' comment"); - CheckEquals(std::string("second"), std::string(lines[1].GetComment()), __func__, __LINE__, + CheckEquals("first", std::string(lines[0].GetComment()), __func__, __LINE__, "a ';' comment"); + CheckEquals("second", std::string(lines[1].GetComment()), __func__, __LINE__, "a '#' comment, without its trailing space"); - CheckEquals(std::string("indented"), std::string(lines[2].GetComment()), __func__, __LINE__, + CheckEquals("indented", std::string(lines[2].GetComment()), __func__, __LINE__, "an indented comment"); CheckEquals(std::string(), std::string(lines[3].GetComment()), __func__, __LINE__, "an empty comment"); - CheckEquals(std::string(" \t;indented"), lines[2].GetText(), __func__, __LINE__, + CheckEquals(" \t;indented", lines[2].GetText(), __func__, __LINE__, "the line's text should be kept as it is"); } //--------------------------------------------------------------------------- @@ -1422,7 +1422,7 @@ ASW_TEST(TTest_ASWIni_DocumentParse, InlineComments_NeedABlankBeforeThePrefix) // Assert AssertEquals(5, static_cast(lines.size()), __func__, __LINE__, "the text should have five lines"); CheckKeyValue(lines[0], "a", "v", __func__, __LINE__, "a comment after a space"); - CheckEquals(std::string("note"), std::string(lines[0].GetComment()), __func__, __LINE__, "the comment's text"); + CheckEquals("note", std::string(lines[0].GetComment()), __func__, __LINE__, "the comment's text"); CheckKeyValue(lines[1], "b", "v;x", __func__, __LINE__, "a prefix with no blank before it"); CheckFalse(lines[1].HasComment(), __func__, __LINE__, "a prefix with no blank before it shouldn't be a comment"); CheckKeyValue(lines[2], "c", "", __func__, __LINE__, "an empty value with a comment"); @@ -1430,7 +1430,7 @@ ASW_TEST(TTest_ASWIni_DocumentParse, InlineComments_NeedABlankBeforeThePrefix) CheckKeyValue(lines[3], "d", ";note", __func__, __LINE__, "a prefix right after the separator"); CheckFalse(lines[3].HasComment(), __func__, __LINE__, "a prefix right after the separator shouldn't be a comment"); CheckKeyValue(lines[4], "e", "v", __func__, __LINE__, "a comment after a tab"); - CheckEquals(std::string("tabbed"), std::string(lines[4].GetComment()), __func__, __LINE__, + CheckEquals("tabbed", std::string(lines[4].GetComment()), __func__, __LINE__, "the comment's text, trimmed"); } //--------------------------------------------------------------------------- @@ -1480,7 +1480,7 @@ ASW_TEST(TTest_ASWIni_DocumentParse, KeyValue_KeyAndValueAreTrimmed) // Assert AssertEquals(3, static_cast(lines.size()), __func__, __LINE__, "the text should have three lines"); CheckKeyValue(lines[0], "My Key", "value with spaces", __func__, __LINE__, "a key and value with blanks"); - CheckEquals(std::string("\tMy Key \t=\t value with spaces \t"), lines[0].GetText(), __func__, __LINE__, + CheckEquals("\tMy Key \t=\t value with spaces \t", lines[0].GetText(), __func__, __LINE__, "the line's text should be kept as it is"); CheckKeyValue(lines[1], "empty", "", __func__, __LINE__, "an empty value"); CheckKeyValue(lines[2], "k", "v", __func__, __LINE__, "no blanks"); @@ -1517,7 +1517,7 @@ ASW_TEST(TTest_ASWIni_DocumentParse, LineBreaks_AreKeptForEachLine) CheckEquals(ELineBreak::CRLF, lines[1].GetLineBreak(), __func__, __LINE__, "line 2 should end with CRLF"); CheckEquals(ELineBreak::CR, lines[2].GetLineBreak(), __func__, __LINE__, "line 3 should end with CR"); CheckEquals(ELineBreak::None, lines[3].GetLineBreak(), __func__, __LINE__, "line 4 should have no line break"); - CheckEquals(std::string("b=2"), lines[1].GetText(), __func__, __LINE__, + CheckEquals("b=2", lines[1].GetText(), __func__, __LINE__, "a line's text shouldn't hold its line break"); } //--------------------------------------------------------------------------- @@ -1536,9 +1536,9 @@ ASW_TEST(TTest_ASWIni_DocumentParse, Parse_KeepsTheOptions) "the document should keep the reading options"); CheckEquals(ASWIni::ELineEnding::LF, document.GetOptions().Writing.LineEnding, __func__, __LINE__, "the document should keep the writing options"); - CheckEquals(std::string("note"), std::string(AllLines(document)[0].GetComment()), __func__, __LINE__, + CheckEquals("note", std::string(AllLines(document)[0].GetComment()), __func__, __LINE__, "the text should be read with the reading options"); - CheckEquals(std::string("a = 1 ; note\nb=2\n"), document.ToText(), __func__, __LINE__, + CheckEquals("a = 1 ; note\nb=2\n", document.ToText(), __func__, __LINE__, "the text should be written with the writing options"); } //--------------------------------------------------------------------------- @@ -1608,7 +1608,7 @@ ASW_TEST(TTest_ASWIni_DocumentParse, QuotedValues_DoubledQuoteIsOneQuote) AssertEquals(7, static_cast(commented.size()), __func__, __LINE__, "the text should have seven lines"); CheckKeyValue(commented[3], "d", "a\" b", __func__, __LINE__, "doubled quotes with InlineComments"); - CheckEquals(std::string("note"), std::string(commented[3].GetComment()), __func__, __LINE__, + CheckEquals("note", std::string(commented[3].GetComment()), __func__, __LINE__, "the comment after doubled quotes"); } //--------------------------------------------------------------------------- @@ -1643,10 +1643,10 @@ ASW_TEST(TTest_ASWIni_DocumentParse, QuotedValues_LoseTheirQuotes) AssertEquals(7, static_cast(commented.size()), __func__, __LINE__, "the text should have seven lines"); CheckKeyValue(commented[4], "e", "x", __func__, __LINE__, "a comment after the quotes with InlineComments"); CheckTrue(commented[4].IsQuoted(), __func__, __LINE__, "\"x\" ; note should be quoted with InlineComments"); - CheckEquals(std::string("note"), std::string(commented[4].GetComment()), __func__, __LINE__, + CheckEquals("note", std::string(commented[4].GetComment()), __func__, __LINE__, "the comment after the quotes"); CheckKeyValue(commented[5], "f", "a ; b", __func__, __LINE__, "a prefix inside the quotes"); - CheckEquals(std::string("note"), std::string(commented[5].GetComment()), __func__, __LINE__, + CheckEquals("note", std::string(commented[5].GetComment()), __func__, __LINE__, "the comment should be searched for after the closing quote"); CheckKeyValue(commented[6], "g", "\"x\";note", __func__, __LINE__, "a prefix right after the closing quote"); CheckFalse(commented[6].HasComment(), __func__, __LINE__, @@ -1687,7 +1687,7 @@ ASW_TEST(TTest_ASWIni_DocumentParse, Sections_HoldTheLinesAfterTheirHeader) "the preamble should hold the lines before the first header"); CheckKeyValue(sections[0].GetLines()[1], "a", "1", __func__, __LINE__, "a key before any section"); CheckTrue(sections[1].HasHeader(), __func__, __LINE__, "[S] should have a header"); - CheckEquals(std::string("S"), std::string(sections[1].GetName()), __func__, __LINE__, "[S]'s name"); + CheckEquals("S", std::string(sections[1].GetName()), __func__, __LINE__, "[S]'s name"); CheckEquals(3, static_cast(sections[1].GetLines().size()), __func__, __LINE__, "[S] should hold its header, b and the comment"); CheckEquals(ELineKind::Section, sections[1].GetLines()[0].GetKind(), __func__, __LINE__, @@ -1705,11 +1705,11 @@ ASW_TEST(TTest_ASWIni_DocumentParse, Sections_KeepATrailingComment) // Assert AssertEquals(3, static_cast(lines.size()), __func__, __LINE__, "the text should have three lines"); - CheckEquals(std::string("General"), std::string(lines[0].GetSectionName()), __func__, __LINE__, + CheckEquals("General", std::string(lines[0].GetSectionName()), __func__, __LINE__, "the name before the comment"); CheckTrue(lines[0].HasComment(), __func__, __LINE__, "\"[General] ; note\" should have a comment"); - CheckEquals(std::string("note"), std::string(lines[0].GetComment()), __func__, __LINE__, "the comment's text"); - CheckEquals(std::string("x"), std::string(lines[1].GetComment()), __func__, __LINE__, + CheckEquals("note", std::string(lines[0].GetComment()), __func__, __LINE__, "the comment's text"); + CheckEquals("x", std::string(lines[1].GetComment()), __func__, __LINE__, "a comment right after the ']' (even with InlineComments off)"); CheckFalse(lines[2].HasComment(), __func__, __LINE__, "blanks after the ']' aren't a comment"); } @@ -1723,15 +1723,15 @@ ASW_TEST(TTest_ASWIni_DocumentParse, Sections_NamesAreTrimmedAndFlat) // Assert AssertEquals(5, static_cast(lines.size()), __func__, __LINE__, "the text should have five lines"); - CheckEquals(std::string("General"), std::string(lines[0].GetSectionName()), __func__, __LINE__, + CheckEquals("General", std::string(lines[0].GetSectionName()), __func__, __LINE__, "the blanks around the name should be trimmed"); - CheckEquals(std::string("Indented"), std::string(lines[1].GetSectionName()), __func__, __LINE__, + CheckEquals("Indented", std::string(lines[1].GetSectionName()), __func__, __LINE__, "an indented header"); - CheckEquals(std::string("a.b"), std::string(lines[2].GetSectionName()), __func__, __LINE__, + CheckEquals("a.b", std::string(lines[2].GetSectionName()), __func__, __LINE__, "a dot should be an ordinary character"); - CheckEquals(std::string("remote \"origin\""), std::string(lines[3].GetSectionName()), __func__, __LINE__, + CheckEquals("remote \"origin\"", std::string(lines[3].GetSectionName()), __func__, __LINE__, "git's subsection syntax should be a literal name"); - CheckEquals(std::string("*.md"), std::string(lines[4].GetSectionName()), __func__, __LINE__, + CheckEquals("*.md", std::string(lines[4].GetSectionName()), __func__, __LINE__, "an .editorconfig glob should be a literal name"); } //--------------------------------------------------------------------------- @@ -1766,7 +1766,7 @@ void TTest_ASWIni_DocumentMessages::CheckParseFails(std::string_view text, TASWI CheckFalse(result.Message.empty(), method, lineNumber, msg + ": the result should describe the error"); AssertEquals(2, static_cast(document.GetSections().size()), method, lineNumber, msg + ": the document should keep its sections"); - CheckEquals(std::string("Old"), std::string(document.GetSections()[1].GetName()), method, lineNumber, + CheckEquals("Old", std::string(document.GetSections()[1].GetName()), method, lineNumber, msg + ": the document should keep its section"); CheckEquals(1, static_cast(messages.size()), method, lineNumber, msg + ": no message should be added when parsing fails"); @@ -1817,7 +1817,7 @@ ASW_TEST(TTest_ASWIni_DocumentMessages, DuplicateKey_IsReportedWithTheFirstLine) AssertTrue(result.IsOk(), __func__, __LINE__, "a duplicate key shouldn't fail the parse: " + result.Message); AssertEquals(1, static_cast(messages.size()), __func__, __LINE__, "one duplicate"); CheckWarning(messages[0], EIniCode::DuplicateKey, 4, "S", __func__, __LINE__, "the duplicate key"); - CheckEquals(std::string("WIDTH"), messages[0].Key, __func__, __LINE__, "the key as the duplicate writes it"); + CheckEquals("WIDTH", messages[0].Key, __func__, __LINE__, "the key as the duplicate writes it"); CheckContains(messages[0].Text, "line 2", __func__, __LINE__, "the text should name the first line"); CheckContains(messages[0].Text, "first one's", __func__, __LINE__, "the text should say the first one wins"); CheckEquals(4, static_cast(document.GetSections()[1].GetLines().size()), __func__, __LINE__, @@ -1948,8 +1948,8 @@ ASW_TEST(TTest_ASWIni_DocumentMessages, InvalidUtf8_IsReportedOnce) CheckWarning(messages[0], EIniCode::InvalidUtf8, 3, "S", __func__, __LINE__, "the first invalid line"); std::vector const lines = AllLines(document); AssertEquals(4, static_cast(lines.size()), __func__, __LINE__, "the text should have four lines"); - CheckEquals(std::string("a=\xFF"), lines[2].GetText(), __func__, __LINE__, "the bytes should be kept"); - CheckEquals(std::string("\xC0\x80"), std::string(lines[3].GetValue()), __func__, __LINE__, + CheckEquals("a=\xFF", lines[2].GetText(), __func__, __LINE__, "the bytes should be kept"); + CheckEquals("\xC0\x80", std::string(lines[3].GetValue()), __func__, __LINE__, "an overlong sequence should be kept as a value"); } //--------------------------------------------------------------------------- @@ -1971,7 +1971,7 @@ ASW_TEST(TTest_ASWIni_DocumentMessages, NoSeparator_IsMalformed) TASWIniDocumentLine const& line = document.GetSections()[1].GetLines()[1]; CheckEquals(ELineKind::Raw, line.GetKind(), __func__, __LINE__, "the line should be kept as a Raw line"); CheckEquals(std::string(), std::string(line.GetKey()), __func__, __LINE__, "a Raw line should have no key"); - CheckEquals(std::string("skip-networking"), line.GetText(), __func__, __LINE__, "the text should be kept"); + CheckEquals("skip-networking", line.GetText(), __func__, __LINE__, "the text should be kept"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_DocumentMessages, StrictParsing_FailsAtTheFirstMalformedLine) @@ -2031,7 +2031,7 @@ ASW_TEST(TTest_ASWIni_DocumentMessages, TextAfterSectionHeader_IsMalformedButUse "\"[a]b]\": the first ']' closes the name"); AssertEquals(3, static_cast(document.GetSections().size()), __func__, __LINE__, "both headers should start a section"); - CheckEquals(std::string("General"), std::string(document.GetSections()[1].GetName()), __func__, __LINE__, + CheckEquals("General", std::string(document.GetSections()[1].GetName()), __func__, __LINE__, "the section's name"); CheckEquals(2, static_cast(document.GetSections()[1].GetLines().size()), __func__, __LINE__, "the key should be in [General]"); @@ -2108,7 +2108,7 @@ ASW_TEST(TTest_ASWIni_DocumentMessages, Warnings_AreAppended) // Assert AssertTrue(result.IsOk(), __func__, __LINE__, "the text should parse: " + result.Message); AssertEquals(2, static_cast(messages.size()), __func__, __LINE__, "the earlier message and the new one"); - CheckEquals(std::string("earlier"), messages[0].Text, __func__, __LINE__, "the earlier message should be kept"); + CheckEquals("earlier", messages[0].Text, __func__, __LINE__, "the earlier message should be kept"); CheckWarning(messages[1], EIniCode::MalformedLine, 1, "", __func__, __LINE__, "the new warning"); } //--------------------------------------------------------------------------- @@ -2220,9 +2220,9 @@ ASW_TEST(TTest_ASWIni_DocumentToText, EmptyDocument_IsEmptyText) // Act & Assert CheckEquals(std::string(), TASWIniDocument().ToText(), __func__, __LINE__, "a new document should be an empty text"); - CheckEquals(std::string("\xEF\xBB\xBF"), alwaysDocument.ToText(), __func__, __LINE__, + CheckEquals("\xEF\xBB\xBF", alwaysDocument.ToText(), __func__, __LINE__, "an empty document with Always should be only the mark"); - CheckEquals(std::string("\xEF\xBB\xBF"), WriteBack("\xEF\xBB\xBF", TASWIniWritingOptions(), __func__, + CheckEquals("\xEF\xBB\xBF", WriteBack("\xEF\xBB\xBF", TASWIniWritingOptions(), __func__, __LINE__), __func__, __LINE__, "a text of only the mark should be written back as it was"); } //--------------------------------------------------------------------------- @@ -2258,9 +2258,9 @@ ASW_TEST(TTest_ASWIni_DocumentToText, LineEnding_ConvertsEveryLine) #endif // Act & Assert - CheckEquals(std::string("a=1\nb=2\nc=3\nd=4\n"), WriteBack(text, lf, __func__, __LINE__), __func__, __LINE__, + CheckEquals("a=1\nb=2\nc=3\nd=4\n", WriteBack(text, lf, __func__, __LINE__), __func__, __LINE__, "LF should end every line with LF"); - CheckEquals(std::string("a=1\r\nb=2\r\nc=3\r\nd=4\r\n"), WriteBack(text, crlf, __func__, __LINE__), __func__, + CheckEquals("a=1\r\nb=2\r\nc=3\r\nd=4\r\n", WriteBack(text, crlf, __func__, __LINE__), __func__, __LINE__, "CRLF should end every line with CRLF"); CheckEquals(nativeText, WriteBack(text, native, __func__, __LINE__), __func__, __LINE__, "Native should end every line with the platform's line break"); @@ -2275,9 +2275,9 @@ ASW_TEST(TTest_ASWIni_DocumentToText, LineEnding_NeverAddsAFinalLineBreak) lf.LineEnding = ASWIni::ELineEnding::LF; // Act & Assert - CheckEquals(std::string("a=1\r\nb=2"), WriteBack("a=1\nb=2", crlf, __func__, __LINE__), __func__, __LINE__, + CheckEquals("a=1\r\nb=2", WriteBack("a=1\nb=2", crlf, __func__, __LINE__), __func__, __LINE__, "a last line with no line break should get none with CRLF"); - CheckEquals(std::string("a=1"), WriteBack("a=1", lf, __func__, __LINE__), __func__, __LINE__, + CheckEquals("a=1", WriteBack("a=1", lf, __func__, __LINE__), __func__, __LINE__, "a single line with no line break should get none with LF"); } //--------------------------------------------------------------------------- @@ -2921,15 +2921,15 @@ ASW_TEST(TTest_ASWIni_DocumentLookup, GetKeyNames_EachKeyOnceInFileOrder) TASWIniDocument const matchingCase = Parsed(text, caseSensitive, __func__, __LINE__); // Assert - CheckEquals(std::string("b|a|c"), JoinedNames(ignoringCase.GetKeyNames("a")), __func__, __LINE__, + CheckEquals("b|a|c", JoinedNames(ignoringCase.GetKeyNames("a")), __func__, __LINE__, "the keys of both [A] and [a], each once, as first written"); - CheckEquals(std::string("p|q"), JoinedNames(ignoringCase.GetKeyNames("")), __func__, __LINE__, + CheckEquals("p|q", JoinedNames(ignoringCase.GetKeyNames("")), __func__, __LINE__, "the keys before the first header"); CheckEquals(std::string(), JoinedNames(ignoringCase.GetKeyNames("Missing")), __func__, __LINE__, "a missing section has no keys"); - CheckEquals(std::string("b|a|B"), JoinedNames(matchingCase.GetKeyNames("A")), __func__, __LINE__, + CheckEquals("b|a|B", JoinedNames(matchingCase.GetKeyNames("A")), __func__, __LINE__, "the keys of [A] with CaseSensitive"); - CheckEquals(std::string("c|A"), JoinedNames(matchingCase.GetKeyNames("a")), __func__, __LINE__, + CheckEquals("c|A", JoinedNames(matchingCase.GetKeyNames("a")), __func__, __LINE__, "the keys of [a] with CaseSensitive"); } //--------------------------------------------------------------------------- @@ -2946,9 +2946,9 @@ ASW_TEST(TTest_ASWIni_DocumentLookup, GetSectionNames_EachNameOnceInFileOrder) TASWIniDocument const preambleOnly = Parsed("k=1\n", TASWIniOptions(), __func__, __LINE__); // Assert - CheckEquals(std::string("B|A|C"), JoinedNames(ignoringCase.GetSectionNames()), __func__, __LINE__, + CheckEquals("B|A|C", JoinedNames(ignoringCase.GetSectionNames()), __func__, __LINE__, "each name once, as first written, without the preamble"); - CheckEquals(std::string("B|A|b|C"), JoinedNames(matchingCase.GetSectionNames()), __func__, __LINE__, + CheckEquals("B|A|b|C", JoinedNames(matchingCase.GetSectionNames()), __func__, __LINE__, "names that differ in case are different names with CaseSensitive"); CheckEquals(std::string(), JoinedNames(preambleOnly.GetSectionNames()), __func__, __LINE__, "a document with no header has no section names"); @@ -2968,13 +2968,13 @@ ASW_TEST(TTest_ASWIni_DocumentLookup, GetSectionNames_PrefixSelectsTheNames) TASWIniDocument const matchingCase = Parsed(text, caseSensitive, __func__, __LINE__); // Assert - CheckEquals(std::string("Window.Main|window.Tools"), JoinedNames(ignoringCase.GetSectionNames("Window.")), + CheckEquals("Window.Main|window.Tools", JoinedNames(ignoringCase.GetSectionNames("Window.")), __func__, __LINE__, "the names that start with \"Window.\" in any case"); - CheckEquals(std::string("Window.Main"), JoinedNames(matchingCase.GetSectionNames("Window.")), __func__, + CheckEquals("Window.Main", JoinedNames(matchingCase.GetSectionNames("Window.")), __func__, __LINE__, "the names that start with \"Window.\" with CaseSensitive"); - CheckEquals(std::string("Window.Main|window.Tools|Window"), JoinedNames(ignoringCase.GetSectionNames("WINDOW")), + CheckEquals("Window.Main|window.Tools|Window", JoinedNames(ignoringCase.GetSectionNames("WINDOW")), __func__, __LINE__, "a prefix that is a whole name"); - CheckEquals(std::string("Window.Main|Other|window.Tools|Window"), JoinedNames(ignoringCase.GetSectionNames("")), + CheckEquals("Window.Main|Other|window.Tools|Window", JoinedNames(ignoringCase.GetSectionNames("")), __func__, __LINE__, "an empty prefix selects every name"); CheckEquals(std::string(), JoinedNames(ignoringCase.GetSectionNames("Window.Main.Extra")), __func__, __LINE__, "a prefix longer than every name"); @@ -3092,15 +3092,15 @@ ASW_TEST(TTest_ASWIni_DocumentSetValue, AddSection_AddsAnEmptySectionAtTheEnd) lf.Writing.LineEnding = ASWIni::ELineEnding::LF; // Act & Assert - CheckEquals(std::string("[A]\nk=1\n\n[B]\n"), AddAndWrite("[A]\nk=1\n", options, "B", __func__, __LINE__), + CheckEquals("[A]\nk=1\n\n[B]\n", AddAndWrite("[A]\nk=1\n", options, "B", __func__, __LINE__), __func__, __LINE__, "after a blank line"); - CheckEquals(std::string("[A]\nk=1\n[B]\n"), AddAndWrite("[A]\nk=1\n", noBlankLine, "B", __func__, __LINE__), + CheckEquals("[A]\nk=1\n[B]\n", AddAndWrite("[A]\nk=1\n", noBlankLine, "B", __func__, __LINE__), __func__, __LINE__, "without a blank line when BlankLineBeforeNewSection is off"); - CheckEquals(std::string("[A]\n\n[B]\n"), AddAndWrite("[A]\n\n", options, "B", __func__, __LINE__), __func__, + CheckEquals("[A]\n\n[B]\n", AddAndWrite("[A]\n\n", options, "B", __func__, __LINE__), __func__, __LINE__, "after the blank line the text ends with"); - CheckEquals(std::string("[B]\n"), AddAndWrite("", lf, "B", __func__, __LINE__), __func__, __LINE__, + CheckEquals("[B]\n", AddAndWrite("", lf, "B", __func__, __LINE__), __func__, __LINE__, "first in an empty document, with no blank line"); - CheckEquals(std::string("[A]\n\n[B]\n"), AddAndWrite("[A]", lf, "B", __func__, __LINE__), __func__, __LINE__, + CheckEquals("[A]\n\n[B]\n", AddAndWrite("[A]", lf, "B", __func__, __LINE__), __func__, __LINE__, "a last line without a line break gets one"); } //--------------------------------------------------------------------------- @@ -3137,7 +3137,7 @@ ASW_TEST(TTest_ASWIni_DocumentSetValue, AddSection_RejectsNamesThatWouldntReadBa std::string const msg = "the name \"" + name + "\""; CheckEquals(EIniCode::InvalidArgument, result.Code, __func__, __LINE__, msg + " should be rejected"); CheckFalse(result.Message.empty(), __func__, __LINE__, msg + ": the result should describe the problem"); - CheckEquals(std::string("[A]\n"), document.ToText(), __func__, __LINE__, msg + ": the text shouldn't change"); + CheckEquals("[A]\n", document.ToText(), __func__, __LINE__, msg + ": the text shouldn't change"); CheckFalse(document.IsModified(), __func__, __LINE__, msg + ": the document shouldn't be modified"); } } @@ -3174,9 +3174,9 @@ ASW_TEST(TTest_ASWIni_DocumentSetValue, NewKey_GoesAfterTheHeaderOfASectionWitho TASWIniOptions const options; // Act & Assert - CheckEquals(std::string("[A]\nk = v\n; about\n\n[B]\n"), SetAndWrite("[A]\n; about\n\n[B]\n", options, "A", "k", + CheckEquals("[A]\nk = v\n; about\n\n[B]\n", SetAndWrite("[A]\n; about\n\n[B]\n", options, "A", "k", "v", __func__, __LINE__), __func__, __LINE__, "before the comments and blank lines of the section"); - CheckEquals(std::string(" [A]\nk = v\n"), SetAndWrite(" [A]\n", options, "A", "k", "v", __func__, __LINE__), + CheckEquals(" [A]\nk = v\n", SetAndWrite(" [A]\n", options, "A", "k", "v", __func__, __LINE__), __func__, __LINE__, "without the indentation of the header"); } //--------------------------------------------------------------------------- @@ -3186,12 +3186,12 @@ ASW_TEST(TTest_ASWIni_DocumentSetValue, NewKey_GoesAfterTheLastKey) TASWIniOptions const options; // Act & Assert - CheckEquals(std::string("[A]\na = 1\n b = 2\n c = 3\n; old = 3\n\n[B]\n"), SetAndWrite( + CheckEquals("[A]\na = 1\n b = 2\n c = 3\n; old = 3\n\n[B]\n", SetAndWrite( "[A]\na = 1\n b = 2\n; old = 3\n\n[B]\n", options, "A", "c", "3", __func__, __LINE__), __func__, __LINE__, "after the last key, with its indentation, before a comment and a blank line"); - CheckEquals(std::string("[A]\n\tk=1\n\tl = 2\n"), SetAndWrite("[A]\n\tk=1\n", options, "A", "l", "2", __func__, + CheckEquals("[A]\n\tk=1\n\tl = 2\n", SetAndWrite("[A]\n\tk=1\n", options, "A", "l", "2", __func__, __LINE__), __func__, __LINE__, "a tab as indentation"); - CheckEquals(std::string("[A]\nk=1\nl = 2\nraw\n"), SetAndWrite("[A]\nk=1\nraw\n", options, "A", "l", "2", + CheckEquals("[A]\nk=1\nl = 2\nraw\n", SetAndWrite("[A]\nk=1\nraw\n", options, "A", "l", "2", __func__, __LINE__), __func__, __LINE__, "a Raw line isn't a key"); } //--------------------------------------------------------------------------- @@ -3202,7 +3202,7 @@ ASW_TEST(TTest_ASWIni_DocumentSetValue, NewKey_GoesInTheFirstSectionOfThatName) __LINE__); // Assert - CheckEquals(std::string("[A]\na=1\nc = 3\n[B]\n[a]\nb=2\n"), written, __func__, __LINE__, + CheckEquals("[A]\na=1\nc = 3\n[B]\n[a]\nb=2\n", written, __func__, __LINE__, "in the first section named A, in any case"); } //--------------------------------------------------------------------------- @@ -3214,19 +3214,19 @@ ASW_TEST(TTest_ASWIni_DocumentSetValue, NewKey_GoesUnderTheFileCommentInThePream lf.Writing.LineEnding = ASWIni::ELineEnding::LF; // Act & Assert - CheckEquals(std::string("x=1\ny = 2\n\n[A]\n"), SetAndWrite("x=1\n\n[A]\n", options, "", "y", "2", __func__, + CheckEquals("x=1\ny = 2\n\n[A]\n", SetAndWrite("x=1\n\n[A]\n", options, "", "y", "2", __func__, __LINE__), __func__, __LINE__, "after the last key of the preamble"); - CheckEquals(std::string("; file\n\nk = v\n; about A\n[A]\n"), SetAndWrite("; file\n\n; about A\n[A]\n", options, + CheckEquals("; file\n\nk = v\n; about A\n[A]\n", SetAndWrite("; file\n\n; about A\n[A]\n", options, "", "k", "v", __func__, __LINE__), __func__, __LINE__, "after the file comment and the blank line under it"); - CheckEquals(std::string("; file\n\n\nk = v\n"), SetAndWrite("; file\n\n\n", options, "", "k", "v", __func__, + CheckEquals("; file\n\n\nk = v\n", SetAndWrite("; file\n\n\n", options, "", "k", "v", __func__, __LINE__), __func__, __LINE__, "after every blank line under the file comment"); - CheckEquals(std::string("k = v\n; about A\n[A]\n"), SetAndWrite("; about A\n[A]\n", options, "", "k", "v", + CheckEquals("k = v\n; about A\n[A]\n", SetAndWrite("; about A\n[A]\n", options, "", "k", "v", __func__, __LINE__), __func__, __LINE__, "before a comment that leads into the first header"); - CheckEquals(std::string("; file\n\nk = v\n"), SetAndWrite("; file\n", options, "", "k", "v", __func__, __LINE__), + CheckEquals("; file\n\nk = v\n", SetAndWrite("; file\n", options, "", "k", "v", __func__, __LINE__), __func__, __LINE__, "a blank line between the file comment and the key when there is none"); - CheckEquals(std::string("; file\n\nk = v\n"), SetAndWrite("; file", lf, "", "k", "v", __func__, __LINE__), + CheckEquals("; file\n\nk = v\n", SetAndWrite("; file", lf, "", "k", "v", __func__, __LINE__), __func__, __LINE__, "a file comment without a line break"); - CheckEquals(std::string("k = v\n"), SetAndWrite("", lf, "", "k", "v", __func__, __LINE__), __func__, __LINE__, + CheckEquals("k = v\n", SetAndWrite("", lf, "", "k", "v", __func__, __LINE__), __func__, __LINE__, "an empty document"); } //--------------------------------------------------------------------------- @@ -3239,13 +3239,13 @@ ASW_TEST(TTest_ASWIni_DocumentSetValue, NewKey_IsQuotedWhenItNeedsIt) quotedWithComments.Reading.InlineComments = true; // Act & Assert - CheckEquals(std::string("[A]\nk = \" x \"\n"), SetAndWrite("[A]\n", quoted, "A", "k", " x ", __func__, __LINE__), + CheckEquals("[A]\nk = \" x \"\n", SetAndWrite("[A]\n", quoted, "A", "k", " x ", __func__, __LINE__), __func__, __LINE__, "blanks at either end"); - CheckEquals(std::string("[A]\nk = \"a ; b\"\n"), SetAndWrite("[A]\n", quotedWithComments, "A", "k", "a ; b", + CheckEquals("[A]\nk = \"a ; b\"\n", SetAndWrite("[A]\n", quotedWithComments, "A", "k", "a ; b", __func__, __LINE__), __func__, __LINE__, "a comment prefix after a blank, with InlineComments"); - CheckEquals(std::string("[A]\nk = a\n"), SetAndWrite("[A]\n", quoted, "A", "k", "a", __func__, __LINE__), + CheckEquals("[A]\nk = a\n", SetAndWrite("[A]\n", quoted, "A", "k", "a", __func__, __LINE__), __func__, __LINE__, "a value that doesn't need quotes"); - CheckEquals(std::string("[A]\nk = \"\"\"x\"\"\"\n"), SetAndWrite("[A]\n", quoted, "A", "k", "\"x\"", __func__, + CheckEquals("[A]\nk = \"\"\"x\"\"\"\n", SetAndWrite("[A]\n", quoted, "A", "k", "\"x\"", __func__, __LINE__), __func__, __LINE__, "a value in quotes, with its quotes doubled"); } //--------------------------------------------------------------------------- @@ -3257,13 +3257,13 @@ ASW_TEST(TTest_ASWIni_DocumentSetValue, NewKey_LineBreaks) crlf.Writing.LineEnding = ASWIni::ELineEnding::CRLF; // Act & Assert - CheckEquals(std::string("[A]\r\nk=1\r\nl = 2\r\n"), SetAndWrite("[A]\r\nk=1", options, "A", "l", "2", __func__, + CheckEquals("[A]\r\nk=1\r\nl = 2\r\n", SetAndWrite("[A]\r\nk=1", options, "A", "l", "2", __func__, __LINE__), __func__, __LINE__, "the document's line break, also for a last line without one"); - CheckEquals(std::string("[A]\rk=1\rl = 2\r"), SetAndWrite("[A]\rk=1\r", options, "A", "l", "2", __func__, + CheckEquals("[A]\rk=1\rl = 2\r", SetAndWrite("[A]\rk=1\r", options, "A", "l", "2", __func__, __LINE__), __func__, __LINE__, "CR, the document's line break"); - CheckEquals(std::string("[A]\nk=1\nl = 2\n[B]\nx=1"), SetAndWrite("[A]\nk=1\n[B]\nx=1", options, "A", "l", "2", + CheckEquals("[A]\nk=1\nl = 2\n[B]\nx=1", SetAndWrite("[A]\nk=1\n[B]\nx=1", options, "A", "l", "2", __func__, __LINE__), __func__, __LINE__, "a last line elsewhere keeps having no line break"); - CheckEquals(std::string("[A]\r\nk=1\r\nl = 2\r\n"), SetAndWrite("[A]\nk=1\n", crlf, "A", "l", "2", __func__, + CheckEquals("[A]\r\nk=1\r\nl = 2\r\n", SetAndWrite("[A]\nk=1\n", crlf, "A", "l", "2", __func__, __LINE__), __func__, __LINE__, "the converted line break"); } //--------------------------------------------------------------------------- @@ -3300,17 +3300,17 @@ ASW_TEST(TTest_ASWIni_DocumentSetValue, NewKey_UsesTheWritingSeparator) tabbed.Writing.Separator = "\t=\t"; // Act & Assert - CheckEquals(std::string("[A]\nk = v\n"), SetAndWrite("[A]\n", spaced, "A", "k", "v", __func__, __LINE__), + CheckEquals("[A]\nk = v\n", SetAndWrite("[A]\n", spaced, "A", "k", "v", __func__, __LINE__), __func__, __LINE__, "the default \" = \""); - CheckEquals(std::string("[A]\nk=v\n"), SetAndWrite("[A]\n", plain, "A", "k", "v", __func__, __LINE__), __func__, + CheckEquals("[A]\nk=v\n", SetAndWrite("[A]\n", plain, "A", "k", "v", __func__, __LINE__), __func__, __LINE__, "\"=\""); - CheckEquals(std::string("[A]\nk: v\n"), SetAndWrite("[A]\n", colon, "A", "k", "v", __func__, __LINE__), __func__, + CheckEquals("[A]\nk: v\n", SetAndWrite("[A]\n", colon, "A", "k", "v", __func__, __LINE__), __func__, __LINE__, "\": \""); - CheckEquals(std::string("[A]\nk\t=\tv\n"), SetAndWrite("[A]\n", tabbed, "A", "k", "v", __func__, __LINE__), + CheckEquals("[A]\nk\t=\tv\n", SetAndWrite("[A]\n", tabbed, "A", "k", "v", __func__, __LINE__), __func__, __LINE__, "\"\\t=\\t\""); - CheckEquals(std::string("[A]\nk =\n"), SetAndWrite("[A]\n", spaced, "A", "k", "", __func__, __LINE__), __func__, + CheckEquals("[A]\nk =\n", SetAndWrite("[A]\n", spaced, "A", "k", "", __func__, __LINE__), __func__, __LINE__, "an empty value without the blank after the separator"); - CheckEquals(std::string("[A]\nk:\n"), SetAndWrite("[A]\n", colon, "A", "k", "", __func__, __LINE__), __func__, + CheckEquals("[A]\nk:\n", SetAndWrite("[A]\n", colon, "A", "k", "", __func__, __LINE__), __func__, __LINE__, "an empty value with \": \""); } //--------------------------------------------------------------------------- @@ -3324,15 +3324,15 @@ ASW_TEST(TTest_ASWIni_DocumentSetValue, NewSection_GoesAtTheEnd) lf.Writing.LineEnding = ASWIni::ELineEnding::LF; // Act & Assert - CheckEquals(std::string("[A]\nk=1\n\n[B]\nx = 1\n"), SetAndWrite("[A]\nk=1\n", options, "B", "x", "1", __func__, + CheckEquals("[A]\nk=1\n\n[B]\nx = 1\n", SetAndWrite("[A]\nk=1\n", options, "B", "x", "1", __func__, __LINE__), __func__, __LINE__, "after a blank line, with the key right after the header"); - CheckEquals(std::string("[A]\nk=1\n[B]\nx = 1\n"), SetAndWrite("[A]\nk=1\n", noBlankLine, "B", "x", "1", + CheckEquals("[A]\nk=1\n[B]\nx = 1\n", SetAndWrite("[A]\nk=1\n", noBlankLine, "B", "x", "1", __func__, __LINE__), __func__, __LINE__, "without a blank line when BlankLineBeforeNewSection is off"); - CheckEquals(std::string("; c\n\n[B]\nx = 1\n"), SetAndWrite("; c\n", options, "B", "x", "1", __func__, + CheckEquals("; c\n\n[B]\nx = 1\n", SetAndWrite("; c\n", options, "B", "x", "1", __func__, __LINE__), __func__, __LINE__, "after a preamble"); - CheckEquals(std::string("[B]\nx = 1\n"), SetAndWrite("", lf, "B", "x", "1", __func__, __LINE__), __func__, + CheckEquals("[B]\nx = 1\n", SetAndWrite("", lf, "B", "x", "1", __func__, __LINE__), __func__, __LINE__, "first in an empty document"); - CheckEquals(std::string("[A]\nk=1\n\n[B]\nx = 1\n"), SetAndWrite("[A]\nk=1", lf, "B", "x", "1", __func__, + CheckEquals("[A]\nk=1\n\n[B]\nx = 1\n", SetAndWrite("[A]\nk=1", lf, "B", "x", "1", __func__, __LINE__), __func__, __LINE__, "after a last line without a line break"); } //--------------------------------------------------------------------------- @@ -3348,7 +3348,7 @@ ASW_TEST(TTest_ASWIni_DocumentSetValue, NewSection_KeepsALineThatEndsWithCrApart std::string const written = AddAndWrite(text, TASWIniOptions(), "B", __func__, __LINE__); // Assert - CheckEquals(std::string("[A]\nk=1\nl=2\r\n\n[B]\n"), written, __func__, __LINE__, + CheckEquals("[A]\nk=1\nl=2\r\n\n[B]\n", written, __func__, __LINE__, "the line that ends with CR should end with CRLF instead"); CheckEquals(5, static_cast(ParseText(written, TASWIniOptions(), result, messages).GetLineCount()), __func__, __LINE__, "the text should read back as five lines"); @@ -3362,9 +3362,9 @@ ASW_TEST(TTest_ASWIni_DocumentSetValue, Value_ChangesTheWinningDuplicate) lastWins.Reading.DuplicateKeys = ASWIni::EDuplicateKeys::LastWins; // Act & Assert - CheckEquals(std::string("[A]\nk=x\nk=2\n[a]\nk=3\n"), SetAndWrite(text, TASWIniOptions(), "A", "K", "x", __func__, + CheckEquals("[A]\nk=x\nk=2\n[a]\nk=3\n", SetAndWrite(text, TASWIniOptions(), "A", "K", "x", __func__, __LINE__), __func__, __LINE__, "the first line with FirstWins"); - CheckEquals(std::string("[A]\nk=1\nk=2\n[a]\nk=x\n"), SetAndWrite(text, lastWins, "A", "K", "x", __func__, + CheckEquals("[A]\nk=1\nk=2\n[a]\nk=x\n", SetAndWrite(text, lastWins, "A", "K", "x", __func__, __LINE__), __func__, __LINE__, "the last line, in the duplicate section, with LastWins"); } //--------------------------------------------------------------------------- @@ -3374,15 +3374,15 @@ ASW_TEST(TTest_ASWIni_DocumentSetValue, Value_EmptyGetsTheBlanksBeforeTheSeparat TASWIniOptions const options; // Act & Assert - CheckEquals(std::string("a = v\n"), SetAndWrite("a =\n", options, "", "a", "v", __func__, __LINE__), __func__, + CheckEquals("a = v\n", SetAndWrite("a =\n", options, "", "a", "v", __func__, __LINE__), __func__, __LINE__, "a blank before the separator"); - CheckEquals(std::string("b=v\n"), SetAndWrite("b=\n", options, "", "b", "v", __func__, __LINE__), __func__, + CheckEquals("b=v\n", SetAndWrite("b=\n", options, "", "b", "v", __func__, __LINE__), __func__, __LINE__, "no blank before the separator"); - CheckEquals(std::string("c\t=\tv\n"), SetAndWrite("c\t=\n", options, "", "c", "v", __func__, __LINE__), __func__, + CheckEquals("c\t=\tv\n", SetAndWrite("c\t=\n", options, "", "c", "v", __func__, __LINE__), __func__, __LINE__, "a tab before the separator"); - CheckEquals(std::string("d : v\n"), SetAndWrite("d :\n", options, "", "d", "v", __func__, __LINE__), __func__, + CheckEquals("d : v\n", SetAndWrite("d :\n", options, "", "d", "v", __func__, __LINE__), __func__, __LINE__, "two blanks before a ':'"); - CheckEquals(std::string("e = v\n"), SetAndWrite("e = \n", options, "", "e", "v", __func__, __LINE__), __func__, + CheckEquals("e = v\n", SetAndWrite("e = \n", options, "", "e", "v", __func__, __LINE__), __func__, __LINE__, "a blank after the separator is kept"); } //--------------------------------------------------------------------------- @@ -3393,13 +3393,13 @@ ASW_TEST(TTest_ASWIni_DocumentSetValue, Value_KeepsTheInlineComment) withComments.Reading.InlineComments = true; // Act & Assert - CheckEquals(std::string("k = x ; note\n"), SetAndWrite("k = v ; note\n", withComments, "", "k", "x", __func__, + CheckEquals("k = x ; note\n", SetAndWrite("k = v ; note\n", withComments, "", "k", "x", __func__, __LINE__), __func__, __LINE__, "a comment after the value"); - CheckEquals(std::string("k=x\t# note\n"), SetAndWrite("k=v\t# note\n", withComments, "", "k", "x", __func__, + CheckEquals("k=x\t# note\n", SetAndWrite("k=v\t# note\n", withComments, "", "k", "x", __func__, __LINE__), __func__, __LINE__, "a comment after a tab"); - CheckEquals(std::string("k = x ; note\n"), SetAndWrite("k = ; note\n", withComments, "", "k", "x", __func__, + CheckEquals("k = x ; note\n", SetAndWrite("k = ; note\n", withComments, "", "k", "x", __func__, __LINE__), __func__, __LINE__, "a comment after an empty value gets a blank before it"); - CheckEquals(std::string("k = x\n"), SetAndWrite("k = v ; note\n", TASWIniOptions(), "", "k", "x", __func__, + CheckEquals("k = x\n", SetAndWrite("k = v ; note\n", TASWIniOptions(), "", "k", "x", __func__, __LINE__), __func__, __LINE__, "without InlineComments, the prefix and the note are part of the value"); } //--------------------------------------------------------------------------- @@ -3409,11 +3409,11 @@ ASW_TEST(TTest_ASWIni_DocumentSetValue, Value_KeepsTheLineBreak) TASWIniOptions const options; // Act & Assert - CheckEquals(std::string("a=1\r\nb=x\n"), SetAndWrite("a=1\r\nb=2\n", options, "", "b", "x", __func__, __LINE__), + CheckEquals("a=1\r\nb=x\n", SetAndWrite("a=1\r\nb=2\n", options, "", "b", "x", __func__, __LINE__), __func__, __LINE__, "the line's own line break"); - CheckEquals(std::string("a=x\rb=2\r"), SetAndWrite("a=1\rb=2\r", options, "", "a", "x", __func__, __LINE__), + CheckEquals("a=x\rb=2\r", SetAndWrite("a=1\rb=2\r", options, "", "a", "x", __func__, __LINE__), __func__, __LINE__, "CR"); - CheckEquals(std::string("k=2"), SetAndWrite("k=1", options, "", "k", "2", __func__, __LINE__), __func__, + CheckEquals("k=2", SetAndWrite("k=1", options, "", "k", "2", __func__, __LINE__), __func__, __LINE__, "a last line without a line break keeps having none"); } //--------------------------------------------------------------------------- @@ -3426,15 +3426,15 @@ ASW_TEST(TTest_ASWIni_DocumentSetValue, Value_QuotedStaysQuoted) quotedWithComments.Reading.InlineComments = true; // Act & Assert - CheckEquals(std::string("k = \"new\"\n"), SetAndWrite("k = \"old\"\n", quoted, "", "k", "new", __func__, + CheckEquals("k = \"new\"\n", SetAndWrite("k = \"old\"\n", quoted, "", "k", "new", __func__, __LINE__), __func__, __LINE__, "a quoted value"); - CheckEquals(std::string("k = \"x\"\n"), SetAndWrite("k = \"\"\n", quoted, "", "k", "x", __func__, __LINE__), + CheckEquals("k = \"x\"\n", SetAndWrite("k = \"\"\n", quoted, "", "k", "x", __func__, __LINE__), __func__, __LINE__, "an empty quoted value"); - CheckEquals(std::string("k = \"b\" ; c\n"), SetAndWrite("k = \"a\" ; c\n", quotedWithComments, "", "k", "b", + CheckEquals("k = \"b\" ; c\n", SetAndWrite("k = \"a\" ; c\n", quotedWithComments, "", "k", "b", __func__, __LINE__), __func__, __LINE__, "a quoted value with a comment"); - CheckEquals(std::string("k = \"a\"\"b\"\n"), SetAndWrite("k = \"old\"\n", quoted, "", "k", "a\"b", __func__, + CheckEquals("k = \"a\"\"b\"\n", SetAndWrite("k = \"old\"\n", quoted, "", "k", "a\"b", __func__, __LINE__), __func__, __LINE__, "a value with a '\"' stays quoted, with the '\"' doubled"); - CheckEquals(std::string("k = \"new\"\n"), SetAndWrite("k = \"a\"\"b\"\n", quoted, "", "k", "new", __func__, + CheckEquals("k = \"new\"\n", SetAndWrite("k = \"a\"\"b\"\n", quoted, "", "k", "new", __func__, __LINE__), __func__, __LINE__, "a value with doubled quotes is replaced as a whole"); } //--------------------------------------------------------------------------- @@ -3447,27 +3447,27 @@ ASW_TEST(TTest_ASWIni_DocumentSetValue, Value_QuotedWhenItNeedsIt) quotedWithComments.Reading.InlineComments = true; // Act & Assert - CheckEquals(std::string("k = \" spaced \"\n"), SetAndWrite("k = v\n", quoted, "", "k", " spaced ", __func__, + CheckEquals("k = \" spaced \"\n", SetAndWrite("k = v\n", quoted, "", "k", " spaced ", __func__, __LINE__), __func__, __LINE__, "blanks at either end"); - CheckEquals(std::string("k = \"open\n"), SetAndWrite("k = v\n", quoted, "", "k", "\"open", __func__, __LINE__), + CheckEquals("k = \"open\n", SetAndWrite("k = v\n", quoted, "", "k", "\"open", __func__, __LINE__), __func__, __LINE__, "a leading '\"' with no closing one reads back without quotes"); - CheckEquals(std::string("k = \"a ; b\"\n"), SetAndWrite("k = v\n", quotedWithComments, "", "k", "a ; b", + CheckEquals("k = \"a ; b\"\n", SetAndWrite("k = v\n", quotedWithComments, "", "k", "a ; b", __func__, __LINE__), __func__, __LINE__, "a comment prefix after a blank"); - CheckEquals(std::string("k = \";x\"\n"), SetAndWrite("k = v\n", quotedWithComments, "", "k", ";x", __func__, + CheckEquals("k = \";x\"\n", SetAndWrite("k = v\n", quotedWithComments, "", "k", ";x", __func__, __LINE__), __func__, __LINE__, "a leading comment prefix, after the separator's blank"); - CheckEquals(std::string("k = a;b\n"), SetAndWrite("k = v\n", quotedWithComments, "", "k", "a;b", __func__, + CheckEquals("k = a;b\n", SetAndWrite("k = v\n", quotedWithComments, "", "k", "a;b", __func__, __LINE__), __func__, __LINE__, "a comment prefix with no blank before it doesn't need quotes"); - CheckEquals(std::string("k = \"\"\"x\"\"\"\n"), SetAndWrite("k = v\n", quoted, "", "k", "\"x\"", __func__, + CheckEquals("k = \"\"\"x\"\"\"\n", SetAndWrite("k = v\n", quoted, "", "k", "\"x\"", __func__, __LINE__), __func__, __LINE__, "a value in quotes, with its quotes doubled"); - CheckEquals(std::string("k = \" a\"\"b \"\n"), SetAndWrite("k = v\n", quoted, "", "k", " a\"b ", __func__, + CheckEquals("k = \" a\"\"b \"\n", SetAndWrite("k = v\n", quoted, "", "k", " a\"b ", __func__, __LINE__), __func__, __LINE__, "a value that needs quotes and holds one"); - CheckEquals(std::string("k = \"\"\"\"\"\"\n"), SetAndWrite("k = v\n", quoted, "", "k", "\"\"", __func__, + CheckEquals("k = \"\"\"\"\"\"\n", SetAndWrite("k = v\n", quoted, "", "k", "\"\"", __func__, __LINE__), __func__, __LINE__, "a value of two quotes"); - CheckEquals(std::string("k = \"\"\"a, b\"\"\"\n"), SetAndWrite("k = v\n", quoted, "", "k", "\"a, b\"", __func__, + CheckEquals("k = \"\"\"a, b\"\"\"\n", SetAndWrite("k = v\n", quoted, "", "k", "\"a, b\"", __func__, __LINE__), __func__, __LINE__, "a list of one quoted item"); - CheckEquals(std::string("k = \"a, b\", c\n"), SetAndWrite("k = v\n", quoted, "", "k", "\"a, b\", c", __func__, + CheckEquals("k = \"a, b\", c\n", SetAndWrite("k = v\n", quoted, "", "k", "\"a, b\", c", __func__, __LINE__), __func__, __LINE__, "a leading quoted part that doesn't make the value quoted needs no quotes"); - CheckEquals(std::string("k = \"a\"\" ; b\" ; c\n"), SetAndWrite("k = v ; c\n", quotedWithComments, "", "k", + CheckEquals("k = \"a\"\" ; b\" ; c\n", SetAndWrite("k = v ; c\n", quotedWithComments, "", "k", "a\" ; b", __func__, __LINE__), __func__, __LINE__, "a quote and a comment prefix, with InlineComments"); } //--------------------------------------------------------------------------- @@ -3497,13 +3497,13 @@ ASW_TEST(TTest_ASWIni_DocumentSetValue, Value_ReplacesOnlyTheValue) TASWIniOptions const options; // Act & Assert - CheckEquals(std::string(" Width \t=\t 800 \t\n"), SetAndWrite(" Width \t=\t 640 \t\n", options, "", "width", + CheckEquals(" Width \t=\t 800 \t\n", SetAndWrite(" Width \t=\t 640 \t\n", options, "", "width", "800", __func__, __LINE__), __func__, __LINE__, "the indentation, key, spacing and trailing blanks stay"); - CheckEquals(std::string("a: 2\n"), SetAndWrite("a: 1\n", options, "", "a", "2", __func__, __LINE__), __func__, + CheckEquals("a: 2\n", SetAndWrite("a: 1\n", options, "", "a", "2", __func__, __LINE__), __func__, __LINE__, "a ':' separator stays"); - CheckEquals(std::string("k=a=b\n"), SetAndWrite("k=v\n", options, "", "k", "a=b", __func__, __LINE__), __func__, + CheckEquals("k=a=b\n", SetAndWrite("k=v\n", options, "", "k", "a=b", __func__, __LINE__), __func__, __LINE__, "a value with a separator"); - CheckEquals(std::string("[S]\nurl = http://b:8080\n"), SetAndWrite("[S]\nurl = http://a\n", options, "S", "url", + CheckEquals("[S]\nurl = http://b:8080\n", SetAndWrite("[S]\nurl = http://a\n", options, "S", "url", "http://b:8080", __func__, __LINE__), __func__, __LINE__, "a value with ':'"); } //--------------------------------------------------------------------------- @@ -3517,11 +3517,11 @@ ASW_TEST(TTest_ASWIni_DocumentSetValue, Value_SameValueChangesNothing) // Act & Assert // SetAndWrite() also checks that the document isn't modified when its text doesn't change - CheckEquals(std::string("k = v\n"), SetAndWrite("k = v\n", TASWIniOptions(), "", "K", "v", __func__, __LINE__), + CheckEquals("k = v\n", SetAndWrite("k = v\n", TASWIniOptions(), "", "K", "v", __func__, __LINE__), __func__, __LINE__, "the same value"); - CheckEquals(std::string("k = \"v\"\n"), SetAndWrite("k = \"v\"\n", quoted, "", "k", "v", __func__, __LINE__), + CheckEquals("k = \"v\"\n", SetAndWrite("k = \"v\"\n", quoted, "", "k", "v", __func__, __LINE__), __func__, __LINE__, "the same quoted value"); - CheckEquals(std::string("k = v ; note\n"), SetAndWrite("k = v ; note\n", withComments, "", "k", "v", __func__, + CheckEquals("k = v ; note\n", SetAndWrite("k = v ; note\n", withComments, "", "k", "v", __func__, __LINE__), __func__, __LINE__, "the same value with a comment"); } //--------------------------------------------------------------------------- @@ -3613,16 +3613,16 @@ ASW_TEST(TTest_ASWIni_DocumentRemove, RemoveKey_KeepsALineThatEndsWithCrApart) std::string const written = RemoveKeyAndWrite("a=1\rk=1\n\nb=2\n", "", "k", true, __func__, __LINE__); // Assert - CheckEquals(std::string("a=1\r\n\nb=2\n"), written, __func__, __LINE__, + CheckEquals("a=1\r\n\nb=2\n", written, __func__, __LINE__, "the line that ends with CR should end with CRLF instead"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_DocumentRemove, RemoveKey_KeepsTheLinesAroundIt) { // Act & Assert - CheckEquals(std::string("[A]\nj=0\n; about B\n[B]\n"), RemoveKeyAndWrite("[A]\nj=0\nk=1\n; about B\n[B]\n", "A", + CheckEquals("[A]\nj=0\n; about B\n[B]\n", RemoveKeyAndWrite("[A]\nj=0\nk=1\n; about B\n[B]\n", "A", "k", true, __func__, __LINE__), __func__, __LINE__, "the comment below the key belongs to the next section"); - CheckEquals(std::string("[A]\nj=0\n"), RemoveKeyAndWrite("[A]\nj=0\nk=1", "A", "k", true, __func__, __LINE__), + CheckEquals("[A]\nj=0\n", RemoveKeyAndWrite("[A]\nj=0\nk=1", "A", "k", true, __func__, __LINE__), __func__, __LINE__, "a last line without a line break"); } //--------------------------------------------------------------------------- @@ -3633,20 +3633,20 @@ ASW_TEST(TTest_ASWIni_DocumentRemove, RemoveKey_RemovesEveryDuplicate) __func__, __LINE__); // Assert - CheckEquals(std::string("[A]\n[B]\nk=3\n[a]\n"), written, __func__, __LINE__, + CheckEquals("[A]\n[B]\nk=3\n[a]\n", written, __func__, __LINE__, "every line of the key in both [A] and [a], with their comments, and not the key of [B]"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_DocumentRemove, RemoveKey_RemovesItsComment) { // Act & Assert - CheckEquals(std::string("[A]\n\nl=2\n"), RemoveKeyAndWrite("[A]\n; about k\n; more\nk=1\n\nl=2\n", "A", "k", + CheckEquals("[A]\n\nl=2\n", RemoveKeyAndWrite("[A]\n; about k\n; more\nk=1\n\nl=2\n", "A", "k", true, __func__, __LINE__), __func__, __LINE__, "the comment lines directly above the key"); - CheckEquals(std::string("[A]\n; c\n\nl=2\n"), RemoveKeyAndWrite("[A]\n; c\n\nk=1\nl=2\n", "A", "k", true, + CheckEquals("[A]\n; c\n\nl=2\n", RemoveKeyAndWrite("[A]\n; c\n\nk=1\nl=2\n", "A", "k", true, __func__, __LINE__), __func__, __LINE__, "a comment with a blank line under it isn't the key's"); CheckEquals(std::string(), RemoveKeyAndWrite("; c\nk=1\n", "", "k", true, __func__, __LINE__), __func__, __LINE__, "a comment directly above a key at the start of the file is the key's"); - CheckEquals(std::string("; file\n\n[A]\n"), RemoveKeyAndWrite("; file\n\n; about k\nk=1\n[A]\n", "", "k", true, + CheckEquals("; file\n\n[A]\n", RemoveKeyAndWrite("; file\n\n; about k\nk=1\n[A]\n", "", "k", true, __func__, __LINE__), __func__, __LINE__, "the file comment stays"); } //--------------------------------------------------------------------------- @@ -3669,10 +3669,10 @@ ASW_TEST(TTest_ASWIni_DocumentRemove, RemoveKey_ReturnsFalseWhenMissing) ASW_TEST(TTest_ASWIni_DocumentRemove, RemoveSection_KeepsTheCommentOfTheNextSection) { // Act & Assert - CheckEquals(std::string("[A]\nk=1\n\n; about C\n[C]\n"), RemoveSectionAndWrite( + CheckEquals("[A]\nk=1\n\n; about C\n[C]\n", RemoveSectionAndWrite( "[A]\nk=1\n\n[B]\nx=1\n\n; about C\n[C]\n", "B", true, __func__, __LINE__), __func__, __LINE__, "the comment above [C] moves to [A]"); - CheckEquals(std::string("; about C\n[C]\n"), RemoveSectionAndWrite("[B]\nx=1\n; about C\n[C]\n", "B", true, + CheckEquals("; about C\n[C]\n", RemoveSectionAndWrite("[B]\nx=1\n; about C\n[C]\n", "B", true, __func__, __LINE__), __func__, __LINE__, "the comment above [C] moves to the preamble"); } //--------------------------------------------------------------------------- @@ -3683,16 +3683,16 @@ ASW_TEST(TTest_ASWIni_DocumentRemove, RemoveSection_RemovesEveryDuplicate) true, __func__, __LINE__); // Assert - CheckEquals(std::string("[A]\n; about C\n[C]\n"), written, __func__, __LINE__, + CheckEquals("[A]\n; about C\n[C]\n", written, __func__, __LINE__, "both [B] and [b] with their comments, and not the comment of [C]"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_DocumentRemove, RemoveSection_RemovesItsComment) { // Act & Assert - CheckEquals(std::string("[A]\nk=1\n\n[C]\n"), RemoveSectionAndWrite("[A]\nk=1\n\n; about B\n[B]\nx=1\n\n[C]\n", + CheckEquals("[A]\nk=1\n\n[C]\n", RemoveSectionAndWrite("[A]\nk=1\n\n; about B\n[B]\nx=1\n\n[C]\n", "B", true, __func__, __LINE__), __func__, __LINE__, "the comment lines directly above the header"); - CheckEquals(std::string("; file\n\n[B]\n"), RemoveSectionAndWrite("; file\n\n; about A\n[A]\nk=1\n[B]\n", "a", + CheckEquals("; file\n\n[B]\n", RemoveSectionAndWrite("; file\n\n; about A\n[A]\nk=1\n[B]\n", "a", true, __func__, __LINE__), __func__, __LINE__, "the first section's comment, but not the file comment"); CheckEquals(std::string(), RemoveSectionAndWrite("; about A\n[A]\n", "A", true, __func__, __LINE__), __func__, __LINE__, "a comment that leads straight into the first header is its comment"); @@ -3701,9 +3701,9 @@ ASW_TEST(TTest_ASWIni_DocumentRemove, RemoveSection_RemovesItsComment) ASW_TEST(TTest_ASWIni_DocumentRemove, RemoveSection_RemovesTheLastSection) { // Act & Assert - CheckEquals(std::string("[A]\nk=1\n\n"), RemoveSectionAndWrite("[A]\nk=1\n\n[B]\nx=1\n; trailing\n", "B", true, + CheckEquals("[A]\nk=1\n\n", RemoveSectionAndWrite("[A]\nk=1\n\n[B]\nx=1\n; trailing\n", "B", true, __func__, __LINE__), __func__, __LINE__, "the comment at the end of the file goes with the last section"); - CheckEquals(std::string("[A]\nk=1\n"), RemoveSectionAndWrite("[A]\nk=1\n[B]\nx=1", "B", true, __func__, + CheckEquals("[A]\nk=1\n", RemoveSectionAndWrite("[A]\nk=1\n[B]\nx=1", "B", true, __func__, __LINE__), __func__, __LINE__, "a last line without a line break"); } //--------------------------------------------------------------------------- @@ -3850,11 +3850,11 @@ ASW_TEST(TTest_ASWIni_DocumentRename, RenameKey_ChangesOnlyTheName) quotedWithComments.Reading.InlineComments = true; // Act & Assert - CheckEquals(std::string("[A]\n Height \t=\t 640\n"), RenameKeyAndWrite("[A]\n Width \t=\t 640\n", options, "A", + CheckEquals("[A]\n Height \t=\t 640\n", RenameKeyAndWrite("[A]\n Width \t=\t 640\n", options, "A", "width", "Height", __func__, __LINE__), __func__, __LINE__, "the indentation, spacing and value stay"); - CheckEquals(std::string("[A]\nn = \"v\" ; c\n"), RenameKeyAndWrite("[A]\nk = \"v\" ; c\n", quotedWithComments, + CheckEquals("[A]\nn = \"v\" ; c\n", RenameKeyAndWrite("[A]\nk = \"v\" ; c\n", quotedWithComments, "A", "k", "n", __func__, __LINE__), __func__, __LINE__, "the quotes and the comment stay"); - CheckEquals(std::string("Max Width: 1\n"), RenameKeyAndWrite("k: 1\n", options, "", "k", "Max Width", __func__, + CheckEquals("Max Width: 1\n", RenameKeyAndWrite("k: 1\n", options, "", "k", "Max Width", __func__, __LINE__), __func__, __LINE__, "a key of the preamble, renamed to a name with a space"); } //--------------------------------------------------------------------------- @@ -3878,9 +3878,9 @@ ASW_TEST(TTest_ASWIni_DocumentRename, RenameKey_MayChangeOnlyTheCase) TASWIniOptions const options; // Act & Assert - CheckEquals(std::string("[A]\nWidth=1\n"), RenameKeyAndWrite("[A]\nwidth=1\n", options, "A", "width", "Width", + CheckEquals("[A]\nWidth=1\n", RenameKeyAndWrite("[A]\nwidth=1\n", options, "A", "width", "Width", __func__, __LINE__), __func__, __LINE__, "a new case"); - CheckEquals(std::string("[A]\nwidth=1\n"), RenameKeyAndWrite("[A]\nwidth=1\n", options, "A", "WIDTH", "width", + CheckEquals("[A]\nwidth=1\n", RenameKeyAndWrite("[A]\nwidth=1\n", options, "A", "WIDTH", "width", __func__, __LINE__), __func__, __LINE__, "the name it has changes nothing"); } //--------------------------------------------------------------------------- @@ -3904,18 +3904,18 @@ ASW_TEST(TTest_ASWIni_DocumentRename, RenameKey_RenamesEveryDuplicate) "n", __func__, __LINE__); // Assert - CheckEquals(std::string("[A]\nn=1\nn=2\n[a]\nn=3\n[B]\nk=4\n"), written, __func__, __LINE__, + CheckEquals("[A]\nn=1\nn=2\n[a]\nn=3\n[B]\nk=4\n", written, __func__, __LINE__, "every line of the key in both [A] and [a], and not the key of [B]"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_DocumentRename, RenameSection_ChangesOnlyTheName) { // Act & Assert - CheckEquals(std::string("[ Main ] ; note\nk=1\n"), RenameSectionAndWrite("[ General ] ; note\nk=1\n", "general", + CheckEquals("[ Main ] ; note\nk=1\n", RenameSectionAndWrite("[ General ] ; note\nk=1\n", "general", "Main", __func__, __LINE__), __func__, __LINE__, "the blanks and the comment stay"); - CheckEquals(std::string(" [B]\n"), RenameSectionAndWrite(" [A]\n", "A", "B", __func__, __LINE__), __func__, + CheckEquals(" [B]\n", RenameSectionAndWrite(" [A]\n", "A", "B", __func__, __LINE__), __func__, __LINE__, "the indentation stays"); - CheckEquals(std::string("[B] junk\n"), RenameSectionAndWrite("[A] junk\n", "A", "B", __func__, __LINE__), + CheckEquals("[B] junk\n", RenameSectionAndWrite("[A] junk\n", "A", "B", __func__, __LINE__), __func__, __LINE__, "text after the header stays"); } //--------------------------------------------------------------------------- @@ -3935,9 +3935,9 @@ ASW_TEST(TTest_ASWIni_DocumentRename, RenameSection_FailsWhenMissing) ASW_TEST(TTest_ASWIni_DocumentRename, RenameSection_MayChangeOnlyTheCase) { // Act & Assert - CheckEquals(std::string("[General]\n"), RenameSectionAndWrite("[general]\n", "general", "General", __func__, + CheckEquals("[General]\n", RenameSectionAndWrite("[general]\n", "general", "General", __func__, __LINE__), __func__, __LINE__, "a new case"); - CheckEquals(std::string("[general]\n"), RenameSectionAndWrite("[general]\n", "GENERAL", "general", __func__, + CheckEquals("[general]\n", RenameSectionAndWrite("[general]\n", "GENERAL", "general", __func__, __LINE__), __func__, __LINE__, "the name it has changes nothing"); } //--------------------------------------------------------------------------- @@ -3962,7 +3962,7 @@ ASW_TEST(TTest_ASWIni_DocumentRename, RenameSection_RenamesEveryDuplicate) std::string const written = RenameSectionAndWrite("[A]\nk=1\n[B]\n[a]\nl=2\n", "A", "C", __func__, __LINE__); // Assert - CheckEquals(std::string("[C]\nk=1\n[B]\n[C]\nl=2\n"), written, __func__, __LINE__, "both [A] and [a]"); + CheckEquals("[C]\nk=1\n[B]\n[C]\nl=2\n", written, __func__, __LINE__, "both [A] and [a]"); } //--------------------------------------------------------------------------- @@ -4082,9 +4082,9 @@ ASW_TEST(TTest_ASWIni_DocumentComments, GetFileComment_IsTheBlockAtTheStartBefor TASWIniOptions const options; // Act & Assert - CheckEquals(std::string("a\nb"), Parsed("; a\n# b\n\n[A]\n", options, __func__, __LINE__).GetFileComment(), + CheckEquals("a\nb", Parsed("; a\n# b\n\n[A]\n", options, __func__, __LINE__).GetFileComment(), __func__, __LINE__, "the comment lines at the start, before a blank line"); - CheckEquals(std::string("only"), Parsed("; only\n", options, __func__, __LINE__).GetFileComment(), __func__, + CheckEquals("only", Parsed("; only\n", options, __func__, __LINE__).GetFileComment(), __func__, __LINE__, "comment lines before the end of the file"); CheckEquals(std::string(), Parsed("; a\n[A]\n", options, __func__, __LINE__).GetFileComment(), __func__, __LINE__, "comment lines that lead into the first header are its comment"); @@ -4104,9 +4104,9 @@ ASW_TEST(TTest_ASWIni_DocumentComments, GetKeyComment_IsTheBlockDirectlyAboveThe std::string const duplicates = "[A]\n; first\nk=1\n; second\nk=2\n"; // Act & Assert - CheckEquals(std::string("one\ntwo"), Parsed("[A]\n; one\n ;two\nk=1\n", options, __func__, __LINE__) + CheckEquals("one\ntwo", Parsed("[A]\n; one\n ;two\nk=1\n", options, __func__, __LINE__) .GetKeyComment("A", "k"), __func__, __LINE__, "the comment lines directly above the key"); - CheckEquals(std::string("\nb"), Parsed("[A]\n;\n; b\nk=1\n", options, __func__, __LINE__).GetKeyComment("A", + CheckEquals("\nb", Parsed("[A]\n;\n; b\nk=1\n", options, __func__, __LINE__).GetKeyComment("A", "k"), __func__, __LINE__, "an empty comment line"); CheckEquals(std::string(), Parsed("[A]\n; x\n\nk=1\n", options, __func__, __LINE__).GetKeyComment("A", "k"), __func__, __LINE__, "a comment with a blank line under it isn't the key's"); @@ -4114,9 +4114,9 @@ ASW_TEST(TTest_ASWIni_DocumentComments, GetKeyComment_IsTheBlockDirectlyAboveThe __func__, __LINE__, "a comment above the header isn't the key's"); CheckEquals(std::string(), Parsed("[A]\n; c\nk=1\n", options, __func__, __LINE__).GetKeyComment("A", "x"), __func__, __LINE__, "a missing key has no comment"); - CheckEquals(std::string("first"), Parsed(duplicates, options, __func__, __LINE__).GetKeyComment("A", "k"), + CheckEquals("first", Parsed(duplicates, options, __func__, __LINE__).GetKeyComment("A", "k"), __func__, __LINE__, "the first line's, with FirstWins"); - CheckEquals(std::string("second"), Parsed(duplicates, lastWins, __func__, __LINE__).GetKeyComment("A", "k"), + CheckEquals("second", Parsed(duplicates, lastWins, __func__, __LINE__).GetKeyComment("A", "k"), __func__, __LINE__, "the last line's, with LastWins"); } //--------------------------------------------------------------------------- @@ -4128,15 +4128,15 @@ ASW_TEST(TTest_ASWIni_DocumentComments, GetSectionComment_IsTheBlockDirectlyAbov __LINE__); // Act & Assert - CheckEquals(std::string("about A"), document.GetSectionComment("a"), __func__, __LINE__, + CheckEquals("about A", document.GetSectionComment("a"), __func__, __LINE__, "the comment above the first header, after the file comment"); - CheckEquals(std::string("about B"), document.GetSectionComment("B"), __func__, __LINE__, + CheckEquals("about B", document.GetSectionComment("B"), __func__, __LINE__, "the comment at the end of the section before"); - CheckEquals(std::string("file"), document.GetFileComment(), __func__, __LINE__, "the file comment"); + CheckEquals("file", document.GetFileComment(), __func__, __LINE__, "the file comment"); CheckEquals(std::string(), document.GetKeyComment("A", "k"), __func__, __LINE__, "k has no comment"); CheckEquals(std::string(), document.GetSectionComment(""), __func__, __LINE__, "the preamble has no header"); CheckEquals(std::string(), document.GetSectionComment("X"), __func__, __LINE__, "a missing section"); - CheckEquals(std::string("about A"), Parsed("; about A\n[A]\n", options, __func__, __LINE__).GetSectionComment( + CheckEquals("about A", Parsed("; about A\n[A]\n", options, __func__, __LINE__).GetSectionComment( "A"), __func__, __LINE__, "comment lines that lead into the first header"); CheckEquals(std::string(), Parsed("[A]\n; about a\n[a]\n", options, __func__, __LINE__).GetSectionComment("a"), __func__, __LINE__, "the first section of that name's"); @@ -4213,11 +4213,11 @@ ASW_TEST(TTest_ASWIni_DocumentComments, SetComment_UsesTheWritingCommentPrefix) slashes.Writing.CommentPrefix = "// "; // Act & Assert - CheckEquals(std::string("#note\n\n[A]\n"), FileCommentAndWrite("[A]\n", hash, "note", __func__, __LINE__), + CheckEquals("#note\n\n[A]\n", FileCommentAndWrite("[A]\n", hash, "note", __func__, __LINE__), __func__, __LINE__, "\"#\""); - CheckEquals(std::string("// note\n\n[A]\n"), FileCommentAndWrite("[A]\n", slashes, "note", __func__, __LINE__), + CheckEquals("// note\n\n[A]\n", FileCommentAndWrite("[A]\n", slashes, "note", __func__, __LINE__), __func__, __LINE__, "\"// \""); - CheckEquals(std::string("; a\n;\n; b\n\n[A]\n"), FileCommentAndWrite("[A]\n", options, "a\n\nb", __func__, + CheckEquals("; a\n;\n; b\n\n[A]\n", FileCommentAndWrite("[A]\n", options, "a\n\nb", __func__, __LINE__), __func__, __LINE__, "an empty line gets the prefix without its trailing blank"); } //--------------------------------------------------------------------------- @@ -4229,15 +4229,15 @@ ASW_TEST(TTest_ASWIni_DocumentComments, SetFileComment_AddsItAtTheStartWithABlan lf.Writing.LineEnding = ASWIni::ELineEnding::LF; // Act & Assert - CheckEquals(std::string("; File\n\n[A]\nk=1\n"), FileCommentAndWrite("[A]\nk=1\n", options, "File", __func__, + CheckEquals("; File\n\n[A]\nk=1\n", FileCommentAndWrite("[A]\nk=1\n", options, "File", __func__, __LINE__), __func__, __LINE__, "before the first header, with a blank line"); - CheckEquals(std::string("; File\n\n[A]\n"), FileCommentAndWrite("\n[A]\n", options, "File", __func__, __LINE__), + CheckEquals("; File\n\n[A]\n", FileCommentAndWrite("\n[A]\n", options, "File", __func__, __LINE__), __func__, __LINE__, "no second blank line when one follows already"); - CheckEquals(std::string("; File\n\n; about A\n[A]\n"), FileCommentAndWrite("; about A\n[A]\n", options, "File", + CheckEquals("; File\n\n; about A\n[A]\n", FileCommentAndWrite("; about A\n[A]\n", options, "File", __func__, __LINE__), __func__, __LINE__, "above the comment of the first section"); - CheckEquals(std::string("; File\n\n"), FileCommentAndWrite("", lf, "File", __func__, __LINE__), __func__, + CheckEquals("; File\n\n", FileCommentAndWrite("", lf, "File", __func__, __LINE__), __func__, __LINE__, "an empty document"); - CheckEquals(std::string("; a\n; b\n;\n; c\n\n[A]\n"), FileCommentAndWrite("[A]\n", options, "a\r\nb\n\n c ", + CheckEquals("; a\n; b\n;\n; c\n\n[A]\n", FileCommentAndWrite("[A]\n", options, "a\r\nb\n\n c ", __func__, __LINE__), __func__, __LINE__, "a line for each line of the text, trimmed"); } //--------------------------------------------------------------------------- @@ -4251,7 +4251,7 @@ ASW_TEST(TTest_ASWIni_DocumentComments, SetFileComment_RemovingItLeavesNoFileCom std::string const written = FileCommentAndWrite("; old\n\n; a\n\n[A]\n", options, "", __func__, __LINE__); // Assert - CheckEquals(std::string("\n; a\n\n[A]\n"), written, __func__, __LINE__, + CheckEquals("\n; a\n\n[A]\n", written, __func__, __LINE__, "the blank line under the file comment should stay"); CheckEquals(std::string(), Parsed(written, options, __func__, __LINE__).GetFileComment(), __func__, __LINE__, "the text should have no file comment"); @@ -4265,15 +4265,15 @@ ASW_TEST(TTest_ASWIni_DocumentComments, SetFileComment_ReplacesAndRemovesIt) lf.Writing.LineEnding = ASWIni::ELineEnding::LF; // Act & Assert - CheckEquals(std::string("; new\n\n[A]\n"), FileCommentAndWrite("# old\n# more\n\n[A]\n", options, "new", + CheckEquals("; new\n\n[A]\n", FileCommentAndWrite("# old\n# more\n\n[A]\n", options, "new", __func__, __LINE__), __func__, __LINE__, "every line is replaced; the blank line stays"); - CheckEquals(std::string("[A]\n"), FileCommentAndWrite("# old\n\n[A]\n", options, "", __func__, __LINE__), + CheckEquals("[A]\n", FileCommentAndWrite("# old\n\n[A]\n", options, "", __func__, __LINE__), __func__, __LINE__, "an empty text removes it with the blank line under it"); - CheckEquals(std::string("\n[A]\n"), FileCommentAndWrite("# old\n\n\n[A]\n", options, "", __func__, __LINE__), + CheckEquals("\n[A]\n", FileCommentAndWrite("# old\n\n\n[A]\n", options, "", __func__, __LINE__), __func__, __LINE__, "only one blank line goes with it"); CheckEquals(std::string(), FileCommentAndWrite("; only", lf, "", __func__, __LINE__), __func__, __LINE__, "a file comment with nothing after it"); - CheckEquals(std::string("[A]\n"), FileCommentAndWrite("[A]\n", options, "", __func__, __LINE__), __func__, + CheckEquals("[A]\n", FileCommentAndWrite("[A]\n", options, "", __func__, __LINE__), __func__, __LINE__, "removing a file comment that isn't there changes nothing"); } //--------------------------------------------------------------------------- @@ -4293,11 +4293,11 @@ ASW_TEST(TTest_ASWIni_DocumentComments, SetFileComment_StaysAboveNewKeys) "the section's comment should be set"); // Assert - CheckEquals(std::string("; c\n\nk = v\n\n; about A\n[A]\nx = 1\n"), document.ToText(), __func__, __LINE__, + CheckEquals("; c\n\nk = v\n\n; about A\n[A]\nx = 1\n", document.ToText(), __func__, __LINE__, "the text"); - CheckEquals(std::string("c"), document.GetFileComment(), __func__, __LINE__, "the file comment"); + CheckEquals("c", document.GetFileComment(), __func__, __LINE__, "the file comment"); CheckEquals(std::string(), document.GetKeyComment("", "k"), __func__, __LINE__, "k has no comment"); - CheckEquals(std::string("about A"), document.GetSectionComment("A"), __func__, __LINE__, "the section's comment"); + CheckEquals("about A", document.GetSectionComment("A"), __func__, __LINE__, "the section's comment"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_DocumentComments, SetKeyComment_GoesDirectlyAboveTheKey) @@ -4308,17 +4308,17 @@ ASW_TEST(TTest_ASWIni_DocumentComments, SetKeyComment_GoesDirectlyAboveTheKey) lastWins.Reading.DuplicateKeys = ASWIni::EDuplicateKeys::LastWins; // Act & Assert - CheckEquals(std::string("[A]\n ; note\n k=1\n"), KeyCommentAndWrite("[A]\n k=1\n", options, "A", "k", "note", + CheckEquals("[A]\n ; note\n k=1\n", KeyCommentAndWrite("[A]\n k=1\n", options, "A", "k", "note", __func__, __LINE__), __func__, __LINE__, "with the key's indentation"); - CheckEquals(std::string("[A]\n; new\nk=1\n"), KeyCommentAndWrite("[A]\n; old\nk=1\n", options, "A", "k", "new", + CheckEquals("[A]\n; new\nk=1\n", KeyCommentAndWrite("[A]\n; old\nk=1\n", options, "A", "k", "new", __func__, __LINE__), __func__, __LINE__, "replacing the comment"); - CheckEquals(std::string("[A]\nk=1\n"), KeyCommentAndWrite("[A]\n; old\n# more\nk=1\n", options, "A", "k", "", + CheckEquals("[A]\nk=1\n", KeyCommentAndWrite("[A]\n; old\n# more\nk=1\n", options, "A", "k", "", __func__, __LINE__), __func__, __LINE__, "an empty text removes it"); - CheckEquals(std::string("[A]\n; c\n\n; n\nk=1\n"), KeyCommentAndWrite("[A]\n; c\n\nk=1\n", options, "A", "k", + CheckEquals("[A]\n; c\n\n; n\nk=1\n", KeyCommentAndWrite("[A]\n; c\n\nk=1\n", options, "A", "k", "n", __func__, __LINE__), __func__, __LINE__, "a comment with a blank line under it stays"); - CheckEquals(std::string("[A]\nk=1\n; n\nk=2\n"), KeyCommentAndWrite("[A]\nk=1\nk=2\n", lastWins, "A", "k", "n", + CheckEquals("[A]\nk=1\n; n\nk=2\n", KeyCommentAndWrite("[A]\nk=1\nk=2\n", lastWins, "A", "k", "n", __func__, __LINE__), __func__, __LINE__, "above the winning line"); - CheckEquals(std::string("; n\nk=1\n[A]\n"), KeyCommentAndWrite("k=1\n[A]\n", options, "", "k", "n", __func__, + CheckEquals("; n\nk=1\n[A]\n", KeyCommentAndWrite("k=1\n[A]\n", options, "", "k", "n", __func__, __LINE__), __func__, __LINE__, "a key at the start of the file, whose comment isn't the file comment"); } //--------------------------------------------------------------------------- @@ -4328,15 +4328,15 @@ ASW_TEST(TTest_ASWIni_DocumentComments, SetSectionComment_GoesDirectlyAboveTheHe TASWIniOptions const options; // Act & Assert - CheckEquals(std::string("[A]\nk=1\n\n ; about B\n [B]\n"), SectionCommentAndWrite("[A]\nk=1\n\n [B]\n", + CheckEquals("[A]\nk=1\n\n ; about B\n [B]\n", SectionCommentAndWrite("[A]\nk=1\n\n [B]\n", options, "B", "about B", __func__, __LINE__), __func__, __LINE__, "with the header's indentation"); - CheckEquals(std::string("; about A\n[A]\n"), SectionCommentAndWrite("[A]\n", options, "A", "about A", __func__, + CheckEquals("; about A\n[A]\n", SectionCommentAndWrite("[A]\n", options, "A", "about A", __func__, __LINE__), __func__, __LINE__, "the first header, with an empty preamble"); - CheckEquals(std::string("; file\n\n; about A\n[A]\n"), SectionCommentAndWrite("; file\n\n[A]\n", options, "A", + CheckEquals("; file\n\n; about A\n[A]\n", SectionCommentAndWrite("; file\n\n[A]\n", options, "A", "about A", __func__, __LINE__), __func__, __LINE__, "under the file comment"); - CheckEquals(std::string("[A]\n[B]\n"), SectionCommentAndWrite("[A]\n; old\n[B]\n", options, "B", "", __func__, + CheckEquals("[A]\n[B]\n", SectionCommentAndWrite("[A]\n; old\n[B]\n", options, "B", "", __func__, __LINE__), __func__, __LINE__, "an empty text removes it"); - CheckEquals(std::string("; x\n[A]\n[B]\n[a]\n"), SectionCommentAndWrite("[A]\n[B]\n[a]\n", options, "a", "x", + CheckEquals("; x\n[A]\n[B]\n[a]\n", SectionCommentAndWrite("[A]\n[B]\n[a]\n", options, "a", "x", __func__, __LINE__), __func__, __LINE__, "the first section of that name"); } //--------------------------------------------------------------------------- diff --git a/tests/tests/Test_ASWIni_File.cpp b/tests/tests/Test_ASWIni_File.cpp index 414a590..ae14eac 100644 --- a/tests/tests/Test_ASWIni_File.cpp +++ b/tests/tests/Test_ASWIni_File.cpp @@ -194,7 +194,7 @@ ASW_TEST(TTest_ASWIni_File, ReadWholeFile_LargerThanMaxSize) CheckContains(tooLarge.Message, "11 bytes", __func__, __LINE__, "the message should give the file's size"); CheckEmpty(contentsAfterFailure, __func__, __LINE__, "nothing should be read from a file that is too large"); CheckTrue(exactSize.IsOk(), __func__, __LINE__, "a file of exactly the limit should be read: " + exactSize.Message); - CheckEquals(std::string("0123456789A"), contents, __func__, __LINE__, "the whole file should be read"); + CheckEquals("0123456789A", contents, __func__, __LINE__, "the whole file should be read"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_File, ReadWholeFile_MissingFile) @@ -304,9 +304,9 @@ ASW_TEST(TTest_ASWIni_File, WriteWholeFile_Backup_CopiesPreviousFile) CheckTrue(result.IsOk(), __func__, __LINE__, "the file should be saved: " + result.Message); CheckEmpty(warnings, __func__, __LINE__, "there should be no warnings"); CheckTrue(ReadTestFile(path, contents), __func__, __LINE__, "the file should be readable"); - CheckEquals(std::string("new"), contents, __func__, __LINE__, "the file should have the new contents"); + CheckEquals("new", contents, __func__, __LINE__, "the file should have the new contents"); CheckTrue(ReadTestFile(folder.Path() / "app.ini.bak", backup), __func__, __LINE__, "the backup should exist"); - CheckEquals(std::string("old"), backup, __func__, __LINE__, "the backup should have the previous contents"); + CheckEquals("old", backup, __func__, __LINE__, "the backup should have the previous contents"); // Act: a second save replaces the older backup ASWIni::TASWIniResult const second = ASWIni::Detail::WriteWholeFile(path, "newer", options, warnings); @@ -314,7 +314,7 @@ ASW_TEST(TTest_ASWIni_File, WriteWholeFile_Backup_CopiesPreviousFile) // Assert CheckTrue(second.IsOk(), __func__, __LINE__, "the second save should succeed: " + second.Message); CheckTrue(ReadTestFile(folder.Path() / "app.ini.bak", backup), __func__, __LINE__, "the backup should exist"); - CheckEquals(std::string("new"), backup, __func__, __LINE__, "the backup should be replaced"); + CheckEquals("new", backup, __func__, __LINE__, "the backup should be replaced"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_File, WriteWholeFile_Backup_SkippedForNewFile) @@ -375,7 +375,7 @@ ASW_TEST(TTest_ASWIni_File, WriteWholeFile_CreatesMissingFolders) std::string contents; CheckTrue(result.IsOk(), __func__, __LINE__, "the file should be saved: " + result.Message); CheckTrue(ReadTestFile(path, contents), __func__, __LINE__, "the file should be in the new folders"); - CheckEquals(std::string("x"), contents, __func__, __LINE__, "the file should have its contents"); + CheckEquals("x", contents, __func__, __LINE__, "the file should have its contents"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_File, WriteWholeFile_EmptyPath) @@ -415,7 +415,7 @@ ASW_TEST(TTest_ASWIni_File, WriteWholeFile_FailedReplace_KeepsTargetAndRemovesTe CheckEquals(1, static_cast(CountEntries(folder.Path())), __func__, __LINE__, "no temporary file should be left"); CheckTrue(ReadTestFile(path / "inside.txt", inside), __func__, __LINE__, "the folder should be untouched"); - CheckEquals(std::string("kept"), inside, __func__, __LINE__, "the folder's file should be unchanged"); + CheckEquals("kept", inside, __func__, __LINE__, "the folder's file should be unchanged"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_File, WriteWholeFile_InPlace_OverwritesAndTruncates) @@ -437,7 +437,7 @@ ASW_TEST(TTest_ASWIni_File, WriteWholeFile_InPlace_OverwritesAndTruncates) std::string contents; CheckTrue(result.IsOk(), __func__, __LINE__, "the file should be saved: " + result.Message); CheckTrue(ReadTestFile(path, contents), __func__, __LINE__, "the file should be readable"); - CheckEquals(std::string("short"), contents, __func__, __LINE__, "the old contents should be cut off"); + CheckEquals("short", contents, __func__, __LINE__, "the old contents should be cut off"); CheckEquals(1, static_cast(CountEntries(folder.Path())), __func__, __LINE__, "no other file should be made"); } @@ -472,7 +472,7 @@ ASW_TEST(TTest_ASWIni_File, WriteWholeFile_KeepsHiddenAttribute) CheckTrue((attributesAfterInPlace & FILE_ATTRIBUTE_HIDDEN) != 0, __func__, __LINE__, "the file should still be hidden after an in-place save"); CheckTrue(ReadTestFile(path, contents), __func__, __LINE__, "the file should be readable"); - CheckEquals(std::string("newer"), contents, __func__, __LINE__, "the file should have the last contents"); + CheckEquals("newer", contents, __func__, __LINE__, "the file should have the last contents"); } #endif //--------------------------------------------------------------------------- @@ -521,7 +521,7 @@ ASW_TEST(TTest_ASWIni_File, WriteWholeFile_KeepsSymbolicLink) CheckTrue(result.IsOk(), __func__, __LINE__, "the file should be saved: " + result.Message); CheckTrue(std::filesystem::is_symlink(link, error), __func__, __LINE__, "the link should still be a link"); CheckTrue(ReadTestFile(real, contents), __func__, __LINE__, "the linked file should be readable"); - CheckEquals(std::string("new"), contents, __func__, __LINE__, "the linked file should have the new contents"); + CheckEquals("new", contents, __func__, __LINE__, "the linked file should have the new contents"); } #endif //--------------------------------------------------------------------------- @@ -543,7 +543,7 @@ ASW_TEST(TTest_ASWIni_File, WriteWholeFile_NonAsciiPath) // Assert CheckTrue(written.IsOk(), __func__, __LINE__, "the file should be saved: " + written.Message); CheckTrue(read.IsOk(), __func__, __LINE__, "the file should be read: " + read.Message); - CheckEquals(std::string("x"), contents, __func__, __LINE__, "the file should have its contents"); + CheckEquals("x", contents, __func__, __LINE__, "the file should have its contents"); #if defined(_WIN32) std::error_code error; CheckTrue(std::filesystem::exists(folder.Path() / L"caf\x00E9" / L"\x03BB.ini", error), __func__, __LINE__, @@ -573,7 +573,7 @@ ASW_TEST(TTest_ASWIni_File, WriteWholeFile_ReadOnlyFile_Fails) CheckEquals(static_cast(ERROR_ACCESS_DENIED), result.SystemError, __func__, __LINE__, "the system error should be access denied"); CheckTrue(ReadTestFile(path, contents), __func__, __LINE__, "the file should still be readable"); - CheckEquals(std::string("old"), contents, __func__, __LINE__, "the file should be unchanged"); + CheckEquals("old", contents, __func__, __LINE__, "the file should be unchanged"); CheckEquals(1, static_cast(CountEntries(folder.Path())), __func__, __LINE__, "no temporary file should be left"); @@ -600,7 +600,7 @@ ASW_TEST(TTest_ASWIni_File, WriteWholeFile_ReplacesFile) CheckTrue(result.IsOk(), __func__, __LINE__, "the file should be saved: " + result.Message); CheckEmpty(warnings, __func__, __LINE__, "there should be no warnings"); CheckTrue(ReadTestFile(path, contents), __func__, __LINE__, "the file should be readable"); - CheckEquals(std::string("new"), contents, __func__, __LINE__, "the file should have only the new contents"); + CheckEquals("new", contents, __func__, __LINE__, "the file should have only the new contents"); CheckEquals(1, static_cast(CountEntries(folder.Path())), __func__, __LINE__, "no temporary file should be left"); } diff --git a/tests/tests/Test_ASWIni_Interface.cpp b/tests/tests/Test_ASWIni_Interface.cpp index 4af8d43..9be0308 100644 --- a/tests/tests/Test_ASWIni_Interface.cpp +++ b/tests/tests/Test_ASWIni_Interface.cpp @@ -545,8 +545,8 @@ ASW_TEST(TTest_ASWIni_Interface, GetValue_ConvertsTheValue) CheckTrue(maximized, __func__, __LINE__, "a bool should be read"); CheckTrue(zoom == 1.5, __func__, __LINE__, "a double should be read"); CheckTrue(color == EColor::Green, __func__, __LINE__, "an enum should be read by name"); - CheckEquals(std::string("{10, 20, 30}"), ListText(columns), __func__, __LINE__, "a list should be read"); - CheckEquals(std::string("My \"App\""), title, __func__, __LINE__, "a std::string should be the text"); + CheckEquals("{10, 20, 30}", ListText(columns), __func__, __LINE__, "a list should be read"); + CheckEquals("My \"App\"", title, __func__, __LINE__, "a std::string should be the text"); CheckEquals(-7LL, global, __func__, __LINE__, "a key before the first section should be read"); CheckEquals(std::size_t(0), ini.Reported.size(), __func__, __LINE__, "nothing should be reported"); } @@ -571,8 +571,8 @@ ASW_TEST(TTest_ASWIni_Interface, GetValue_InvalidValueGivesTheDefaultAndAWarning "converter's code"); CheckEquals(ConverterMessage("wide"), message.Text, __func__, __LINE__, "the message should have the converter's text"); - CheckEquals(std::string("Window"), message.Section, __func__, __LINE__, "the message should name the section"); - CheckEquals(std::string("Width"), message.Key, __func__, __LINE__, "the message should name the key"); + CheckEquals("Window", message.Section, __func__, __LINE__, "the message should name the section"); + CheckEquals("Width", message.Key, __func__, __LINE__, "the message should name the key"); CheckEquals(std::string(), message.FilePath, __func__, __LINE__, "the file path should be left to Report()"); CheckEquals(std::size_t(0), message.Line, __func__, __LINE__, "the message should have no line"); } @@ -592,7 +592,7 @@ ASW_TEST(TTest_ASWIni_Interface, GetValue_MissingKeyGivesTheDefault) // Assert CheckEquals(480, height, __func__, __LINE__, "a missing key should give the default"); CheckEquals(320, width, __func__, __LINE__, "a key of a missing section should give the default"); - CheckEquals(std::string("{1, 2}"), ListText(columns), __func__, __LINE__, "a missing list should be the default"); + CheckEquals("{1, 2}", ListText(columns), __func__, __LINE__, "a missing list should be the default"); CheckEquals(std::size_t(0), ini.Reported.size(), __func__, __LINE__, "a missing key should report nothing"); } //--------------------------------------------------------------------------- @@ -641,12 +641,12 @@ ASW_TEST(TTest_ASWIni_Interface, GetValue_TextDefaultGivesTheText) std::string const fromView = ini.GetValue("App", "Missing", std::string_view("view")); // Assert - CheckEquals(std::string(" My App "), name, __func__, __LINE__, "the text should be the value as it is"); - CheckEquals(std::string("Default"), literal, __func__, __LINE__, "a missing key should give a literal default"); + CheckEquals(" My App ", name, __func__, __LINE__, "the text should be the value as it is"); + CheckEquals("Default", literal, __func__, __LINE__, "a missing key should give a literal default"); CheckEquals(std::string(), fromNull, __func__, __LINE__, "a nullptr default should be empty"); - CheckEquals(std::string("buffer"), fromBuffer, __func__, __LINE__, "a char array default should be its text"); - CheckEquals(std::string("buffer"), fromPointer, __func__, __LINE__, "a char pointer default should be its text"); - CheckEquals(std::string("view"), fromView, __func__, __LINE__, "a std::string_view default should be its text"); + CheckEquals("buffer", fromBuffer, __func__, __LINE__, "a char array default should be its text"); + CheckEquals("buffer", fromPointer, __func__, __LINE__, "a char pointer default should be its text"); + CheckEquals("view", fromView, __func__, __LINE__, "a std::string_view default should be its text"); CheckEquals(std::size_t(0), ini.ValueOptionsCalls, __func__, __LINE__, "a text needs no converter, so no value options"); } @@ -686,7 +686,7 @@ ASW_TEST(TTest_ASWIni_Interface, GetValue_UsesTheGivenValueOptions) // Assert CheckEquals(std::size_t(2), columns.size(), __func__, __LINE__, "the list should be split at the given delimiter"); if (columns.size() == 2) - CheckEquals(std::string("20, 30"), columns[1], __func__, __LINE__, "the default delimiter should be text"); + CheckEquals("20, 30", columns[1], __func__, __LINE__, "the default delimiter should be text"); CheckEquals(std::size_t(0), ini.ValueOptionsCalls, __func__, __LINE__, "the object's value options shouldn't be asked for"); @@ -753,12 +753,12 @@ ASW_TEST(TTest_ASWIni_Interface, SetValue_ConverterExceptionIsReported) // Assert CheckEquals(EIniCode::UnexpectedException, stdResult.Code, __func__, __LINE__, "a std::exception should be UnexpectedException"); - CheckEquals(std::string("The key \"Value\" of the section \"Broken\" can't be set: The converter is broken."), + CheckEquals("The key \"Value\" of the section \"Broken\" can't be set: The converter is broken.", stdResult.Message, __func__, __LINE__, "the message should give what()"); CheckEquals(EIniCode::UnexpectedException, otherResult.Code, __func__, __LINE__, "another exception should be UnexpectedException"); - CheckEquals(std::string("The key \"Value\" of the section \"Broken\" can't be set: An exception that isn't a " - "std::exception was thrown."), otherResult.Message, __func__, __LINE__, + CheckEquals("The key \"Value\" of the section \"Broken\" can't be set: An exception that isn't a " + "std::exception was thrown.", otherResult.Message, __func__, __LINE__, "the message should say what was thrown"); CheckEquals(std::size_t(2), ini.Reported.size(), __func__, __LINE__, "each failure should be reported"); if (ini.Reported.size() == 2) @@ -811,7 +811,7 @@ ASW_TEST(TTest_ASWIni_Interface, SetValue_SetTextFailureIsReturned) // Assert CheckEquals(EIniCode::InvalidArgument, typed.Code, __func__, __LINE__, "SetText()'s failure should be returned"); - CheckEquals(std::string("The key name is empty."), typed.Message, __func__, __LINE__, + CheckEquals("The key name is empty.", typed.Message, __func__, __LINE__, "SetText()'s message should be returned as it is"); CheckEquals(EIniCode::InvalidArgument, text.Code, __func__, __LINE__, "SetText()'s failure should be returned for a text too"); @@ -863,7 +863,7 @@ ASW_TEST(TTest_ASWIni_Interface, SetValue_UsesTheGivenValueOptions) CheckTrue(result.IsOk(), __func__, __LINE__, "the value should be set"); CheckEquals(std::size_t(1), ini.SetTextCalls.size(), __func__, __LINE__, "the value should be set with SetText()"); if (ini.SetTextCalls.size() == 1) - CheckEquals(std::string("[Window] Maximized=on"), ini.SetTextCalls[0], __func__, __LINE__, + CheckEquals("[Window] Maximized=on", ini.SetTextCalls[0], __func__, __LINE__, "the value should be written as the given options say"); CheckEquals(std::size_t(0), ini.ValueOptionsCalls, __func__, __LINE__, @@ -883,7 +883,7 @@ ASW_TEST(TTest_ASWIni_Interface, SetValue_UsesTheValueOptions) CheckTrue(result.IsOk(), __func__, __LINE__, "the value should be set"); CheckEquals(std::size_t(1), ini.SetTextCalls.size(), __func__, __LINE__, "the value should be set with SetText()"); if (ini.SetTextCalls.size() == 1) - CheckEquals(std::string("[Window] Maximized=yes"), ini.SetTextCalls[0], __func__, __LINE__, + CheckEquals("[Window] Maximized=yes", ini.SetTextCalls[0], __func__, __LINE__, "the value should be written as the object's options say"); CheckEquals(std::size_t(1), ini.ValueOptionsCalls, __func__, __LINE__, @@ -906,12 +906,12 @@ ASW_TEST(TTest_ASWIni_Interface, TryGetValue_ConverterExceptionIsReturned) // Assert CheckEquals(EIniCode::UnexpectedException, stdResult.Code, __func__, __LINE__, "a std::exception should be UnexpectedException"); - CheckEquals(std::string("The key \"Std\" of the section \"Broken\" can't be read: The converter is broken."), + CheckEquals("The key \"Std\" of the section \"Broken\" can't be read: The converter is broken.", stdResult.Message, __func__, __LINE__, "the message should give what()"); CheckEquals(EIniCode::UnexpectedException, otherResult.Code, __func__, __LINE__, "another exception should be UnexpectedException"); - CheckEquals(std::string("The key \"Other\" of the section \"Broken\" can't be read: An exception that isn't a " - "std::exception was thrown."), otherResult.Message, __func__, __LINE__, + CheckEquals("The key \"Other\" of the section \"Broken\" can't be read: An exception that isn't a " + "std::exception was thrown.", otherResult.Message, __func__, __LINE__, "the message should say what was thrown"); CheckFalse(value.StdException, __func__, __LINE__, "the value should stay as it was"); CheckEquals(std::size_t(0), ini.Reported.size(), __func__, __LINE__, "nothing should be reported"); @@ -938,7 +938,7 @@ ASW_TEST(TTest_ASWIni_Interface, TryGetValue_ConvertsTheValue) "every value should be read"); CheckEquals(640, width, __func__, __LINE__, "an int should be read"); CheckTrue(color == EColor::Green, __func__, __LINE__, "an enum should be read"); - CheckEquals(std::string(" My App "), title, __func__, __LINE__, "a std::string should be the text as it is"); + CheckEquals(" My App ", title, __func__, __LINE__, "a std::string should be the text as it is"); CheckEquals(std::size_t(0), ini.Reported.size(), __func__, __LINE__, "nothing should be reported"); } //--------------------------------------------------------------------------- @@ -980,7 +980,7 @@ ASW_TEST(TTest_ASWIni_Interface, TryGetValue_MissingKeyIsNotFound) // Assert CheckEquals(EIniCode::NotFound, result.Code, __func__, __LINE__, "a missing key should be NotFound"); - CheckEquals(std::string("The key \"Height\" of the section \"Window\" doesn't exist."), result.Message, __func__, + CheckEquals("The key \"Height\" of the section \"Window\" doesn't exist.", result.Message, __func__, __LINE__, "the message should name the key and section"); CheckEquals(480, height, __func__, __LINE__, "the value should stay as it was"); CheckEquals(std::size_t(0), ini.Reported.size(), __func__, __LINE__, "nothing should be reported"); @@ -1002,7 +1002,7 @@ ASW_TEST(TTest_ASWIni_Interface, TryGetValue_UsesTheGivenValueOptions) // Assert CheckTrue(result.IsOk(), __func__, __LINE__, "the list should be read"); - CheckEquals(std::string("{10, 20}"), ListText(columns), __func__, __LINE__, + CheckEquals("{10, 20}", ListText(columns), __func__, __LINE__, "the list should be split at the given delimiter"); CheckEquals(std::size_t(0), ini.ValueOptionsCalls, __func__, __LINE__, "the object's value options shouldn't be asked for"); @@ -1021,7 +1021,7 @@ ASW_TEST(TTest_ASWIni_Interface, TryGetValue_UsesTheValueOptions) // Assert CheckTrue(result.IsOk(), __func__, __LINE__, "the list should be read"); - CheckEquals(std::string("{10, 20}"), ListText(columns), __func__, __LINE__, + CheckEquals("{10, 20}", ListText(columns), __func__, __LINE__, "the list should be split at the object's delimiter"); CheckEquals(std::size_t(1), ini.ValueOptionsCalls, __func__, __LINE__, "the object's value options should be asked for once"); diff --git a/tests/tests/Test_ASWIni_Options.cpp b/tests/tests/Test_ASWIni_Options.cpp index 0caf478..9cd3633 100644 --- a/tests/tests/Test_ASWIni_Options.cpp +++ b/tests/tests/Test_ASWIni_Options.cpp @@ -97,10 +97,10 @@ ASW_TEST(TTest_ASWIni_ReadingOptions, Defaults_MatchDocumentedValues) // Assert // The defaults the README and the 1.0 decisions document - CheckEquals(std::string("=:"), options.Separators, __func__, __LINE__, "Separators"); + CheckEquals("=:", options.Separators, __func__, __LINE__, "Separators"); AssertEquals(2, static_cast(options.CommentPrefixes.size()), __func__, __LINE__, "two comment prefixes"); - CheckEquals(std::string(";"), options.CommentPrefixes[0], __func__, __LINE__, "the first comment prefix"); - CheckEquals(std::string("#"), options.CommentPrefixes[1], __func__, __LINE__, "the second comment prefix"); + CheckEquals(";", options.CommentPrefixes[0], __func__, __LINE__, "the first comment prefix"); + CheckEquals("#", options.CommentPrefixes[1], __func__, __LINE__, "the second comment prefix"); CheckFalse(options.InlineComments, __func__, __LINE__, "InlineComments should be off"); CheckFalse(options.QuotedValues, __func__, __LINE__, "QuotedValues should be off"); CheckFalse(options.CaseSensitive, __func__, __LINE__, "names should be case-insensitive"); @@ -113,11 +113,11 @@ ASW_TEST(TTest_ASWIni_ReadingOptions, Defaults_MatchDocumentedValues) //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_ReadingOptions, ToString_DuplicateKeysNames) { - CheckEquals(std::string("FirstWins"), std::string(ASWIni::ToString(ASWIni::EDuplicateKeys::FirstWins)), __func__, + CheckEquals("FirstWins", ASWIni::ToString(ASWIni::EDuplicateKeys::FirstWins), __func__, __LINE__, "EDuplicateKeys::FirstWins"); - CheckEquals(std::string("LastWins"), std::string(ASWIni::ToString(ASWIni::EDuplicateKeys::LastWins)), __func__, + CheckEquals("LastWins", ASWIni::ToString(ASWIni::EDuplicateKeys::LastWins), __func__, __LINE__, "EDuplicateKeys::LastWins"); - CheckEquals(std::string("Unknown"), std::string(ASWIni::ToString(static_cast(99))), + CheckEquals("Unknown", ASWIni::ToString(static_cast(99)), __func__, __LINE__, "an unknown value"); } //--------------------------------------------------------------------------- @@ -262,8 +262,8 @@ ASW_TEST(TTest_ASWIni_WritingOptions, Defaults_MatchDocumentedValues) // Assert // The defaults the README and the 1.0 decisions document - CheckEquals(std::string(" = "), options.Separator, __func__, __LINE__, "Separator"); - CheckEquals(std::string("; "), options.CommentPrefix, __func__, __LINE__, "CommentPrefix"); + CheckEquals(" = ", options.Separator, __func__, __LINE__, "Separator"); + CheckEquals("; ", options.CommentPrefix, __func__, __LINE__, "CommentPrefix"); CheckEquals(ASWIni::ELineEnding::Auto, options.LineEnding, __func__, __LINE__, "LineEnding"); CheckEquals(ASWIni::EBomMode::Auto, options.Bom, __func__, __LINE__, "Bom"); CheckTrue(options.BlankLineBeforeNewSection, __func__, __LINE__, "BlankLineBeforeNewSection should be on"); @@ -272,29 +272,29 @@ ASW_TEST(TTest_ASWIni_WritingOptions, Defaults_MatchDocumentedValues) //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_WritingOptions, ToString_EnumNames) { - CheckEquals(std::string("Auto"), std::string(ASWIni::ToString(ASWIni::ELineEnding::Auto)), __func__, __LINE__, + CheckEquals("Auto", ASWIni::ToString(ASWIni::ELineEnding::Auto), __func__, __LINE__, "ELineEnding::Auto"); - CheckEquals(std::string("Native"), std::string(ASWIni::ToString(ASWIni::ELineEnding::Native)), __func__, __LINE__, + CheckEquals("Native", ASWIni::ToString(ASWIni::ELineEnding::Native), __func__, __LINE__, "ELineEnding::Native"); - CheckEquals(std::string("LF"), std::string(ASWIni::ToString(ASWIni::ELineEnding::LF)), __func__, __LINE__, + CheckEquals("LF", ASWIni::ToString(ASWIni::ELineEnding::LF), __func__, __LINE__, "ELineEnding::LF"); - CheckEquals(std::string("CRLF"), std::string(ASWIni::ToString(ASWIni::ELineEnding::CRLF)), __func__, __LINE__, + CheckEquals("CRLF", ASWIni::ToString(ASWIni::ELineEnding::CRLF), __func__, __LINE__, "ELineEnding::CRLF"); - CheckEquals(std::string("Auto"), std::string(ASWIni::ToString(ASWIni::EBomMode::Auto)), __func__, __LINE__, + CheckEquals("Auto", ASWIni::ToString(ASWIni::EBomMode::Auto), __func__, __LINE__, "EBomMode::Auto"); - CheckEquals(std::string("Always"), std::string(ASWIni::ToString(ASWIni::EBomMode::Always)), __func__, __LINE__, + CheckEquals("Always", ASWIni::ToString(ASWIni::EBomMode::Always), __func__, __LINE__, "EBomMode::Always"); - CheckEquals(std::string("Never"), std::string(ASWIni::ToString(ASWIni::EBomMode::Never)), __func__, __LINE__, + CheckEquals("Never", ASWIni::ToString(ASWIni::EBomMode::Never), __func__, __LINE__, "EBomMode::Never"); - CheckEquals(std::string("Unknown"), std::string(ASWIni::ToString(static_cast(99))), __func__, + CheckEquals("Unknown", ASWIni::ToString(static_cast(99)), __func__, __LINE__, "an unknown ELineEnding"); - CheckEquals(std::string("CodeWins"), std::string(ASWIni::ToString(ASWIni::ECommentPolicy::CodeWins)), __func__, + CheckEquals("CodeWins", ASWIni::ToString(ASWIni::ECommentPolicy::CodeWins), __func__, __LINE__, "ECommentPolicy::CodeWins"); - CheckEquals(std::string("FileWins"), std::string(ASWIni::ToString(ASWIni::ECommentPolicy::FileWins)), __func__, + CheckEquals("FileWins", ASWIni::ToString(ASWIni::ECommentPolicy::FileWins), __func__, __LINE__, "ECommentPolicy::FileWins"); - CheckEquals(std::string("Unknown"), std::string(ASWIni::ToString(static_cast(99))), __func__, + CheckEquals("Unknown", ASWIni::ToString(static_cast(99)), __func__, __LINE__, "an unknown EBomMode"); - CheckEquals(std::string("Unknown"), std::string(ASWIni::ToString(static_cast(99))), + CheckEquals("Unknown", ASWIni::ToString(static_cast(99)), __func__, __LINE__, "an unknown ECommentPolicy"); } //--------------------------------------------------------------------------- @@ -429,7 +429,7 @@ ASW_TEST(TTest_ASWIni_SavingOptions, Defaults_MatchDocumentedValues) // The defaults the README and the 1.0 decisions document CheckTrue(options.AtomicSave, __func__, __LINE__, "AtomicSave should be on"); CheckFalse(options.Backup, __func__, __LINE__, "Backup should be off"); - CheckEquals(std::string(".bak"), options.BackupSuffix, __func__, __LINE__, "BackupSuffix"); + CheckEquals(".bak", options.BackupSuffix, __func__, __LINE__, "BackupSuffix"); CheckTrue(options.CreateFolders, __func__, __LINE__, "CreateFolders should be on"); } //--------------------------------------------------------------------------- @@ -523,15 +523,15 @@ ASW_TEST(TTest_ASWIni_ValueOptions, Defaults_MatchDocumentedValues) //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_ValueOptions, ToString_BoolFormatNames) { - CheckEquals(std::string("TrueFalse"), std::string(ASWIni::ToString(ASWIni::EBoolFormat::TrueFalse)), __func__, + CheckEquals("TrueFalse", ASWIni::ToString(ASWIni::EBoolFormat::TrueFalse), __func__, __LINE__, "EBoolFormat::TrueFalse"); - CheckEquals(std::string("YesNo"), std::string(ASWIni::ToString(ASWIni::EBoolFormat::YesNo)), __func__, __LINE__, + CheckEquals("YesNo", ASWIni::ToString(ASWIni::EBoolFormat::YesNo), __func__, __LINE__, "EBoolFormat::YesNo"); - CheckEquals(std::string("OnOff"), std::string(ASWIni::ToString(ASWIni::EBoolFormat::OnOff)), __func__, __LINE__, + CheckEquals("OnOff", ASWIni::ToString(ASWIni::EBoolFormat::OnOff), __func__, __LINE__, "EBoolFormat::OnOff"); - CheckEquals(std::string("OneZero"), std::string(ASWIni::ToString(ASWIni::EBoolFormat::OneZero)), __func__, + CheckEquals("OneZero", ASWIni::ToString(ASWIni::EBoolFormat::OneZero), __func__, __LINE__, "EBoolFormat::OneZero"); - CheckEquals(std::string("Unknown"), std::string(ASWIni::ToString(static_cast(99))), __func__, + CheckEquals("Unknown", ASWIni::ToString(static_cast(99)), __func__, __LINE__, "an unknown EBoolFormat"); } //--------------------------------------------------------------------------- diff --git a/tests/tests/Test_ASWIni_Settings.cpp b/tests/tests/Test_ASWIni_Settings.cpp index 1fd62d6..2f7b880 100644 --- a/tests/tests/Test_ASWIni_Settings.cpp +++ b/tests/tests/Test_ASWIni_Settings.cpp @@ -405,8 +405,8 @@ ASW_TEST(TTest_ASWIni_SettingsAccess, Get_InvalidValueGivesTheDefault) CheckEquals(EIniCode::InvalidValue, messages[0].Code, __func__, __LINE__, "the code should be the converter's"); CheckEquals(widthProblem + " The default value \"640\" is used.", messages[0].Text, __func__, __LINE__, "the text should give the converter's problem and the default value"); - CheckEquals(std::string("General"), messages[0].Section, __func__, __LINE__, "the message should name the section"); - CheckEquals(std::string("Width"), messages[0].Key, __func__, __LINE__, "the message should name the key"); + CheckEquals("General", messages[0].Section, __func__, __LINE__, "the message should name the section"); + CheckEquals("Width", messages[0].Key, __func__, __LINE__, "the message should name the key"); CheckEquals(levelProblem + " The default value is used.", messages[1].Text, __func__, __LINE__, "a default value that can't be written should be left out of the text"); CheckEquals(text, ini.ToText(), __func__, __LINE__, "Get() shouldn't change the document"); @@ -429,7 +429,7 @@ ASW_TEST(TTest_ASWIni_SettingsAccess, Get_ReadsTheDocument) // Act & Assert CheckEquals(16, number.Get(), __func__, __LINE__, "the value should be read, with the names' case ignored"); CheckTrue(enabled.Get(), __func__, __LINE__, "a bool should be read in any of its forms"); - CheckEquals(std::string("spaced"), name.Get(), __func__, __LINE__, "a text should be the document's value"); + CheckEquals("spaced", name.Get(), __func__, __LINE__, "a text should be the document's value"); CheckTrue(level.Get() == ELevel::High, __func__, __LINE__, "an enum should be read by name"); CheckTrue(items.Get() == std::vector{ 1, 2, 3 }, __func__, __LINE__, "a list should be read"); CheckTrue(number.IsPresent(), __func__, __LINE__, "a key in the document should be present"); @@ -443,7 +443,7 @@ ASW_TEST(TTest_ASWIni_SettingsAccess, Get_ReadsTheDocument) static_cast(ini.LoadText("")); CheckFalse(enabled.Get(), __func__, __LINE__, "a document loaded again should be read"); - CheckEquals(std::string("none"), name.Get(), __func__, __LINE__, "an empty document should give the defaults"); + CheckEquals("none", name.Get(), __func__, __LINE__, "an empty document should give the defaults"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_SettingsAccess, New_GivesTheDefaults) @@ -462,16 +462,16 @@ ASW_TEST(TTest_ASWIni_SettingsAccess, New_GivesTheDefaults) // Assert CheckEquals(640, widthValue, __func__, __LINE__, "a missing key should give the default"); - CheckEquals(std::string("app"), nameValue, __func__, __LINE__, "a missing key should give the default"); + CheckEquals("app", nameValue, __func__, __LINE__, "a missing key should give the default"); CheckFalse(width.IsPresent(), __func__, __LINE__, "a missing key shouldn't be present"); CheckTrue(&general.GetOwner() == &ini, __func__, __LINE__, "the section should keep its owner"); - CheckEquals(std::string("General"), general.GetName(), __func__, __LINE__, "the section should keep its name"); - CheckEquals(std::string("The general settings"), general.GetComment(), __func__, __LINE__, + CheckEquals("General", general.GetName(), __func__, __LINE__, "the section should keep its name"); + CheckEquals("The general settings", general.GetComment(), __func__, __LINE__, "the section should keep its comment"); - CheckEquals(std::string("General"), width.GetSectionName(), __func__, __LINE__, + CheckEquals("General", width.GetSectionName(), __func__, __LINE__, "the setting should keep its section's name"); - CheckEquals(std::string("Width"), width.GetKey(), __func__, __LINE__, "the setting should keep its key"); - CheckEquals(std::string("In pixels"), width.GetComment(), __func__, __LINE__, + CheckEquals("Width", width.GetKey(), __func__, __LINE__, "the setting should keep its key"); + CheckEquals("In pixels", width.GetComment(), __func__, __LINE__, "the setting should keep its comment"); CheckEquals(std::string(), name.GetComment(), __func__, __LINE__, "a setting without a comment should have none"); CheckEquals(640, width.GetDefault(), __func__, __LINE__, "the setting should keep its default"); @@ -569,25 +569,25 @@ ASW_TEST(TTest_ASWIni_SettingsAccess, Range_ChecksGetAndSet) CheckEquals(2, read, __func__, __LINE__, "a value out of the range should give the default"); CheckEquals(EIniCode::ValueOutOfRange, belowRange.Code, __func__, __LINE__, "a value below should be refused"); CheckEquals(EIniCode::ValueOutOfRange, aboveRange.Code, __func__, __LINE__, "a value above should be refused"); - CheckEquals(std::string("The key \"Level\" of the section \"General\" can't be set: The value \"5\" is out of the " - "setting's range: it must be 0 to 4."), aboveRange.Message, __func__, __LINE__, + CheckEquals("The key \"Level\" of the section \"General\" can't be set: The value \"5\" is out of the " + "setting's range: it must be 0 to 4.", aboveRange.Message, __func__, __LINE__, "the message should name the key and give the range"); CheckTrue(top.IsOk() && bottom.IsOk(), __func__, __LINE__, "the range's ends should be in it"); CheckEquals(0, level.Get(), __func__, __LINE__, "the last value set should be read"); CheckEquals(EIniCode::ValueOutOfRange, belowMin.Code, __func__, __LINE__, "a value below Min should be refused"); - CheckEndsWith(belowMin.Message, std::string("\"0\" is out of the setting's range: it must be at least 1."), + CheckEndsWith(belowMin.Message, "\"0\" is out of the setting's range: it must be at least 1.", __func__, __LINE__, "a range with only a Min should say so"); CheckEquals(EIniCode::ValueOutOfRange, aboveMax.Code, __func__, __LINE__, "a value above Max should be refused"); - CheckEndsWith(aboveMax.Message, std::string("\"1.5\" is out of the setting's range: it must be at most 1."), + CheckEndsWith(aboveMax.Message, "\"1.5\" is out of the setting's range: it must be at most 1.", __func__, __LINE__, "a range with only a Max should say so"); - CheckEquals(std::string("[General]\nLevel = 0\n"), ini.ToText(), __func__, __LINE__, + CheckEquals("[General]\nLevel = 0\n", ini.ToText(), __func__, __LINE__, "only the values in the range should be written"); AssertEquals(5, static_cast(messages.size()), __func__, __LINE__, "the Warning of Get() and each failed Set() should be reported"); CheckEquals(ESeverity::Warning, messages[0].Severity, __func__, __LINE__, "Get() should report a Warning"); CheckEquals(EIniCode::ValueOutOfRange, messages[0].Code, __func__, __LINE__, "Get() should report the code"); - CheckEquals(std::string("The value \"7\" is out of the setting's range: it must be 0 to 4. The default value \"2\" " - "is used."), messages[0].Text, __func__, __LINE__, "Get()'s Warning should give the range and the default"); + CheckEquals("The value \"7\" is out of the setting's range: it must be 0 to 4. The default value \"2\" " + "is used.", messages[0].Text, __func__, __LINE__, "Get()'s Warning should give the range and the default"); CheckEquals(ESeverity::Error, messages[2].Severity, __func__, __LINE__, "a failed Set() should be an Error"); CheckEquals(aboveRange.Message, messages[2].Text, __func__, __LINE__, "the Error should have the result's text"); } @@ -607,7 +607,7 @@ ASW_TEST(TTest_ASWIni_SettingsAccess, Reset_SetsTheDefault) // Assert CheckTrue(result.IsOk(), __func__, __LINE__, "Reset() should succeed"); CheckEquals(640, width.Get(), __func__, __LINE__, "the value should be the default"); - CheckEquals(std::string("[General]\nWidth = 640\n"), ini.ToText(), __func__, __LINE__, + CheckEquals("[General]\nWidth = 640\n", ini.ToText(), __func__, __LINE__, "the default should be written to the document"); } //--------------------------------------------------------------------------- @@ -635,8 +635,8 @@ ASW_TEST(TTest_ASWIni_SettingsAccess, Set_AddsTheKeyWithItsComment) // Assert CheckTrue(keptResult.IsOk() && plainResult.IsOk() && addedResult.IsOk() && bareResult.IsOk() && elsewhereResult.IsOk(), __func__, __LINE__, "each Set() should succeed"); - CheckEquals(std::string("[General]\n; The user's note\nKept = 10\nPlain = 20\n; First line\n; Second line\n" - "Added = 30\nBare = 40\n\n[Other]\n; In a new section\nKey = 50\n"), ini.ToText(), __func__, __LINE__, + CheckEquals("[General]\n; The user's note\nKept = 10\nPlain = 20\n; First line\n; Second line\n" + "Added = 30\nBare = 40\n\n[Other]\n; In a new section\nKey = 50\n", ini.ToText(), __func__, __LINE__, "a key Set() adds should get the setting's comment, and a key that exists should keep its own"); } //--------------------------------------------------------------------------- @@ -673,7 +673,7 @@ ASW_TEST(TTest_ASWIni_SettingsAccess, Set_CommentThatCantBeWrittenChangesNothing CheckEquals(ESeverity::Error, messages[0].Severity, __func__, __LINE__, "the failure should be an Error"); CheckEquals(addedResult.Message, messages[0].Text, __func__, __LINE__, "the Error should have the result's text"); CheckTrue(existingResult.IsOk(), __func__, __LINE__, "a key that exists doesn't get the comment, so it is set"); - CheckEquals(std::string("[General]\nExisting = 2\n"), ini.ToText(), __func__, __LINE__, + CheckEquals("[General]\nExisting = 2\n", ini.ToText(), __func__, __LINE__, "only the value of the key that exists should change"); } //--------------------------------------------------------------------------- @@ -714,11 +714,11 @@ ASW_TEST(TTest_ASWIni_SettingsAccess, Set_FailuresAreReported) "a key that can't be written should fail as SetText() does"); CheckEquals(EIniCode::UnexpectedException, stdException.Code, __func__, __LINE__, "a validator's exception should be UnexpectedException"); - CheckEquals(std::string("The key \"StdThrower\" of the section \"General\" can't be set: broken"), + CheckEquals("The key \"StdThrower\" of the section \"General\" can't be set: broken", stdException.Message, __func__, __LINE__, "the message should name the key and give what() of the exception"); CheckEquals(EIniCode::UnexpectedException, otherException.Code, __func__, __LINE__, "an exception that isn't a std::exception should be UnexpectedException"); - CheckContains(otherException.Message, std::string("isn't a std::exception"), __func__, __LINE__, + CheckContains(otherException.Message, "isn't a std::exception", __func__, __LINE__, "the message should say what was thrown"); CheckEquals(std::string(), ini.ToText(), __func__, __LINE__, "the failures should change nothing"); AssertEquals(4, static_cast(messages.size()), __func__, __LINE__, "each failure should be reported once"); @@ -751,14 +751,14 @@ ASW_TEST(TTest_ASWIni_SettingsAccess, Set_WritesTheDocument) // Assert CheckTrue(allOk, __func__, __LINE__, "each Set() should succeed"); - CheckEquals(std::string("[Values]\nNumber = -42\nCount = 7\nEnabled = true\nRatio = 0.5\nName = some name\n" - "Level = High\nItems = 1, 2, 3\nFile = app.log\n"), ini.ToText(), __func__, __LINE__, + CheckEquals("[Values]\nNumber = -42\nCount = 7\nEnabled = true\nRatio = 0.5\nName = some name\n" + "Level = High\nItems = 1, 2, 3\nFile = app.log\n", ini.ToText(), __func__, __LINE__, "each value should be written with its converter, in the order set"); CheckTrue(ini.IsModified(), __func__, __LINE__, "the document should be modified"); CheckEquals(-42, number.Get(), __func__, __LINE__, "the value set should be read back"); CheckEquals(7u, count.Get(), __func__, __LINE__, "the value set should be read back"); CheckTrue(enabled.Get(), __func__, __LINE__, "the value set should be read back"); - CheckEquals(std::string("some name"), name.Get(), __func__, __LINE__, "the value set should be read back"); + CheckEquals("some name", name.Get(), __func__, __LINE__, "the value set should be read back"); CheckTrue(level.Get() == ELevel::High, __func__, __LINE__, "the value set should be read back"); CheckTrue(items.Get() == std::vector{ 1, 2, 3 }, __func__, __LINE__, "the value set should be read back"); CheckTrue(file.Get() == std::filesystem::path("app.log"), __func__, __LINE__, "the value set should be read back"); @@ -789,7 +789,7 @@ ASW_TEST(TTest_ASWIni_SettingsAccess, Types_WithoutOperatorLessWork) CheckTrue(valid.IsOk(), __func__, __LINE__, "a value of an application's type should be set"); CheckEquals(EIniCode::InvalidValue, refused.Code, __func__, __LINE__, "the validator should refuse a value"); CheckTrue(listSet.IsOk(), __func__, __LINE__, "a list of an application's type should be set"); - CheckEquals(std::string("[Room]\nTemperature = 21\nMarks = 2, 3\n"), ini.ToText(), __func__, __LINE__, + CheckEquals("[Room]\nTemperature = 21\nMarks = 2, 3\n", ini.ToText(), __func__, __LINE__, "the values should be written with the application's converter"); CheckEquals(21, temperature.Get().Degrees, __func__, __LINE__, "the value should be read back"); CheckEquals(std::size_t(2), listRead.size(), __func__, __LINE__, "the list should be read back"); @@ -830,23 +830,23 @@ ASW_TEST(TTest_ASWIni_SettingsAccess, Validator_ChecksGetAndSet) TASWIniResult const validEven = evenNumber.Set(4); // Assert - CheckEquals(std::string("App_"), readPrefix, __func__, __LINE__, "a value the validator refuses gives the default"); + CheckEquals("App_", readPrefix, __func__, __LINE__, "a value the validator refuses gives the default"); AssertGreaterThan(messages.size(), std::size_t(0), __func__, __LINE__, "Get() should report the refused value"); CheckEquals(ESeverity::Warning, messages[0].Severity, __func__, __LINE__, "Get() should report a Warning"); CheckEquals(EIniCode::InvalidValue, messages[0].Code, __func__, __LINE__, "a refused value is InvalidValue"); - CheckEquals(std::string("The value \"\" isn't valid: it can't be empty. The default value \"App_\" is used."), + CheckEquals("The value \"\" isn't valid: it can't be empty. The default value \"App_\" is used.", messages[0].Text, __func__, __LINE__, "the Warning should give the validator's problem and the default"); CheckEquals(EIniCode::InvalidValue, emptyPrefix.Code, __func__, __LINE__, "Set() should be refused"); - CheckEquals(std::string("The key \"Prefix\" of the section \"General\" can't be set: The value \"\" isn't valid: " - "it can't be empty."), emptyPrefix.Message, __func__, __LINE__, "the message should give the problem"); + CheckEquals("The key \"Prefix\" of the section \"General\" can't be set: The value \"\" isn't valid: " + "it can't be empty.", emptyPrefix.Message, __func__, __LINE__, "the message should give the problem"); CheckTrue(validPrefix.IsOk(), __func__, __LINE__, "a value the validator accepts should be set"); CheckEquals(2, readEven, __func__, __LINE__, "a value the validator refuses gives the default"); - CheckEndsWith(odd.Message, std::string("The value \"5\" isn't valid: it must be even."), __func__, __LINE__, + CheckEndsWith(odd.Message, "The value \"5\" isn't valid: it must be even.", __func__, __LINE__, "a problem that ends with a period shouldn't get another one"); CheckTrue(validEven.IsOk(), __func__, __LINE__, "a value the validator accepts should be set"); CheckTrue(checked == std::vector{ 3, 5, 4 }, __func__, __LINE__, "the validator should be given each value read or set"); - CheckEquals(std::string("[General]\nPrefix = Log_\nEven = 4\n"), ini.ToText(), __func__, __LINE__, + CheckEquals("[General]\nPrefix = Log_\nEven = 4\n", ini.ToText(), __func__, __LINE__, "only the values the validator accepts should be written"); } //--------------------------------------------------------------------------- @@ -877,9 +877,9 @@ ASW_TEST(TTest_ASWIni_SettingsAccess, ValueOptions_AreTheSettingsOwnOrTheOwners) AssertTrue(own.GetOptions().GetValues() != nullptr, __func__, __LINE__, "the setting should keep its value options"); CheckEquals(EBoolFormat::OneZero, own.GetOptions().GetValues()->BoolFormat, __func__, __LINE__, "the setting should keep its value options"); - CheckEquals(std::string("[General]\nOwn = 1\nOwners = true\nList = 1; 2\n"), textBefore, __func__, __LINE__, + CheckEquals("[General]\nOwn = 1\nOwners = true\nList = 1; 2\n", textBefore, __func__, __LINE__, "a setting with value options of its own should be written with them, another with the owner's"); - CheckEquals(std::string("[General]\nOwn = 0\nOwners = no\nList = 1; 2\n"), ini.ToText(), __func__, __LINE__, + CheckEquals("[General]\nOwn = 0\nOwners = no\nList = 1; 2\n", ini.ToText(), __func__, __LINE__, "a setting without value options of its own should follow the owner's"); CheckTrue(list.Get() == std::vector{ 1, 2 }, __func__, __LINE__, "a setting should be read with its own value options"); @@ -954,15 +954,15 @@ ASW_TEST(TTest_ASWIni_SettingsLoad, AppSettings_OldFileIsBroughtUpToDate) CheckTrue(loaded.IsOk(), __func__, __LINE__, "the old file should load"); CheckTrue(modified, __func__, __LINE__, "the old file should need saving"); CheckTrue(saved.IsOk() && read, __func__, __LINE__, "the file should be saved"); - CheckEquals(std::string("[General]\r\n;Leave blank for default (exe directory).\r\nImagesPath=\r\n" + CheckEquals("[General]\r\n;Leave blank for default (exe directory).\r\nImagesPath=\r\n" "DirLogs=%localAppData%\\ASWSoftware\\SweepThemMines\\Logs\\\r\nLogPrefix=GeneralSTM_\r\n;Valid range for " "LogLevel: 0-4. 0=System/forced logs only, 1=errors/warnings, 2=medium, 3=heavy, 4=debug/verbose\r\n" "LogLevel=0\r\n; Valid value for NDaysRetainLogs: 0 to N days. 0=retain forever.\r\nNDaysRetainLogs=14\r\n" - "UseQuestionMarksInit = true\r\n"), written, __func__, __LINE__, + "UseQuestionMarksInit = true\r\n", written, __func__, __LINE__, "only the lines that needed it should change, and the missing key should be added in the file's line ending"); AssertEquals(4, static_cast(messages.size()), __func__, __LINE__, "each change should be reported"); CheckEquals(EIniCode::KeyAdded, messages[0].Code, __func__, __LINE__, "the missing key should be added"); - CheckEquals(std::string("UseQuestionMarksInit"), messages[0].Key, __func__, __LINE__, + CheckEquals("UseQuestionMarksInit", messages[0].Key, __func__, __LINE__, "the changes should be reported in the order the settings are declared"); CheckEquals(EIniCode::InvalidValue, messages[1].Code, __func__, __LINE__, "the empty DirLogs should be refused"); CheckEquals(EIniCode::ValueOutOfRange, messages[2].Code, __func__, __LINE__, "LogLevel should be out of range"); @@ -1000,10 +1000,10 @@ ASW_TEST(TTest_ASWIni_SettingsLoad, Bindings_FollowTheirLifetimes) static_cast(ini.LoadText("")); // Assert - CheckEquals(std::string("[General]\nKept = 1\n"), textBefore, __func__, __LINE__, + CheckEquals("[General]\nKept = 1\n", textBefore, __func__, __LINE__, "a setting or section that was destroyed should no longer be applied"); CheckEquals(textBefore, textDeclared, __func__, __LINE__, "declaring a setting shouldn't change the document"); - CheckEquals(std::string("[General]\nKept = 1\nLater = 3\n"), ini.ToText(), __func__, __LINE__, + CheckEquals("[General]\nKept = 1\nLater = 3\n", ini.ToText(), __func__, __LINE__, "a setting declared later should be applied by the next load"); } //--------------------------------------------------------------------------- @@ -1031,9 +1031,9 @@ ASW_TEST(TTest_ASWIni_SettingsLoad, Comments_CodeWinsReplacesTheFilesComments) // Assert CheckTrue(result.IsOk(), __func__, __LINE__, "the load should succeed"); - CheckEquals(std::string("; The code's file comment\n\n; The code's section comment\n[General]\n" + CheckEquals("; The code's file comment\n\n; The code's section comment\n[General]\n" "; The code's key comment\n; in two lines\nA = 1\n; The user's note, which the code has no comment for\n" - "B = 2\n\n; The user's note on a section the code has no comment for\n[Other]\n"), text, __func__, __LINE__, + "B = 2\n\n; The user's note on a section the code has no comment for\n[Other]\n", text, __func__, __LINE__, "the code's comments should replace the file's, and a comment the code doesn't declare should stay"); CheckTrue(modified, __func__, __LINE__, "the replaced comments should set the modified flag"); CheckTrue(messages.empty(), __func__, __LINE__, "replacing a comment isn't reported"); @@ -1064,13 +1064,13 @@ ASW_TEST(TTest_ASWIni_SettingsLoad, Comments_FileWinsKeepsTheFilesComments) static_cast(ini.LoadText("[General]\nA = 1\nC = 3\nE = 5\n")); // Assert - CheckEquals(std::string("; The user's file comment\n\n; The user's section comment\n[General]\n" + CheckEquals("; The user's file comment\n\n; The user's section comment\n[General]\n" "; The user's key comment\nA = 1\n; C's comment\nC = 3\n; E's comment\nE = 5\n\n; Bare's comment\n[Bare]\n" - "D = 4\n"), withComments, __func__, __LINE__, + "D = 4\n", withComments, __func__, __LINE__, "the file's comments should stay, and the code's should be written only where there is none"); - CheckEquals(std::string("; The code's file comment\n\n; The code's section comment\n[General]\n" + CheckEquals("; The code's file comment\n\n; The code's section comment\n[General]\n" "; The code's key comment\nA = 1\n; C's comment\nC = 3\n; E's comment\nE = 5\n\n; Bare's comment\n[Bare]\n" - "D = 0\n"), ini.ToText(), __func__, __LINE__, "a file without comments should get all the code's"); + "D = 0\n", ini.ToText(), __func__, __LINE__, "a file without comments should get all the code's"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_SettingsLoad, Load_AddsMissingKeysInDeclarationOrder) @@ -1096,18 +1096,18 @@ ASW_TEST(TTest_ASWIni_SettingsLoad, Load_AddsMissingKeysInDeclarationOrder) // Assert CheckTrue(result.IsOk(), __func__, __LINE__, "the load should succeed"); - CheckEquals(std::string("[General]\nB = 2\n; A's comment\nA = 1\nC = three\n\n[Window]\nWidth = 640\n"), text, + CheckEquals("[General]\nB = 2\n; A's comment\nA = 1\nC = three\n\n[Window]\nWidth = 640\n", text, __func__, __LINE__, "the missing keys and sections should be added in the order they are declared"); CheckTrue(modified, __func__, __LINE__, "adding keys should set the modified flag"); AssertEquals(3, static_cast(reported), __func__, __LINE__, "each added key should be reported"); CheckEquals(ESeverity::Info, messages[0].Severity, __func__, __LINE__, "an added key is an Info message"); CheckEquals(EIniCode::KeyAdded, messages[0].Code, __func__, __LINE__, "an added key is KeyAdded"); - CheckEquals(std::string("The key \"A\" of the section \"General\" is missing: it is added with its default value " - "\"1\"."), messages[0].Text, __func__, __LINE__, "the message should name the key and the default value"); - CheckEquals(std::string("General"), messages[0].Section, __func__, __LINE__, "the message should name the section"); - CheckEquals(std::string("A"), messages[0].Key, __func__, __LINE__, "the message should name the key"); - CheckEquals(std::string("C"), messages[1].Key, __func__, __LINE__, "the keys should be reported in order"); - CheckEquals(std::string("Window"), messages[2].Section, __func__, __LINE__, "the keys should be reported in order"); + CheckEquals("The key \"A\" of the section \"General\" is missing: it is added with its default value " + "\"1\".", messages[0].Text, __func__, __LINE__, "the message should name the key and the default value"); + CheckEquals("General", messages[0].Section, __func__, __LINE__, "the message should name the section"); + CheckEquals("A", messages[0].Key, __func__, __LINE__, "the message should name the key"); + CheckEquals("C", messages[1].Key, __func__, __LINE__, "the keys should be reported in order"); + CheckEquals("Window", messages[2].Section, __func__, __LINE__, "the keys should be reported in order"); CheckEquals(text, ini.ToText(), __func__, __LINE__, "a document with every setting should stay as it is"); CheckFalse(ini.IsModified(), __func__, __LINE__, "a document with every setting isn't modified"); CheckEquals(3, static_cast(messages.size()), __func__, __LINE__, @@ -1134,7 +1134,7 @@ ASW_TEST(TTest_ASWIni_SettingsLoad, Load_FailureAppliesNothing) // Assert CheckEquals(EIniCode::ParseFailed, result.Code, __func__, __LINE__, "a malformed line should fail the load"); - CheckEquals(std::string("[General]\nA = 5\n"), ini.ToText(), __func__, __LINE__, + CheckEquals("[General]\nA = 5\n", ini.ToText(), __func__, __LINE__, "a failed load shouldn't change the document, nor apply the settings to it"); CheckFalse(ini.IsModified(), __func__, __LINE__, "a failed load shouldn't set the modified flag"); AssertEquals(1, static_cast(messages.size()), __func__, __LINE__, "only the failure should be reported"); @@ -1165,10 +1165,10 @@ ASW_TEST(TTest_ASWIni_SettingsLoad, Load_InvalidDefaultIsAnError) AssertEquals(2, static_cast(messages.size()), __func__, __LINE__, "each default should be reported"); CheckEquals(ESeverity::Error, messages[0].Severity, __func__, __LINE__, "a default that isn't valid is an Error"); CheckEquals(EIniCode::ValueOutOfRange, messages[0].Code, __func__, __LINE__, "the code should be the range's"); - CheckEquals(std::string("The key \"Level\" of the section \"General\" can't be given its default value: The value " - "\"9\" is out of the setting's range: it must be 0 to 4."), messages[0].Text, __func__, __LINE__, + CheckEquals("The key \"Level\" of the section \"General\" can't be given its default value: The value " + "\"9\" is out of the setting's range: it must be 0 to 4.", messages[0].Text, __func__, __LINE__, "the message should name the key and give the problem"); - CheckEquals(std::string("Level"), messages[0].Key, __func__, __LINE__, "the message should name the key"); + CheckEquals("Level", messages[0].Key, __func__, __LINE__, "the message should name the key"); CheckEquals(EIniCode::InvalidValue, messages[1].Code, __func__, __LINE__, "the code should be the converter's"); CheckEndsWith(messages[1].Text, unnamedProblem, __func__, __LINE__, "the message should give the problem"); } @@ -1289,7 +1289,7 @@ ASW_TEST(TTest_ASWIni_SettingsLoad, Load_MissingFileGetsEverySetting) CheckEquals(EIniCode::FileNotFound, loaded.Code, __func__, __LINE__, "a missing file is FileNotFound"); CheckTrue(modified, __func__, __LINE__, "the settings added should set the modified flag"); CheckTrue(saved.IsOk() && read, __func__, __LINE__, "Save() should create the file"); - CheckEquals(std::string("; My application's settings\n\n[General]\n; A's comment\nA = 1\nB = x\n"), written, + CheckEquals("; My application's settings\n\n[General]\n; A's comment\nA = 1\nB = x\n", written, __func__, __LINE__, "the file should hold every setting with its comment"); AssertEquals(3, static_cast(messages.size()), __func__, __LINE__, "the missing file and each key added should be reported"); @@ -1316,14 +1316,14 @@ ASW_TEST(TTest_ASWIni_SettingsLoad, Load_OldKeyThatCantBeRenamedIsAnError) // Assert CheckTrue(result.IsOk(), __func__, __LINE__, "the load should succeed"); - CheckEquals(std::string("[General]\nOld = 5\nGood = 3\n"), ini.ToText(), __func__, __LINE__, + CheckEquals("[General]\nOld = 5\nGood = 3\n", ini.ToText(), __func__, __LINE__, "an old key that can't be renamed should stay as it is, and the next setting should still be applied"); AssertEquals(2, static_cast(messages.size()), __func__, __LINE__, "the failure should be reported once, then the next key renamed"); CheckEquals(ESeverity::Error, messages[0].Severity, __func__, __LINE__, "a key that can't be renamed is an Error"); CheckEquals(EIniCode::InvalidArgument, messages[0].Code, __func__, __LINE__, "the code should be RenameKey()'s"); - CheckEquals(std::string("General"), messages[0].Section, __func__, __LINE__, "the message should name the section"); - CheckEquals(std::string("a=b"), messages[0].Key, __func__, __LINE__, "the message should name the setting's key"); + CheckEquals("General", messages[0].Section, __func__, __LINE__, "the message should name the section"); + CheckEquals("a=b", messages[0].Key, __func__, __LINE__, "the message should name the setting's key"); CheckEquals(EIniCode::KeyRenamed, messages[1].Code, __func__, __LINE__, "the next key should still be renamed"); } //--------------------------------------------------------------------------- @@ -1347,16 +1347,16 @@ ASW_TEST(TTest_ASWIni_SettingsLoad, Load_OptionalKeyIsNotAdded) TASWIniResult const set = cheats.Set(true); // Assert - CheckEquals(std::string("[General]\nOther = 1\n"), missingText, __func__, __LINE__, + CheckEquals("[General]\nOther = 1\n", missingText, __func__, __LINE__, "a missing optional key shouldn't be added"); CheckFalse(missingModified, __func__, __LINE__, "the document shouldn't be modified"); CheckFalse(missingReported, __func__, __LINE__, "a missing optional key shouldn't be reported"); - CheckEquals(std::string("[General]\nEnableCheats = false\n"), invalidText, __func__, __LINE__, + CheckEquals("[General]\nEnableCheats = false\n", invalidText, __func__, __LINE__, "an optional key that is there should be applied as any other"); AssertEquals(1, static_cast(messages.size()), __func__, __LINE__, "the invalid value should be reported"); CheckEquals(ESeverity::Warning, messages[0].Severity, __func__, __LINE__, "the invalid value is a Warning"); CheckTrue(set.IsOk(), __func__, __LINE__, "Set() should write an optional setting"); - CheckEquals(std::string("[General]\nEnableCheats = true\n"), ini.ToText(), __func__, __LINE__, + CheckEquals("[General]\nEnableCheats = true\n", ini.ToText(), __func__, __LINE__, "Set() should write an optional setting"); } //--------------------------------------------------------------------------- @@ -1382,17 +1382,17 @@ ASW_TEST(TTest_ASWIni_SettingsLoad, Load_RenamedKeyIsAppliedAsAnyOther) // Assert CheckTrue(result.IsOk(), __func__, __LINE__, "the load should succeed"); - CheckEquals(std::string("[General]\n; From 0 to 4\nLogLevel = 2\nEnableCheats = false\n; The user's note\n" - "Width = 800\n"), ini.ToText(), __func__, __LINE__, + CheckEquals("[General]\n; From 0 to 4\nLogLevel = 2\nEnableCheats = false\n; The user's note\n" + "Width = 800\n", ini.ToText(), __func__, __LINE__, "a renamed key's value should be checked and its comment written as for any key, also for an optional one"); AssertEquals(5, static_cast(messages.size()), __func__, __LINE__, "each key renamed and each value replaced should be reported"); CheckEquals(EIniCode::KeyRenamed, messages[0].Code, __func__, __LINE__, "the rename should come first"); CheckEquals(EIniCode::ValueOutOfRange, messages[1].Code, __func__, __LINE__, "then the value replaced"); CheckEquals(ESeverity::Warning, messages[1].Severity, __func__, __LINE__, "a value replaced is a Warning"); - CheckEquals(std::string("LogLevel"), messages[1].Key, __func__, __LINE__, "the warning should name the new key"); + CheckEquals("LogLevel", messages[1].Key, __func__, __LINE__, "the warning should name the new key"); CheckEquals(EIniCode::KeyRenamed, messages[2].Code, __func__, __LINE__, "an optional key should be renamed"); - CheckEquals(std::string("EnableCheats"), messages[2].Key, __func__, __LINE__, "the message should name the key"); + CheckEquals("EnableCheats", messages[2].Key, __func__, __LINE__, "the message should name the key"); CheckEquals(EIniCode::InvalidValue, messages[3].Code, __func__, __LINE__, "an optional key's renamed value should be checked"); CheckEquals(EIniCode::KeyRenamed, messages[4].Code, __func__, __LINE__, "the last key should be renamed"); @@ -1425,8 +1425,8 @@ ASW_TEST(TTest_ASWIni_SettingsLoad, Load_RenamesAnOldKey) // Assert CheckTrue(result.IsOk(), __func__, __LINE__, "the load should succeed"); - CheckEquals(std::string("[General]\n ; Days to keep the logs\n NDaysRetainLogs: 30\nSizeX = 800\nWidth = 900\n" - "Height = 480\n\n[Other]\nH = 1\n"), text, __func__, __LINE__, + CheckEquals("[General]\n ; Days to keep the logs\n NDaysRetainLogs: 30\nSizeX = 800\nWidth = 900\n" + "Height = 480\n\n[Other]\nH = 1\n", text, __func__, __LINE__, "the first old key in the setting's order should be renamed in place, keeping its spacing and value"); CheckTrue(modified, __func__, __LINE__, "renaming keys should set the modified flag"); CheckEquals(30, daysValue, __func__, __LINE__, "the setting should read the renamed key's value"); @@ -1434,13 +1434,13 @@ ASW_TEST(TTest_ASWIni_SettingsLoad, Load_RenamesAnOldKey) AssertEquals(3, static_cast(reported), __func__, __LINE__, "each key renamed or added should be reported"); CheckEquals(ESeverity::Info, messages[0].Severity, __func__, __LINE__, "a renamed key is an Info message"); CheckEquals(EIniCode::KeyRenamed, messages[0].Code, __func__, __LINE__, "a renamed key is KeyRenamed"); - CheckEquals(std::string("The key \"NDaysRetainLogs\" of the section \"General\" is missing: its earlier name " - "\"LogDays\" is renamed to it."), messages[0].Text, __func__, __LINE__, + CheckEquals("The key \"NDaysRetainLogs\" of the section \"General\" is missing: its earlier name " + "\"LogDays\" is renamed to it.", messages[0].Text, __func__, __LINE__, "the message should name the key and its earlier name"); - CheckEquals(std::string("General"), messages[0].Section, __func__, __LINE__, "the message should name the section"); - CheckEquals(std::string("NDaysRetainLogs"), messages[0].Key, __func__, __LINE__, + CheckEquals("General", messages[0].Section, __func__, __LINE__, "the message should name the section"); + CheckEquals("NDaysRetainLogs", messages[0].Key, __func__, __LINE__, "the message should name the setting's key"); - CheckEquals(std::string("Width"), messages[1].Key, __func__, __LINE__, "the keys should be reported in order"); + CheckEquals("Width", messages[1].Key, __func__, __LINE__, "the keys should be reported in order"); CheckEquals(EIniCode::KeyAdded, messages[2].Code, __func__, __LINE__, "a key whose old key is in another section should be added"); CheckEquals(text, ini.ToText(), __func__, __LINE__, "a document with the new keys should stay as it is"); @@ -1477,7 +1477,7 @@ ASW_TEST(TTest_ASWIni_SettingsLoad, Load_ReplacesAnInvalidValueWithTheDefault) // Assert CheckTrue(result.IsOk(), __func__, __LINE__, "the load should succeed"); - CheckEquals(std::string("[General]\n; In pixels\nWidth = 640\nLevel = 2\nPrefix = App_\nFlag = 1\n"), + CheckEquals("[General]\n; In pixels\nWidth = 640\nLevel = 2\nPrefix = App_\nFlag = 1\n", ini.ToText(), __func__, __LINE__, "each value that isn't valid should be replaced by the default, written with the setting's value options"); CheckTrue(ini.IsModified(), __func__, __LINE__, "the values replaced should set the modified flag"); @@ -1486,10 +1486,10 @@ ASW_TEST(TTest_ASWIni_SettingsLoad, Load_ReplacesAnInvalidValueWithTheDefault) CheckEquals(EIniCode::InvalidValue, messages[0].Code, __func__, __LINE__, "the code should be the converter's"); CheckEquals(widthProblem + " The default value \"640\" is used.", messages[0].Text, __func__, __LINE__, "the text should give the problem and the default"); - CheckEquals(std::string("Width"), messages[0].Key, __func__, __LINE__, "the message should name the key"); + CheckEquals("Width", messages[0].Key, __func__, __LINE__, "the message should name the key"); CheckEquals(EIniCode::ValueOutOfRange, messages[1].Code, __func__, __LINE__, "the code should be the range's"); - CheckEquals(std::string("The value \"9\" is out of the setting's range: it must be 0 to 4. The default value " - "\"2\" is used."), messages[1].Text, __func__, __LINE__, "the text should give the range and the default"); + CheckEquals("The value \"9\" is out of the setting's range: it must be 0 to 4. The default value " + "\"2\" is used.", messages[1].Text, __func__, __LINE__, "the text should give the range and the default"); CheckEquals(EIniCode::InvalidValue, messages[2].Code, __func__, __LINE__, "a refused value is InvalidValue"); } //--------------------------------------------------------------------------- @@ -1515,17 +1515,17 @@ ASW_TEST(TTest_ASWIni_SettingsLoad, Load_WriteFailuresAreErrors) // Assert CheckTrue(result.IsOk(), __func__, __LINE__, "the load should succeed"); - CheckEquals(std::string("[General]\nCommented = 2\nGood = 3\n"), ini.ToText(), __func__, __LINE__, + CheckEquals("[General]\nCommented = 2\nGood = 3\n", ini.ToText(), __func__, __LINE__, "the keys that can be written should be added, the one whose comment can't be without it"); AssertEquals(4, static_cast(messages.size()), __func__, __LINE__, "each failure should be reported"); CheckEquals(ESeverity::Error, messages[0].Severity, __func__, __LINE__, "a key that can't be written is an Error"); CheckEquals(EIniCode::InvalidArgument, messages[0].Code, __func__, __LINE__, "the code should be SetValue()'s"); - CheckEquals(std::string("a=b"), messages[0].Key, __func__, __LINE__, "the message should name the key"); + CheckEquals("a=b", messages[0].Key, __func__, __LINE__, "the message should name the key"); CheckEquals(EIniCode::KeyAdded, messages[1].Code, __func__, __LINE__, "the key should be added"); CheckEquals(ESeverity::Error, messages[2].Severity, __func__, __LINE__, "a comment that can't be written is an Error"); CheckEquals(EIniCode::InvalidArgument, messages[2].Code, __func__, __LINE__, "the code should be SetKeyComment()'s"); - CheckEquals(std::string("Commented"), messages[2].Key, __func__, __LINE__, "the message should name the key"); + CheckEquals("Commented", messages[2].Key, __func__, __LINE__, "the message should name the key"); CheckEquals(EIniCode::KeyAdded, messages[3].Code, __func__, __LINE__, "the next key should still be added"); } //--------------------------------------------------------------------------- diff --git a/tests/tests/Test_ASWIni_Types.cpp b/tests/tests/Test_ASWIni_Types.cpp index d951818..883999c 100644 --- a/tests/tests/Test_ASWIni_Types.cpp +++ b/tests/tests/Test_ASWIni_Types.cpp @@ -186,24 +186,24 @@ ASW_TEST(TTest_ASWIni_Types, ToString_IniCodeNamesAreUnique) std::string const name = ASWIni::ToString(code); // Assert - CheckNotEquals(std::string("Unknown"), name, __func__, __LINE__, + CheckNotEquals("Unknown", name, __func__, __LINE__, "code " + std::to_string(static_cast(code)) + " should have a name"); CheckTrue(names.insert(name).second, __func__, __LINE__, "the name \"" + name + "\" should be unique"); } - CheckEquals(std::string("FileNotFound"), std::string(ASWIni::ToString(ASWIni::EIniCode::FileNotFound)), __func__, + CheckEquals("FileNotFound", ASWIni::ToString(ASWIni::EIniCode::FileNotFound), __func__, __LINE__, "the name should be the enumerator's"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_Types, ToString_LineBreakNames) { - CheckEquals(std::string("None"), std::string(ASWIni::ToString(ASWIni::ELineBreak::None)), __func__, __LINE__, + CheckEquals("None", ASWIni::ToString(ASWIni::ELineBreak::None), __func__, __LINE__, "None's name"); - CheckEquals(std::string("LF"), std::string(ASWIni::ToString(ASWIni::ELineBreak::LF)), __func__, __LINE__, + CheckEquals("LF", ASWIni::ToString(ASWIni::ELineBreak::LF), __func__, __LINE__, "LF's name"); - CheckEquals(std::string("CR"), std::string(ASWIni::ToString(ASWIni::ELineBreak::CR)), __func__, __LINE__, + CheckEquals("CR", ASWIni::ToString(ASWIni::ELineBreak::CR), __func__, __LINE__, "CR's name"); - CheckEquals(std::string("CRLF"), std::string(ASWIni::ToString(ASWIni::ELineBreak::CRLF)), __func__, __LINE__, + CheckEquals("CRLF", ASWIni::ToString(ASWIni::ELineBreak::CRLF), __func__, __LINE__, "CRLF's name"); } //--------------------------------------------------------------------------- @@ -224,8 +224,8 @@ ASW_TEST(TTest_ASWIni_Types, ToString_MessageWithAllParts) std::string const text = ASWIni::ToString(message); // Assert - CheckEquals(std::string("Warning DuplicateKey: The key appears again; the first one is used. (file \"app.ini\", " - "line 12, section \"General\", key \"LogLevel\", system error 5)"), text, __func__, __LINE__, + CheckEquals("Warning DuplicateKey: The key appears again; the first one is used. (file \"app.ini\", " + "line 12, section \"General\", key \"LogLevel\", system error 5)", text, __func__, __LINE__, "every part should be written, in order"); } //--------------------------------------------------------------------------- @@ -241,17 +241,17 @@ ASW_TEST(TTest_ASWIni_Types, ToString_MessageWithTextOnly) std::string const text = ASWIni::ToString(message); // Assert - CheckEquals(std::string("Error InvalidOptions: Separators is empty."), text, __func__, __LINE__, + CheckEquals("Error InvalidOptions: Separators is empty.", text, __func__, __LINE__, "the parts that aren't set should be left out, with no parentheses"); } //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_Types, ToString_SeverityNames) { - CheckEquals(std::string("Info"), std::string(ASWIni::ToString(ASWIni::ESeverity::Info)), __func__, __LINE__, + CheckEquals("Info", ASWIni::ToString(ASWIni::ESeverity::Info), __func__, __LINE__, "Info's name"); - CheckEquals(std::string("Warning"), std::string(ASWIni::ToString(ASWIni::ESeverity::Warning)), __func__, + CheckEquals("Warning", ASWIni::ToString(ASWIni::ESeverity::Warning), __func__, __LINE__, "Warning's name"); - CheckEquals(std::string("Error"), std::string(ASWIni::ToString(ASWIni::ESeverity::Error)), __func__, __LINE__, + CheckEquals("Error", ASWIni::ToString(ASWIni::ESeverity::Error), __func__, __LINE__, "Error's name"); } //--------------------------------------------------------------------------- @@ -264,11 +264,11 @@ ASW_TEST(TTest_ASWIni_Types, ToString_UnknownValues) ASWIni::ESeverity const severity = static_cast(-1); // Act & Assert - CheckEquals(std::string("Unknown"), std::string(ASWIni::ToString(code)), __func__, __LINE__, + CheckEquals("Unknown", ASWIni::ToString(code), __func__, __LINE__, "an unknown code should be \"Unknown\""); - CheckEquals(std::string("Unknown"), std::string(ASWIni::ToString(lineBreak)), __func__, __LINE__, + CheckEquals("Unknown", ASWIni::ToString(lineBreak), __func__, __LINE__, "an unknown line break should be \"Unknown\""); - CheckEquals(std::string("Unknown"), std::string(ASWIni::ToString(severity)), __func__, __LINE__, + CheckEquals("Unknown", ASWIni::ToString(severity), __func__, __LINE__, "an unknown severity should be \"Unknown\""); } //--------------------------------------------------------------------------- diff --git a/tests/tests/Test_ASWIni_Utils.cpp b/tests/tests/Test_ASWIni_Utils.cpp index a044e8d..6f3a6d2 100644 --- a/tests/tests/Test_ASWIni_Utils.cpp +++ b/tests/tests/Test_ASWIni_Utils.cpp @@ -226,13 +226,13 @@ ASW_TEST(TTest_ASWIni_Utils, IsValidUtf8_RejectsInvalidSequences) //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_Utils, LineBreakText_MatchesEachBreak) { - CheckEquals(std::string(""), std::string(ASWIni::Detail::LineBreakText(ELineBreak::None)), __func__, __LINE__, + CheckEquals("", std::string(ASWIni::Detail::LineBreakText(ELineBreak::None)), __func__, __LINE__, "None"); - CheckEquals(std::string("\n"), std::string(ASWIni::Detail::LineBreakText(ELineBreak::LF)), __func__, __LINE__, + CheckEquals("\n", std::string(ASWIni::Detail::LineBreakText(ELineBreak::LF)), __func__, __LINE__, "LF"); - CheckEquals(std::string("\r"), std::string(ASWIni::Detail::LineBreakText(ELineBreak::CR)), __func__, __LINE__, + CheckEquals("\r", std::string(ASWIni::Detail::LineBreakText(ELineBreak::CR)), __func__, __LINE__, "CR"); - CheckEquals(std::string("\r\n"), std::string(ASWIni::Detail::LineBreakText(ELineBreak::CRLF)), __func__, + CheckEquals("\r\n", std::string(ASWIni::Detail::LineBreakText(ELineBreak::CRLF)), __func__, __LINE__, "CRLF"); } //--------------------------------------------------------------------------- @@ -292,13 +292,13 @@ ASW_TEST(TTest_ASWIni_Utils, SplitLines_KeepsEachLineBreak) // Assert AssertEquals(4, static_cast(lines.size()), __func__, __LINE__, "there should be four lines"); - CheckEquals(std::string("a"), std::string(lines[0].Text), __func__, __LINE__, "line 1's text"); + CheckEquals("a", std::string(lines[0].Text), __func__, __LINE__, "line 1's text"); CheckEquals(ELineBreak::LF, lines[0].Break, __func__, __LINE__, "line 1 should end with LF"); - CheckEquals(std::string("b"), std::string(lines[1].Text), __func__, __LINE__, "line 2's text"); + CheckEquals("b", std::string(lines[1].Text), __func__, __LINE__, "line 2's text"); CheckEquals(ELineBreak::CR, lines[1].Break, __func__, __LINE__, "line 2 should end with CR"); - CheckEquals(std::string(""), std::string(lines[2].Text), __func__, __LINE__, "line 3 should be empty"); + CheckEquals("", std::string(lines[2].Text), __func__, __LINE__, "line 3 should be empty"); CheckEquals(ELineBreak::CRLF, lines[2].Break, __func__, __LINE__, "line 3 should end with CRLF"); - CheckEquals(std::string("c"), std::string(lines[3].Text), __func__, __LINE__, "line 4's text"); + CheckEquals("c", std::string(lines[3].Text), __func__, __LINE__, "line 4's text"); CheckEquals(ELineBreak::CRLF, lines[3].Break, __func__, __LINE__, "line 4 should end with CRLF"); } //--------------------------------------------------------------------------- @@ -309,7 +309,7 @@ ASW_TEST(TTest_ASWIni_Utils, SplitLines_LastLineWithoutBreak) // Assert AssertEquals(2, static_cast(lines.size()), __func__, __LINE__, "there should be two lines"); - CheckEquals(std::string("Last=2"), std::string(lines[1].Text), __func__, __LINE__, "the last line's text"); + CheckEquals("Last=2", std::string(lines[1].Text), __func__, __LINE__, "the last line's text"); CheckEquals(ELineBreak::None, lines[1].Break, __func__, __LINE__, "the last line should have no line break"); } //--------------------------------------------------------------------------- @@ -329,17 +329,17 @@ ASW_TEST(TTest_ASWIni_Utils, ToLowerAscii_ChangesOnlyUpperCaseLetters) //--------------------------------------------------------------------------- ASW_TEST(TTest_ASWIni_Utils, Trim_RemovesSpacesAndTabsOnly) { - CheckEquals(std::string("a b"), std::string(ASWIni::Detail::Trim(" \t a b\t ")), __func__, __LINE__, + CheckEquals("a b", std::string(ASWIni::Detail::Trim(" \t a b\t ")), __func__, __LINE__, "spaces and tabs at both ends should go, the inner space should stay"); - CheckEquals(std::string("a b\t "), std::string(ASWIni::Detail::TrimLeft(" \t a b\t ")), __func__, __LINE__, + CheckEquals("a b\t ", std::string(ASWIni::Detail::TrimLeft(" \t a b\t ")), __func__, __LINE__, "TrimLeft should only trim the start"); - CheckEquals(std::string(" \t a b"), std::string(ASWIni::Detail::TrimRight(" \t a b\t ")), __func__, __LINE__, + CheckEquals(" \t a b", std::string(ASWIni::Detail::TrimRight(" \t a b\t ")), __func__, __LINE__, "TrimRight should only trim the end"); - CheckEquals(std::string(""), std::string(ASWIni::Detail::Trim(" \t\t ")), __func__, __LINE__, + CheckEquals("", std::string(ASWIni::Detail::Trim(" \t\t ")), __func__, __LINE__, "only blanks should trim to empty"); - CheckEquals(std::string("\r a \n"), std::string(ASWIni::Detail::Trim("\r a \n")), __func__, __LINE__, + CheckEquals("\r a \n", std::string(ASWIni::Detail::Trim("\r a \n")), __func__, __LINE__, "line breaks should not be trimmed"); - CheckEquals(std::string(""), std::string(ASWIni::Detail::Trim("")), __func__, __LINE__, + CheckEquals("", std::string(ASWIni::Detail::Trim("")), __func__, __LINE__, "an empty text should stay empty"); } //--------------------------------------------------------------------------- diff --git a/tests/vcl/gui/rad370/ASWIniTests_Group.groupproj b/tests/vcl/gui/rad370/ASWIniTests_Group.groupproj index 8476dc8..22735af 100644 --- a/tests/vcl/gui/rad370/ASWIniTests_Group.groupproj +++ b/tests/vcl/gui/rad370/ASWIniTests_Group.groupproj @@ -9,6 +9,9 @@ + + + Default.Personality.12 @@ -35,14 +38,23 @@ + + + + + + + + + - + - + - + diff --git a/tests/vcl/gui/rad370/ASWIniTests_VCL_GUI.cbproj b/tests/vcl/gui/rad370/ASWIniTests_VCL_GUI.cbproj index 069be81..827b1f4 100644 --- a/tests/vcl/gui/rad370/ASWIniTests_VCL_GUI.cbproj +++ b/tests/vcl/gui/rad370/ASWIniTests_VCL_GUI.cbproj @@ -88,12 +88,12 @@ rtl.lib;vcl.lib <_TCHARMapping>wchar_t true - $(BDS)\bin\cbuilder_PROJECTICON.ico + ..\..\..\..\third_party\asw-unit-tests\resource\ASWUnitTests.ico $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_44.png $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_150.png ASWIniTests_VCL_GUI - ..\..\..\..\third_party\asw-unit-tests\vcl\gui\src\;..\..\..\..\third_party\asw-unit-tests\src\;..\..\..\..\ASWIni\;..\..\..\tests\;$(IncludePath) - ..\..\..\..\third_party\asw-unit-tests\vcl\gui\src\;..\..\..\..\third_party\asw-unit-tests\src\;..\..\..\..\ASWIni\;..\..\..\tests\;$(ILINK_LibraryPath) + ..\..\..\..\third_party\asw-unit-tests\vcl\gui\src\;..\..\..\..\third_party\asw-unit-tests\gui\src\;..\..\..\..\third_party\asw-unit-tests\src\;..\..\..\..\ASWIni\;..\..\..\tests\;$(IncludePath) + ..\..\..\..\third_party\asw-unit-tests\vcl\gui\src\;..\..\..\..\third_party\asw-unit-tests\gui\src\;..\..\..\..\third_party\asw-unit-tests\src\;..\..\..\..\ASWIni\;..\..\..\tests\;$(ILINK_LibraryPath) ASWUNITTESTS_RTL_EXCEPTIONS;$(Defines) true false @@ -101,6 +101,7 @@ 1033 CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= false + Carbon|VCLSTYLE|$(BDSCOMMONDIR)\Styles\Carbon.vsf;"Charcoal Dark Slate|VCLSTYLE|$(BDSCOMMONDIR)\Styles\CharcoalDarkSlate.vsf";"Cobalt XEMedia|VCLSTYLE|$(BDSCOMMONDIR)\Styles\CobaltXEMedia.vsf";"Onyx Blue|VCLSTYLE|$(BDSCOMMONDIR)\Styles\OnyxBlue.vsf";"Tablet Dark|VCLSTYLE|$(BDSCOMMONDIR)\Styles\TabletDark.vsf" adortl;bcbie;bcbsmp;bindcomp;bindcompdbx;bindcompfmx;bindcompvcl;bindcompvclsmp;bindcompvclwinx;bindengine;CloudService;CustomIPTransport;dbexpress;dbrtl;dbxcds;DbxClientDriver;DbxCommonDriver;DBXInterBaseDriver;DBXMySQLDriver;DBXSqliteDriver;dsnap;dsnapcon;dsnapxml;FireDAC;FireDACADSDriver;FireDACCommon;FireDACCommonDriver;FireDACCommonODBC;FireDACIBDriver;FireDACMSAccDriver;FireDACMySQLDriver;FireDACPgDriver;FireDACSqliteDriver;fmx;fmxase;fmxdae;fmxFireDAC;fmxobj;FMXTee;FmxTeeUI;IndyCore;IndyIPClient;IndyIPCommon;IndyIPServer;IndyProtocols;IndySystem;inet;inetdb;inetdbxpress;inetstn;RESTBackendComponents;RESTComponents;rtl;Skia;soapmidas;soaprtl;soapserver;Tee;TeeDB;TeeUI;tethering;vcl;vclactnband;vcldb;vcldsnap;vcledge;vclFireDAC;vclie;vclimg;VCLRESTComponents;VclSmp;vcltouch;vclwinx;vclx;xmlrtl;$(PackageImports) @@ -339,12 +340,20 @@ ..\..\..\..\third_party\asw-unit-tests\src\ASWUnitTests_Version.h 19 - - ..\..\..\..\third_party\asw-unit-tests\vcl\gui\src\ASWUnitTests_GUI_CommandLine.h + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_CommandLine.h 20 - - ..\..\..\..\third_party\asw-unit-tests\vcl\gui\src\ASWUnitTests_GUI_Layout.h + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_Commands.h + 70 + + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_INIDocument.h + 71 + + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_Layout.h 21 @@ -353,16 +362,16 @@ ..\..\..\..\third_party\asw-unit-tests\vcl\gui\src\ASWUnitTests_GUI_MainForm.h 22 - - ..\..\..\..\third_party\asw-unit-tests\vcl\gui\src\ASWUnitTests_GUI_RunObserver.h + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_RunObserver.h 23 - - ..\..\..\..\third_party\asw-unit-tests\vcl\gui\src\ASWUnitTests_GUI_Selection.h + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_Selection.h 41 - - ..\..\..\..\third_party\asw-unit-tests\vcl\gui\src\ASWUnitTests_GUI_Shuffle.h + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_Shuffle.h 45 @@ -373,14 +382,30 @@ ..\..\..\..\third_party\asw-unit-tests\vcl\gui\src\ASWUnitTests_GUI_Strings.h 24 - - ..\..\..\..\third_party\asw-unit-tests\vcl\gui\src\ASWUnitTests_GUI_TestList.h + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_TestList.h 25 + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_Theme.h + 72 + + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_Tree.h + 73 + + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_View.h + 74 + ..\..\..\..\third_party\asw-unit-tests\vcl\gui\src\ASWUnitTests_GUI_TextDialog.h 26 + + ..\..\..\..\third_party\asw-unit-tests\vcl\gui\src\ASWUnitTests_GUI_VCLSystem.h + 75 + Base diff --git a/tests/vcl/gui/rad370/ASWIniTests_VCL_GUI.cpp b/tests/vcl/gui/rad370/ASWIniTests_VCL_GUI.cpp index ee27ade..fc46837 100644 --- a/tests/vcl/gui/rad370/ASWIniTests_VCL_GUI.cpp +++ b/tests/vcl/gui/rad370/ASWIniTests_VCL_GUI.cpp @@ -28,9 +28,12 @@ limitations under the License. //--------------------------------------------------------------------------- #include #include +#include //--------------------------------------------------------------------------- #include "ASWUnitTests_GUI_CommandLine.h" #include "ASWUnitTests_GUI_TextDialog.h" +#include "ASWUnitTests_GUI_Theme.h" +#include "ASWUnitTests_GUI_VCLSystem.h" //--------------------------------------------------------------------------- USEFORM("..\..\..\..\third_party\asw-unit-tests\vcl\gui\src\ASWUnitTests_GUI_MainForm.cpp", FormASWUnitTestsGUIMain); //--------------------------------------------------------------------------- @@ -50,7 +53,21 @@ int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) // and the process exits with the same code the console runner would use, without opening the GUI. ASWUnitTests::TGUIOptions options; ASWUnitTests::TGUICommandLineResult const commandLine = - ASWUnitTests::TGUICommandLine::Parse(ASWUnitTests::TGUICommandLine::ProcessArguments(), options); + ASWUnitTests::TGUICommandLine::Parse(ASWUnitTests::ProcessArguments(), options); + + // Before any form exists, so each one, the --help text's included, is created in its style rather than + // restyled. --layout-reset's deletion of the layout file, which also holds the theme and the dark theme, + // comes later. + bool const savedTheme = !options.LayoutIgnore && !options.LayoutReset; + System::UnicodeString const layoutPath = ASWUnitTests::GUILayoutFilePath(); + ASWUnitTests::EGUITheme const theme = savedTheme ? ASWUnitTests::LoadGUIThemeFromLayoutFile(layoutPath) : + ASWUnitTests::EGUITheme::Windows; + std::string const darkTheme = savedTheme ? ASWUnitTests::LoadGUIDarkThemeFromLayoutFile(layoutPath) : + ASWUnitTests::GUIDefaultDarkThemeName(); + std::vector themeProblems; + System::UnicodeString const darkStyle = ASWUnitTests::LoadGUIDarkStyle(ASWUnitTests::GUIThemesFolderPath(), + darkTheme, themeProblems); + ASWUnitTests::ApplyGUITheme(theme, darkStyle); if (commandLine.EarlyExitCode.has_value()) { @@ -59,7 +76,7 @@ int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) } Application->CreateForm(__classid(TFormASWUnitTestsGUIMain), &FormASWUnitTestsGUIMain); - FormASWUnitTestsGUIMain->Start(options); + FormASWUnitTestsGUIMain->Start(options, theme, darkTheme, darkStyle, themeProblems); Application->Run(); // The form outlives Run(); Application frees it later, during shutdown. diff --git a/tests/win32/gui/rad370/ASWIniTests_Win32_GUI.cbproj b/tests/win32/gui/rad370/ASWIniTests_Win32_GUI.cbproj new file mode 100644 index 0000000..c344287 --- /dev/null +++ b/tests/win32/gui/rad370/ASWIniTests_Win32_GUI.cbproj @@ -0,0 +1,417 @@ + + + {C25B0B39-D27D-469F-B479-D64C68C42E5F} + 20.4 + None + ..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI_WinMain.cpp + True + Debug + Win64x + ASWIniTests_Win32_GUI + 1048577 + Application + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + JPHNE + .\$(Platform)\$(Config) + ..\..\..\build\bin\$(Platform)\$(Config) + false + true + true + $(BDSLIB)\$(PLATFORM)\release\$(LANGDIR);$(ILINK_TranslatedLibraryPath) + CppVCLApplication + ..\..\..\..\third_party\asw-unit-tests\resource\ASWUnitTests.ico + System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) + true + ASWIniTests_Win32_GUI + ..\..\..\..\third_party\asw-unit-tests\win32\gui\src\;..\..\..\..\third_party\asw-unit-tests\gui\src\;..\..\..\..\third_party\asw-unit-tests\src\;..\..\..\..\ASWIni\;..\..\..\tests\;$(IncludePath) + <_TCHARMapping>char + ..\..\..\..\third_party\asw-unit-tests\win32\gui\src\;..\..\..\..\third_party\asw-unit-tests\gui\src\;..\..\..\..\third_party\asw-unit-tests\src\;..\..\..\..\ASWIni\;..\..\..\tests\;$(ILINK_LibraryPath) + true + false + false + 1033 + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + + + adortl;appanalytics;bcbie;bcbsmp;bindcomp;bindcompdbx;bindcompfmx;bindcompvcl;bindcompvclsmp;bindcompvclwinx;bindengine;CloudService;CustomIPTransport;dbexpress;dbrtl;dbxcds;DbxClientDriver;DbxCommonDriver;DBXInterBaseDriver;DBXMySQLDriver;DBXSqliteDriver;dsnap;dsnapcon;dsnapxml;FireDAC;FireDACADSDriver;FireDACCommon;FireDACCommonDriver;FireDACCommonODBC;FireDACIBDriver;FireDACMSAccDriver;FireDACMySQLDriver;FireDACPgDriver;FireDACSqliteDriver;fmx;fmxase;fmxdae;fmxFireDAC;fmxobj;IndyCore;IndyIPClient;IndyIPCommon;IndyIPServer;IndyProtocols;IndySystem;inet;inetdb;inetdbxpress;inetstn;RESTBackendComponents;RESTComponents;rtl;Skia;soapmidas;soaprtl;soapserver;tethering;vcl;vclactnband;vcldb;vcldsnap;vcledge;vclFireDAC;vclie;vclimg;VCLRESTComponents;VclSmp;vcltouch;vclwinx;vclx;xmlrtl;$(PackageImports) + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + Debug + $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_44.png + $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_150.png + ASWIniTests_Win32_GUIPCH1.h + ..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI.manifest + none + false + -Wno-padded -Wno-format-nonliteral + true + --project-name "ASWIniTests" + + + adortl;appanalytics;bcbie;bcbsmp;bindcomp;bindcompdbx;bindcompfmx;bindcompvcl;bindcompvclsmp;bindcompvclwinx;bindengine;CloudService;CustomIPTransport;dbexpress;dbrtl;dbxcds;DbxClientDriver;DbxCommonDriver;DBXInterBaseDriver;DBXMySQLDriver;DBXSqliteDriver;dsnap;dsnapcon;dsnapxml;FireDAC;FireDACADSDriver;FireDACCommon;FireDACCommonDriver;FireDACCommonODBC;FireDACIBDriver;FireDACMSAccDriver;FireDACMySQLDriver;FireDACPgDriver;FireDACSqliteDriver;fmx;fmxase;fmxdae;fmxFireDAC;fmxobj;IndyCore;IndyIPClient;IndyIPCommon;IndyIPServer;IndyProtocols;IndySystem;inet;inetdb;inetdbxpress;inetstn;RESTBackendComponents;RESTComponents;rtl;Skia;soapmidas;soaprtl;soapserver;tethering;vcl;vclactnband;vcldb;vcldsnap;vcledge;vclFireDAC;vclie;vclimg;VCLRESTComponents;VclSmp;vcltouch;vclwinx;vclx;xmlrtl;$(PackageImports) + $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_44.png + $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_150.png + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) + Debug + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + 1033 + ASWIniTests_Win32_GUIPCH1.h + + + adortl;bindcomp;bindcompdbx;bindcompfmx;bindcompvcl;bindcompvclsmp;bindcompvclwinx;bindengine;CloudService;CustomIPTransport;dbexpress;dbrtl;dbxcds;DbxClientDriver;DbxCommonDriver;DBXInterBaseDriver;DBXMySQLDriver;DBXSqliteDriver;dsnap;dsnapcon;dsnapxml;FireDAC;FireDACADSDriver;FireDACCommon;FireDACCommonDriver;FireDACCommonODBC;FireDACIBDriver;FireDACMSAccDriver;FireDACMySQLDriver;FireDACPgDriver;FireDACSqliteDriver;fmx;fmxase;fmxdae;fmxFireDAC;fmxobj;IndyCore;IndyIPClient;IndyIPCommon;IndyIPServer;IndyProtocols;IndySystem;inet;inetdb;inetdbxpress;inetstn;RESTBackendComponents;RESTComponents;rtl;Skia;soapmidas;soaprtl;soapserver;tethering;vcl;vclactnband;vcldb;vcldsnap;vcledge;vclFireDAC;vclie;vclimg;VCLRESTComponents;VclSmp;vcltouch;vclwinx;vclx;xmlrtl;$(PackageImports) + $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_44.png + $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_150.png + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) + Debug + true + ASWIniTests_Win32_GUIPCH1.h + ..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI.manifest + -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-weak-vtables -Wno-used-but-marked-unused -Wno-format-nonliteral + none + --project-name "ASWIniTests" + + + false + true + false + true + _DEBUG;$(Defines) + false + None + DEBUG + true + true + true + true + Full + true + true + true + true + true + $(BDSLIB)\$(PLATFORM)\debug;$(ILINK_LibraryPath) + $(BDSLIB)\$(PLATFORM)\debug\$(LANGDIR);$(ILINK_TranslatedLibraryPath) + + + $(BDSLIB)\$(PLATFORM)$(CC_SUFFIX)\debug;$(ILINK_LibraryPath) + + + NDEBUG;$(Defines) + None + + + + 0 + true + + + ..\..\..\..\ASWIni\ASWIni_Base.h + 1 + + + ..\..\..\..\ASWIni\ASWIni_Converters.h + 2 + + + ..\..\..\..\ASWIni\ASWIni_Document.h + 3 + + + ..\..\..\..\ASWIni\ASWIni_File.h + 4 + + + ..\..\..\..\ASWIni\ASWIni_Interface.h + 5 + + + ..\..\..\..\ASWIni\ASWIni_Options.h + 6 + + + ..\..\..\..\ASWIni\ASWIni_Platform.h + 7 + + + ..\..\..\..\ASWIni\ASWIni_Settings.h + 8 + + + ..\..\..\..\ASWIni\ASWIni_Types.h + 9 + + + ..\..\..\..\ASWIni\ASWIni_Utils.h + 10 + + + ..\..\..\..\ASWIni\ASWIni_Version.h + 11 + + + ..\..\..\tests\Test_ASWIni_Base.h + 12 + + + ..\..\..\tests\Test_ASWIni_Converters.h + 13 + + + ..\..\..\tests\Test_ASWIni_Document.h + 14 + + + ..\..\..\tests\Test_ASWIni_File.h + 15 + + + ..\..\..\tests\Test_ASWIni_Interface.h + 16 + + + ..\..\..\tests\Test_ASWIni_Options.h + 17 + + + ..\..\..\tests\Test_ASWIni_Platform.h + 18 + + + ..\..\..\tests\Test_ASWIni_Settings.h + 19 + + + ..\..\..\tests\Test_ASWIni_Types.h + 20 + + + ..\..\..\tests\Test_ASWIni_Utils.h + 21 + + + ..\..\..\tests\Test_ASWIni_Version.h + 22 + + + ..\..\..\tests\UT_Helper_FailingAlloc.h + 23 + + + ..\..\..\tests\UT_Helper_TempDir.h + 24 + + + ..\..\..\tests\UT_Helper_Threads.h + 25 + + + ..\..\..\..\third_party\asw-unit-tests\src\ASWUnitTests_CLI.h + 26 + + + ..\..\..\..\third_party\asw-unit-tests\src\ASWUnitTests_Console.h + 27 + + + ..\..\..\..\third_party\asw-unit-tests\src\ASWUnitTests_CrashGuard.h + 28 + + + ..\..\..\..\third_party\asw-unit-tests\src\ASWUnitTests_Exception.h + 29 + + + ..\..\..\..\third_party\asw-unit-tests\src\ASWUnitTests_Handler.h + 30 + + + ..\..\..\..\third_party\asw-unit-tests\src\ASWUnitTests_JUnitReport.h + 31 + + + ..\..\..\..\third_party\asw-unit-tests\src\ASWUnitTests_Registry.h + 32 + + + ..\..\..\..\third_party\asw-unit-tests\src\ASWUnitTests_StdOutRedirect.h + 33 + + + ..\..\..\..\third_party\asw-unit-tests\src\ASWUnitTests_TestBase.h + 34 + + + ..\..\..\..\third_party\asw-unit-tests\src\ASWUnitTests_Utils.h + 35 + + + ..\..\..\..\third_party\asw-unit-tests\src\ASWUnitTests_Version.h + 36 + + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_CommandLine.h + 37 + + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_Commands.h + 38 + + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_INIDocument.h + 39 + + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_Layout.h + 40 + + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_RunObserver.h + 41 + + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_Selection.h + 42 + + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_Shuffle.h + 43 + + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_TestList.h + 44 + + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_Theme.h + 45 + + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_Tree.h + 46 + + + ..\..\..\..\third_party\asw-unit-tests\gui\src\ASWUnitTests_GUI_View.h + 47 + + + ..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI_DialogTemplate.h + 48 + + + ..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI_DPI.h + 49 + + + ..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI_Glyphs.h + 50 + + + ..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI_MainLayout.h + 51 + + + ..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI_MainWindow.h + 52 + + + ..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI_MessageDialog.h + 53 + + + ..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI_Palette.h + 54 + + + ..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI_ShuffleSeedDialog.h + 55 + + + ..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI_Splitter.h + 56 + + + ..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI_System.h + 57 + + + ..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI_TextDialog.h + 58 + + + ..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI_Theme.h + 59 + + + 60 + + + Base + + + Cfg_1 + Base + + + Cfg_2 + Base + + + + CPlusPlusBuilder.Personality.12 + CppVCLApplication + + + + ..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI_WinMain.cpp + + + False + True + True + False + + + + True + False + True + + + 12 + + + + diff --git a/tests/win32/gui/rad370/ASWIniTests_Win32_GUIPCH1.h b/tests/win32/gui/rad370/ASWIniTests_Win32_GUIPCH1.h new file mode 100644 index 0000000..b5e0f82 --- /dev/null +++ b/tests/win32/gui/rad370/ASWIniTests_Win32_GUIPCH1.h @@ -0,0 +1 @@ +#include "ASWUnitTests_Win32GUI_Windows.h" diff --git a/tests/win32/gui/rad370/Build_Win32_Debug.bat b/tests/win32/gui/rad370/Build_Win32_Debug.bat new file mode 100644 index 0000000..0c7f6fa --- /dev/null +++ b/tests/win32/gui/rad370/Build_Win32_Debug.bat @@ -0,0 +1,19 @@ +@echo off + +REM Builds the ASWIni unit tests' Win32 GUI runner with RAD Studio (Win32, Debug). Requires the Rad370 environment +REM variable. + +if not exist "%~dp0..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI_MainWindow.h" ( + echo ERROR: The ASWUnitTests submodule is missing from third_party\asw-unit-tests. + echo From the repository root, run: git submodule update --init + exit /b 1 +) + +call "%Rad370%\bin\rsvars.bat" + +pushd "%~dp0" +call cmd /c msbuild /t:Build /p:Config=Debug;Platform=Win32 ASWIniTests_Win32_GUI.cbproj +set "BUILD_RESULT=%ERRORLEVEL%" +popd + +exit /b %BUILD_RESULT% diff --git a/tests/win32/gui/rad370/Build_Win32_Release.bat b/tests/win32/gui/rad370/Build_Win32_Release.bat new file mode 100644 index 0000000..a6fe1f6 --- /dev/null +++ b/tests/win32/gui/rad370/Build_Win32_Release.bat @@ -0,0 +1,19 @@ +@echo off + +REM Builds the ASWIni unit tests' Win32 GUI runner with RAD Studio (Win32, Release). Requires the Rad370 environment +REM variable. + +if not exist "%~dp0..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI_MainWindow.h" ( + echo ERROR: The ASWUnitTests submodule is missing from third_party\asw-unit-tests. + echo From the repository root, run: git submodule update --init + exit /b 1 +) + +call "%Rad370%\bin\rsvars.bat" + +pushd "%~dp0" +call cmd /c msbuild /t:Build /p:Config=Release;Platform=Win32 ASWIniTests_Win32_GUI.cbproj +set "BUILD_RESULT=%ERRORLEVEL%" +popd + +exit /b %BUILD_RESULT% diff --git a/tests/win32/gui/rad370/Build_Win64x_Debug.bat b/tests/win32/gui/rad370/Build_Win64x_Debug.bat new file mode 100644 index 0000000..3ee9bd2 --- /dev/null +++ b/tests/win32/gui/rad370/Build_Win64x_Debug.bat @@ -0,0 +1,19 @@ +@echo off + +REM Builds the ASWIni unit tests' Win32 GUI runner with RAD Studio (Win64x, Debug). Requires the Rad370 environment +REM variable. + +if not exist "%~dp0..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI_MainWindow.h" ( + echo ERROR: The ASWUnitTests submodule is missing from third_party\asw-unit-tests. + echo From the repository root, run: git submodule update --init + exit /b 1 +) + +call "%Rad370%\bin\rsvars.bat" + +pushd "%~dp0" +call cmd /c msbuild /t:Build /p:Config=Debug;Platform=Win64x ASWIniTests_Win32_GUI.cbproj +set "BUILD_RESULT=%ERRORLEVEL%" +popd + +exit /b %BUILD_RESULT% diff --git a/tests/win32/gui/rad370/Build_Win64x_Release.bat b/tests/win32/gui/rad370/Build_Win64x_Release.bat new file mode 100644 index 0000000..c4359ff --- /dev/null +++ b/tests/win32/gui/rad370/Build_Win64x_Release.bat @@ -0,0 +1,19 @@ +@echo off + +REM Builds the ASWIni unit tests' Win32 GUI runner with RAD Studio (Win64x, Release). Requires the Rad370 environment +REM variable. + +if not exist "%~dp0..\..\..\..\third_party\asw-unit-tests\win32\gui\src\ASWUnitTests_Win32GUI_MainWindow.h" ( + echo ERROR: The ASWUnitTests submodule is missing from third_party\asw-unit-tests. + echo From the repository root, run: git submodule update --init + exit /b 1 +) + +call "%Rad370%\bin\rsvars.bat" + +pushd "%~dp0" +call cmd /c msbuild /t:Build /p:Config=Release;Platform=Win64x ASWIniTests_Win32_GUI.cbproj +set "BUILD_RESULT=%ERRORLEVEL%" +popd + +exit /b %BUILD_RESULT% diff --git a/third_party/asw-unit-tests b/third_party/asw-unit-tests index 6895de4..07ecccc 160000 --- a/third_party/asw-unit-tests +++ b/third_party/asw-unit-tests @@ -1 +1 @@ -Subproject commit 6895de4bcc63996f65449276f04b3402ab705892 +Subproject commit 07ecccc4262e242430d1b5c5414773cadedd9782