Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tools/Tools.tests.cpp
diff options
context:
space:
mode:
authorLeitwolf112026-11-14 22:03:45 +0300
committerLeitwolf112026-11-14 22:03:45 +0300
commit2d21d2e0f9c6e0789e9c55d6cba611234dc61a60 (patch)
tree6750468ab3926a4c3cdcaed7a826a730708c6b72 /tools/Tools.tests.cpp
parent94a996a3ceafa9f0004ffc28a7de5c543cdb51c2 (diff)
downloadcatch3-2d21d2e0f9c6e0789e9c55d6cba611234dc61a60.tar.gz
Number versions MAJOR.MINOR.PATCH in the version tool
Progmasoft repositories use Semantic Versioning since 2026-11-12, but //tools:version still knew the four-number counters: given 0.4.0 it wrote 0.4.0.0 everywhere, and --next stepped the fourth number. - A Version is three numbers; ParseVersion takes exactly three, without leading zeros, and FormatVersion writes three. - --next is the next patch release. It also follows a four-number version as the rule says: the fourth number goes and the patch rises, so 0.3.0.2 is followed by 0.3.1. - ReleaseNotesOf finds a section by the version it was published as. Its fallback for "D = 0" read the fourth element of what is now a three-element array; it is gone. - Tests for the new parsing, NextPatch and release-note lookup; docs/contributing.md and the tool's usage say what the tool does. Claude-Session: https://claude.ai/code/session_01Ji7xZMYjc4zankoc7hGBE1
Diffstat (limited to 'tools/Tools.tests.cpp')
-rw-r--r--tools/Tools.tests.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/tools/Tools.tests.cpp b/tools/Tools.tests.cpp
index 90e9b129..980d9e7a 100644
--- a/tools/Tools.tests.cpp
+++ b/tools/Tools.tests.cpp
@@ -13,28 +13,32 @@
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");
+ CHECK(next("0.3.0.2.1") == "none");
}
TEST_CASE("A version site is read and written in place", "[tools]")
@@ -57,12 +61,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]")