diff options
| author | Leitwolf | 2026-11-15 13:53:40 +0300 |
|---|---|---|
| committer | GitHub | 2026-11-15 13:53:40 +0300 |
| commit | 9ea8d3a88334d62711f3e9aa429c7fe4905f2ef0 (patch) | |
| tree | 7a4c0aa03d636bea6a359cd6fe9501bb5c8db28e /tools/Tools.tests.cpp | |
| parent | 13ecce487c3075e4ccc2f62b9c08597459d1a268 (diff) | |
| parent | 8979c1caf2eee321cf497671805d2177980c421e (diff) | |
| download | catch3-9ea8d3a88334d62711f3e9aa429c7fe4905f2ef0.tar.gz | |
Merge branch 'devel' into docs/no-former-languagedocs/no-former-language
Diffstat (limited to 'tools/Tools.tests.cpp')
| -rw-r--r-- | tools/Tools.tests.cpp | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/tools/Tools.tests.cpp b/tools/Tools.tests.cpp index 90e9b129..c505b966 100644 --- a/tools/Tools.tests.cpp +++ b/tools/Tools.tests.cpp @@ -3,6 +3,7 @@ #include <Progmasoft/Catch3/Matchers/String.hpp> #include <Progmasoft/Catch3/TestMacros.hpp> +#include <limits> #include <string> #include "tools/Amalgamation.hpp" @@ -13,28 +14,35 @@ using namespace Progmasoft::Catch3::Tools; using Catch::Matchers::ContainsSubstring; -TEST_CASE("Versions have three or four numbers", "[tools]") +TEST_CASE("Versions are MAJOR.MINOR.PATCH", "[tools]") { - CHECK(ParseVersion("0.3.0") == Version{ 0, 3, 0, 0 }); - CHECK(ParseVersion("0.3.0.2") == Version{ 0, 3, 0, 2 }); + CHECK(ParseVersion("0.4.0") == Version{ 0, 4, 0 }); + CHECK(ParseVersion("10.20.30") == Version{ 10, 20, 30 }); + CHECK(FormatVersion(Version{ 0, 4, 0 }) == "0.4.0"); for (const char *wrong : - { "0.3", "0.3.0.2.1", "01.3.0", "0.3.0.", "a.3.0", "", "0.3.0-rc" }) + { "0.3", "0.3.0.2", "01.3.0", "0.3.0.", "a.3.0", "", "0.3.0-rc" }) { INFO(wrong); CHECK_FALSE(ParseVersion(wrong)); } } -TEST_CASE("The next version counts releases", "[tools]") +TEST_CASE("The next patch release follows a SemVer or a four-number version", + "[tools]") { const auto next = [](const char *version) { - return FormatVersion(NextVersion(*ParseVersion(version))); + const auto parsed = NextPatch(version); + return parsed ? FormatVersion(*parsed) : std::string{ "none" }; }; - CHECK(next("0.3.0") == "0.3.0.1"); - CHECK(next("0.4.0.8") == "0.4.0.9"); - CHECK(next("0.4.0.9") == "0.4.1.0"); - CHECK(next("0.4.9.9") == "0.5.0.0"); - CHECK(next("0.19.9.9") == "1.0.0.0"); + CHECK(next("0.4.0") == "0.4.1"); + CHECK(next("1.2.9") == "1.2.10"); + // After the four-number versions: the fourth number goes. + CHECK(next("0.3.0.2") == "0.3.1"); + CHECK(next("0.3") == "none"); + const auto largest = std::to_string(std::numeric_limits<unsigned>::max()); + CHECK(next(("0.4." + largest).c_str()) == "none"); + CHECK(next(("0.3." + largest + ".2").c_str()) == "none"); + CHECK(next("0.3.0.2.1") == "none"); } TEST_CASE("A version site is read and written in place", "[tools]") @@ -57,12 +65,14 @@ TEST_CASE("Release notes are found by their heading", "[tools]") CHECK_FALSE(ReleaseNotesOf(notes, "0.3")); } -TEST_CASE("A release with D = 0 may be headed by three numbers", "[tools]") +TEST_CASE("A release is found by the version it was published as", "[tools]") { - const std::string notes = "# Notes\n\n## 0.4.0\n\nThree.\n"; + const std::string notes + = "# Notes\n\n## 0.4.0\n\nThree.\n\n\n## 0.3.0.2\n\nFour.\n"; CHECK(ReleaseNotesOf(notes, "0.4.0") == "Three.\n"); - CHECK(ReleaseNotesOf(notes, "0.4.0.0") == "Three.\n"); - CHECK_FALSE(ReleaseNotesOf(notes, "0.4.0.1")); + CHECK(ReleaseNotesOf(notes, "0.3.0.2") == "Four.\n"); + CHECK_FALSE(ReleaseNotesOf(notes, "0.4.0.0")); + CHECK_FALSE(ReleaseNotesOf(notes, "0.3.0")); } TEST_CASE("Git that could not say is not a clean checkout", "[tools]") |