Neargye / semver

Semantic Versioning for modern C++
MIT License
296 stars 32 forks source link

feature request: from_string accepts incomplete version strings #22

Open daixtrose opened 3 years ago

daixtrose commented 3 years ago

The test

TEST_CASE("semver::from_string", "[demo]")
{
    using namespace semver;
    // auto version = semver::from_string("1.0.0"); // SUCCEEDS
    auto version = semver::from_string("1.0"); // FAILS
    REQUIRE(version == "1.0.0"_version);
}

fails with an exception

semver::version::from_string invalid version.

It is quite common to omit the patch version. So the from_string/from_chars function pair should be robust against the omission and add .0.

MHebes commented 2 years ago

1.0 is not technically a valid semver for what it's worth