diff options
author | Sven Göthel <[email protected]> | 2024-05-25 16:39:34 +0200 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-05-25 16:39:34 +0200 |
commit | 3dde0f0c4536d5f83cfc88a0e8a4fa8114e51d81 (patch) | |
tree | cc2b7d99adecb33db69957396cc88feee4891d95 | |
parent | 76f2a92dc99fbc21e6b1f4d913e9da973afa956c (diff) |
VersionNumber: Add parsing git description to regexp and maintain it; jau/version.hpp: Use VersionNumber for jau::VERSION
-rw-r--r-- | cmake/modules/version.cpp.in | 2 | ||||
-rw-r--r-- | include/jau/util/VersionNumber.hpp | 139 | ||||
-rw-r--r-- | include/jau/version.hpp | 4 | ||||
-rw-r--r-- | test/test_versionnumber01.cpp | 96 |
4 files changed, 174 insertions, 67 deletions
diff --git a/cmake/modules/version.cpp.in b/cmake/modules/version.cpp.in index 120cff7..85180c9 100644 --- a/cmake/modules/version.cpp.in +++ b/cmake/modules/version.cpp.in @@ -1,5 +1,5 @@ #include <jau/version.hpp> -const char* jau::VERSION = "@jaulib_VERSION_LONG@"; +const jau::util::VersionNumber jau::VERSION("@jaulib_VERSION_LONG@"); const char* jau::VERSION_SHORT = "@jaulib_VERSION_SHORT@"; const char* jau::VERSION_API = "@jaulib_VERSION_API@"; diff --git a/include/jau/util/VersionNumber.hpp b/include/jau/util/VersionNumber.hpp index 52be60c..9280dd3 100644 --- a/include/jau/util/VersionNumber.hpp +++ b/include/jau/util/VersionNumber.hpp @@ -26,11 +26,14 @@ #define JAU_VERSIONNUMBER_HPP_ #include <compare> +#include <cstddef> +#include <iostream> #include <ostream> #include <regex> #include <string> #include <jau/int_types.hpp> +#include <jau/string_util.hpp> namespace jau::util { @@ -49,24 +52,33 @@ namespace jau::util { class VersionNumber { private: int m_major, m_minor, m_sub; + int m_git_commits; + uint64_t m_git_ssha; + bool m_git_dirty; ssize_t m_strEnd; std::string m_version_str; uint16_t state; - - constexpr static const uint16_t HAS_MAJOR = 1U << 0; - constexpr static const uint16_t HAS_MINOR = 1U << 1; - constexpr static const uint16_t HAS_SUB = 1U << 2; + + constexpr static const uint16_t HAS_MAJOR = 1U << 0; + constexpr static const uint16_t HAS_MINOR = 1U << 1; + constexpr static const uint16_t HAS_SUB = 1U << 2; + constexpr static const uint16_t HAS_GIT_INFO = 1U << 3; + constexpr static const bool DBG_OUT = false; protected: - VersionNumber(int majorRev, int minorRev, int subMinorRev, ssize_t strEnd, uint16_t _state) noexcept - : m_major(majorRev), m_minor(minorRev), m_sub(subMinorRev), m_strEnd(strEnd), m_version_str(), state(_state) {} + VersionNumber(int majorRev, int minorRev, int subMinorRev, + int gitCommits, uint64_t gitSSHA, bool gitDirty, + ssize_t strEnd, uint16_t _state) noexcept + : m_major(majorRev), m_minor(minorRev), m_sub(subMinorRev), + m_git_commits(gitCommits), m_git_ssha(gitSSHA), m_git_dirty(gitDirty), + m_strEnd(strEnd), m_version_str(), state(_state) {} public: static std::regex getPattern(const std::string& delim) { - // "\D*(\d+)[^\.\s]*(?:\.\D*(\d+)[^\.\s]*(?:\.\D*(\d+))?)?"); - // return std::regex("\\D*(\\d+)[^\\"+delim+"\\s]*(?:\\"+delim+"\\D*(\\d+)[^\\"+delim+"\\s]*(?:\\"+delim+"\\D*(\\d+))?)?"); - return std::regex(R"(\D*(\d+)[^\)" + delim + "\\s]*(?:\\" + delim + R"(\D*(\d+)[^\)" + delim + "\\s]*(?:\\" + delim + "\\D*(\\d+))?)?"); + // v0.0.1-3-gd55f8a3-dirty + // return std::regex( R"(\D*(\d+)[^\.\s]*(?:\.\D*(\d+)[^\.\s]*(?:\.\D*(\d+)(?:\-(\d+)\-g([0-9a-f]+)(\-dirty)?)?)?)?)"); + return std::regex( R"(\D*(\d+)[^\)" + delim + R"(\s]*(?:\)" + delim + R"(\D*(\d+)[^\)" + delim + R"(\s]*(?:\)" + delim + R"(\D*(\d+)(?:\-(\d+)\-g([0-9a-f]+)(\-dirty)?)?)?)?)"); } static const std::regex& getDefaultPattern() noexcept { // NOLINT(bugprone-exception-escape) @@ -75,13 +87,26 @@ namespace jau::util { } /** - * Explicit version number instantiation, with all components defined explicitly. + * Explicit version number instantiation, with all components defined explicitly including git. + * @see #hasMajor() + * @see #hasMinor() + * @see #hasSub() + * @see #hasGitInfo() + */ + VersionNumber(int majorRev, int minorRev, int subMinorRev, int gitCommits, uint64_t gitSSHA, bool gitDirty) noexcept + : VersionNumber(majorRev, minorRev, subMinorRev, + gitCommits, gitSSHA, gitDirty, + -1, HAS_MAJOR | HAS_MINOR | HAS_SUB | HAS_GIT_INFO) + {} + + /** + * Explicit version number instantiation, with all components defined explicitly excluding git. * @see #hasMajor() * @see #hasMinor() * @see #hasSub() */ VersionNumber(int majorRev, int minorRev, int subMinorRev) noexcept - : VersionNumber(majorRev, minorRev, subMinorRev, -1, HAS_MAJOR | HAS_MINOR | HAS_SUB) + : VersionNumber(majorRev, minorRev, subMinorRev, 0, 0, false, -1, HAS_MAJOR | HAS_MINOR | HAS_SUB) {} /** @@ -91,7 +116,7 @@ namespace jau::util { * @see #hasSub() */ VersionNumber() noexcept - : VersionNumber(0, 0, 0, -1, HAS_MAJOR | HAS_MINOR | HAS_SUB) + : VersionNumber(0, 0, 0, 0, 0, false, -1, HAS_MAJOR | HAS_MINOR | HAS_SUB) {} VersionNumber(const VersionNumber&) noexcept = default; @@ -113,14 +138,27 @@ namespace jau::util { * @see #hasSub() */ VersionNumber(const std::string& versionString, const std::regex& versionPattern) noexcept - : m_major(0), m_minor(0), m_sub(0), m_strEnd(0), m_version_str(versionString), state(0) + : m_major(0), m_minor(0), m_sub(0), + m_git_commits(0), m_git_ssha(0), m_git_dirty(false), + m_strEnd(0), m_version_str(versionString), state(0) { // group1: \d* == digits major // group2: \d* == digits minor // group3: \d* == digits sub + // group4: \d* == digits commit-count + // group5: hex == hex short-sha + // group6: str == dirty std::smatch match; if( std::regex_search(versionString, match, versionPattern) ) { m_strEnd = match.position() + match.length(); + if constexpr ( DBG_OUT ) { + std::cout << "XXX: " << versionString << std::endl; + std::cout << "XXX: match pos " << match.position() << ", len " << match.length() << ", sz " << match.size() << std::endl; + for(size_t i=0; i<match.size(); ++i) { + const std::string& s = match[i]; + std::cout << "- [" << i << "]: '" << s << "', len " << s.length() << std::endl; + } + } if( match.size() >= 2 && match[1].length() > 0 ) { m_major = std::stoi(match[1]); state |= HAS_MAJOR; @@ -129,7 +167,26 @@ namespace jau::util { state |= HAS_MINOR; if( match.size() >= 4 && match[3].length() > 0 ) { m_sub = std::stoi(match[3]); - state |= HAS_SUB; + state |= HAS_SUB; + if( match.size() >= 5 && match[4].length() > 0 ) { + m_git_commits = std::stoi(match[4]); + state |= HAS_GIT_INFO; + if constexpr ( DBG_OUT ) { + std::cout << "XXX: git commits " << m_git_commits << std::endl; + } + if( match.size() >= 6 && match[5].length() > 0 ) { + m_git_ssha = jau::from_hexstring(match[5]); + if constexpr ( DBG_OUT ) { + std::cout << "XXX: git ssha '" << match[5] << "', hex " << jau::to_hexstring(m_git_ssha) << ", dec " << m_git_ssha << std::endl; + } + if( match.size() >= 7 && match[6].length() > 0 ) { + m_git_dirty = true; + if constexpr ( DBG_OUT ) { + std::cout << "XXX: git dirty " << m_git_dirty << std::endl; + } + } + } + } } } } @@ -187,6 +244,8 @@ namespace jau::util { constexpr bool hasMinor() const noexcept { return 0 != ( HAS_MINOR & state ); } /** Returns <code>true</code>, if the optional sub component is defined explicitly, otherwise <code>false</code>. Undefined components has the value <code>0</code>. */ constexpr bool hasSub() const noexcept { return 0 != ( HAS_SUB & state ); } + /** Returns <code>true</code>, if the optional git information is defined explicitly, otherwise <code>false</code>. */ + constexpr bool hasGitInfo() const noexcept { return 0 != ( HAS_GIT_INFO & state ); } /** Returns true if constructed with a `version-string`, otherwise false. */ constexpr bool hasString() const noexcept { return m_version_str.length() > 0; } @@ -202,10 +261,14 @@ namespace jau::util { constexpr int major() const noexcept { return m_major; } constexpr int minor() const noexcept { return m_minor; } constexpr int sub() const noexcept { return m_sub; } - + constexpr int git_commits() const noexcept { return m_git_commits; } + constexpr uint64_t git_ssha() const noexcept { return m_git_ssha; } + constexpr bool git_dirty() const noexcept { return m_git_dirty; } + /** Two way comparison operator */ constexpr bool operator==(const VersionNumber& vo) const noexcept { - return m_major == vo.m_major && m_minor == vo.m_minor && m_sub == vo.m_sub; + return m_major == vo.m_major && m_minor == vo.m_minor && m_sub == vo.m_sub && + m_git_commits == vo.m_git_commits && m_git_ssha == vo.m_git_ssha && m_git_dirty == vo.m_git_dirty; } /** Three way std::strong_ordering comparison operator */ @@ -223,11 +286,46 @@ namespace jau::util { } else if( m_sub < vo.m_sub ) { return std::strong_ordering::less; } + if( hasGitInfo() ) { + if( m_git_commits > vo.m_git_commits ) { + return std::strong_ordering::greater; + } else if( m_git_commits < vo.m_git_commits ) { + return std::strong_ordering::less; + } else if( !m_git_dirty && vo.m_git_dirty ) { + return std::strong_ordering::greater; + } else if( m_git_dirty && !vo.m_git_dirty ) { + return std::strong_ordering::less; + } else if( m_git_ssha > vo.m_git_ssha ) { // no sane interpretation of m_git_ssha + return std::strong_ordering::greater; + } else if( m_git_ssha < vo.m_git_ssha ) { // no sane interpretation of m_git_ssha + return std::strong_ordering::less; + } + } return std::strong_ordering::equal; } + constexpr std::size_t hash() const noexcept { + // 31 * x == (x << 5) - x + std::size_t h = 31 + major(); + h = ((h << 5) - h) + minor(); + h = ((h << 5) - h) + sub(); + h = (h << 15) + git_ssha(); // 32-bit aligned + return (h << 1) + ( git_dirty() ? 1 : 0 ); + } + std::string toString() const noexcept { std::string res = std::to_string(m_major) + "." + std::to_string(m_minor) + "." + std::to_string(m_sub); + if( hasGitInfo() ) { + res.append(", git[post ").append(std::to_string(m_git_commits)) + .append(", tip ").append(jau::to_hexstring(m_git_ssha, true)) + .append(", "); + if( git_dirty() ) { + res.append("dirty"); + } else { + res.append("clean"); + } + res.append("]"); + } if( hasString() ) { res.append(" (").append(m_version_str).append(")"); } @@ -235,8 +333,8 @@ namespace jau::util { } }; - - std::ostream& operator<<(std::ostream& out, const VersionNumber& v) noexcept { + + inline std::ostream& operator<<(std::ostream& out, const VersionNumber& v) noexcept { return out << v.toString(); } @@ -246,10 +344,7 @@ namespace std { template<> struct hash<jau::util::VersionNumber> { std::size_t operator()(const jau::util::VersionNumber& v) const noexcept { - // 31 * x == (x << 5) - x - std::size_t h = 31 + v.major(); - h = ((h << 5) - h) + v.minor(); - return ((h << 5) - h) + v.sub(); + return v.hash(); } }; } diff --git a/include/jau/version.hpp b/include/jau/version.hpp index bd85a98..8af90ac 100644 --- a/include/jau/version.hpp +++ b/include/jau/version.hpp @@ -26,9 +26,11 @@ #ifndef JAU_VERSION_HPP_ #define JAU_VERSION_HPP_ +#include <jau/util/VersionNumber.hpp> + namespace jau { - extern const char* VERSION; + extern const jau::util::VersionNumber VERSION; extern const char* VERSION_SHORT; extern const char* VERSION_API; diff --git a/test/test_versionnumber01.cpp b/test/test_versionnumber01.cpp index b55666f..134fe69 100644 --- a/test/test_versionnumber01.cpp +++ b/test/test_versionnumber01.cpp @@ -27,10 +27,19 @@ #include <jau/test/catch2_ext.hpp> +#include <jau/version.hpp> #include <jau/util/VersionNumber.hpp> using namespace jau::util; +TEST_CASE( "VersionNumber Test 00", "[version][util]" ) { + std::cout << "jaulib version: " << jau::VERSION << std::endl; + REQUIRE(true == jau::VERSION.hasMajor()); + REQUIRE(true == jau::VERSION.hasMinor()); + REQUIRE(true == jau::VERSION.hasSub()); + REQUIRE(true == jau::VERSION.hasString()); +} + TEST_CASE( "VersionNumber Test 01a", "[version][util]" ) { std::string vs00 = "1.0.16"; std::string vs01 = "OpenGL ES GLSL ES 1.0.16"; @@ -41,12 +50,15 @@ TEST_CASE( "VersionNumber Test 01a", "[version][util]" ) { REQUIRE(true == vn0.hasMajor()); REQUIRE(true == vn0.hasMinor()); REQUIRE(true == vn0.hasSub()); + REQUIRE(false == vn0.hasGitInfo()); VersionNumber vn(vs00); std::cout << "vn.00: " << vn << std::endl; REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == vn.hasSub()); + REQUIRE(false == vn.hasGitInfo()); + REQUIRE(true == vn.hasString()); REQUIRE(vn0 == vn); vn = VersionNumber(vs01); @@ -54,6 +66,7 @@ TEST_CASE( "VersionNumber Test 01a", "[version][util]" ) { REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == vn.hasSub()); + REQUIRE(false == vn.hasGitInfo()); REQUIRE(vn0 == vn); vn = VersionNumber(vs02); @@ -61,6 +74,7 @@ TEST_CASE( "VersionNumber Test 01a", "[version][util]" ) { REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == vn.hasSub()); + REQUIRE(false == vn.hasGitInfo()); REQUIRE(vn0 == vn); } @@ -75,6 +89,7 @@ TEST_CASE( "VersionNumber Test 01b", "[version][util]" ) { REQUIRE(true == vn0.hasMajor()); REQUIRE(true == vn0.hasMinor()); REQUIRE(true == vn0.hasSub()); + REQUIRE(false == vn0.hasGitInfo()); VersionNumber vn; vn = VersionNumber(vs00, delim); @@ -82,6 +97,7 @@ TEST_CASE( "VersionNumber Test 01b", "[version][util]" ) { REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == vn.hasSub()); + REQUIRE(false == vn.hasGitInfo()); REQUIRE(vn0 == vn); vn = VersionNumber(vs01, delim); @@ -89,6 +105,7 @@ TEST_CASE( "VersionNumber Test 01b", "[version][util]" ) { REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == vn.hasSub()); + REQUIRE(false == vn.hasGitInfo()); REQUIRE(vn0 == vn); vn = VersionNumber(vs02, delim); @@ -96,6 +113,7 @@ TEST_CASE( "VersionNumber Test 01b", "[version][util]" ) { REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == vn.hasSub()); + REQUIRE(false == vn.hasGitInfo()); REQUIRE(vn0 == vn); } @@ -108,6 +126,7 @@ TEST_CASE( "VersionNumber Test 02a", "[version][util]" ) { REQUIRE(true == vn0.hasMajor()); REQUIRE(true == vn0.hasMinor()); REQUIRE(true == vn0.hasSub()); + REQUIRE(false == vn0.hasGitInfo()); VersionNumber vn; vn = VersionNumber(vs00); @@ -115,6 +134,7 @@ TEST_CASE( "VersionNumber Test 02a", "[version][util]" ) { REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == !vn.hasSub()); + REQUIRE(false == vn.hasGitInfo()); REQUIRE(vn0 == vn); vn = VersionNumber(vs01); @@ -122,6 +142,7 @@ TEST_CASE( "VersionNumber Test 02a", "[version][util]" ) { REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == !vn.hasSub()); + REQUIRE(false == vn.hasGitInfo()); REQUIRE(vn0 == vn); vn = VersionNumber(vs02); @@ -129,6 +150,7 @@ TEST_CASE( "VersionNumber Test 02a", "[version][util]" ) { REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == !vn.hasSub()); + REQUIRE(false == vn.hasGitInfo()); REQUIRE(vn0 == vn); } @@ -142,6 +164,7 @@ TEST_CASE( "VersionNumber Test 02b", "[version][util]" ) { REQUIRE(true == vn0.hasMajor()); REQUIRE(true == vn0.hasMinor()); REQUIRE(true == vn0.hasSub()); + REQUIRE(false == vn0.hasGitInfo()); VersionNumber vn; @@ -149,18 +172,21 @@ TEST_CASE( "VersionNumber Test 02b", "[version][util]" ) { REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == !vn.hasSub()); + REQUIRE(false == vn.hasGitInfo()); REQUIRE(vn0 == vn); vn = VersionNumber(vs01, delim); REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == !vn.hasSub()); + REQUIRE(false == vn.hasGitInfo()); REQUIRE(vn0 == vn); vn = VersionNumber(vs02, delim); REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == !vn.hasSub()); + REQUIRE(false == vn.hasGitInfo()); REQUIRE(vn0 == vn); } @@ -172,6 +198,7 @@ TEST_CASE( "VersionNumber Test 03a", "[version][util]" ) { REQUIRE(true == vn0.hasMajor()); REQUIRE(true == vn0.hasMinor()); REQUIRE(true == vn0.hasSub()); + REQUIRE(false == vn0.hasGitInfo()); VersionNumber vn; @@ -179,18 +206,21 @@ TEST_CASE( "VersionNumber Test 03a", "[version][util]" ) { REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == vn.hasSub()); + REQUIRE(false == vn.hasGitInfo()); REQUIRE(vn0 == vn); vn = VersionNumber(vs01); REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == vn.hasSub()); + REQUIRE(false == vn.hasGitInfo()); REQUIRE(vn0 == vn); vn = VersionNumber(vs02); REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == vn.hasSub()); + REQUIRE(false == vn.hasGitInfo()); REQUIRE(vn0 == vn); } @@ -204,6 +234,7 @@ TEST_CASE( "VersionNumber Test 03b", "[version][util]" ) { REQUIRE(true == vn0.hasMajor()); REQUIRE(true == vn0.hasMinor()); REQUIRE(true == vn0.hasSub()); + REQUIRE(false == vn0.hasGitInfo()); VersionNumber vn; @@ -211,79 +242,58 @@ TEST_CASE( "VersionNumber Test 03b", "[version][util]" ) { REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == vn.hasSub()); + REQUIRE(false == vn.hasGitInfo()); REQUIRE(vn0 == vn); vn = VersionNumber(vs01, delim); REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == vn.hasSub()); + REQUIRE(false == vn.hasGitInfo()); REQUIRE(vn0 == vn); vn = VersionNumber(vs02, delim); REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == vn.hasSub()); + REQUIRE(false == vn.hasGitInfo()); REQUIRE(vn0 == vn); } TEST_CASE( "VersionNumber Test 04a", "[version][util]" ) { - const std::string vs00 = "A10.11.12b (git-d6c318e)"; - const std::string vs01 = "Prelim Text 10.Funny11.Weird12 Something is odd (git-d6c318e)"; - const std::string vs02 = "Prelim Text 10.Funny11l1.Weird12 2 Something is odd (git-d6c318e)"; - const VersionNumber vn0 = VersionNumber(10, 11, 12); + const std::string vs00 = "v1.2.3-10-gabcdef-dirty"; + const std::string vs01 = "v1.2.3-11-g1abcdef"; + const VersionNumber vn0 = VersionNumber(1, 2, 3, 10, 0xabcdef, true); + const VersionNumber vn1 = VersionNumber(1, 2, 3, 11, 0x1abcdef, false); + std::cout << "vn0: " << vn0 << std::endl; + std::cout << "vn1: " << vn1 << std::endl; + REQUIRE(vn1 > vn0); + REQUIRE(vn1.hash() != vn0.hash()); REQUIRE(true == vn0.hasMajor()); REQUIRE(true == vn0.hasMinor()); REQUIRE(true == vn0.hasSub()); - + REQUIRE(true == vn0.hasGitInfo()); + REQUIRE(true == vn1.hasMajor()); + REQUIRE(true == vn1.hasMinor()); + REQUIRE(true == vn1.hasSub()); + REQUIRE(true == vn1.hasGitInfo()); + VersionNumber vn; vn = VersionNumber(vs00); + std::cout << "vn.00: " << vn << std::endl; REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == vn.hasSub()); + REQUIRE(true == vn.hasGitInfo()); REQUIRE(vn0 == vn); vn = VersionNumber(vs01); + std::cout << "vn.01: " << vn << std::endl; REQUIRE(true == vn.hasMajor()); REQUIRE(true == vn.hasMinor()); REQUIRE(true == vn.hasSub()); - REQUIRE(vn0 == vn); - - vn = VersionNumber(vs02); - REQUIRE(true == vn.hasMajor()); - REQUIRE(true == vn.hasMinor()); - REQUIRE(true == vn.hasSub()); - REQUIRE(vn0 == vn); + REQUIRE(true == vn.hasGitInfo()); + REQUIRE(vn1 == vn); } -TEST_CASE( "VersionNumber Test 04b", "[version][util]" ) { - const std::string delim = ","; - - const std::string vs00 = "A10,11,12b (git-d6c318e)"; - const std::string vs01 = "Prelim Text 10,Funny11,Weird12 Something is odd (git-d6c318e)"; - const std::string vs02 = "Prelim Text 10,Funny11l1,Weird12 2 Something is odd (git-d6c318e)"; - const VersionNumber vn0 = VersionNumber(10, 11, 12); - REQUIRE(true == vn0.hasMajor()); - REQUIRE(true == vn0.hasMinor()); - REQUIRE(true == vn0.hasSub()); - - VersionNumber vn; - - vn = VersionNumber(vs00, delim); - REQUIRE(true == vn.hasMajor()); - REQUIRE(true == vn.hasMinor()); - REQUIRE(true == vn.hasSub()); - REQUIRE(vn0 == vn); - - vn = VersionNumber(vs01, delim); - REQUIRE(true == vn.hasMajor()); - REQUIRE(true == vn.hasMinor()); - REQUIRE(true == vn.hasSub()); - REQUIRE(vn0 == vn); - - vn = VersionNumber(vs02, delim); - REQUIRE(true == vn.hasMajor()); - REQUIRE(true == vn.hasMinor()); - REQUIRE(true == vn.hasSub()); - REQUIRE(vn0 == vn); -} |