diff options
Diffstat (limited to 'tests/package-version/driver.cxx')
-rw-r--r-- | tests/package-version/driver.cxx | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/tests/package-version/driver.cxx b/tests/package-version/driver.cxx index 57c3f04..0a5ff43 100644 --- a/tests/package-version/driver.cxx +++ b/tests/package-version/driver.cxx @@ -2,17 +2,19 @@ // license : MIT; see accompanying LICENSE file #include <string> -#include <cassert> #include <cstdint> // uint16 #include <iostream> #include <exception> #include <stdexcept> // invalid_argument -#include <libbutl/utility.mxx> // operator<<(ostream, exception) -#include <libbutl/optional.mxx> +#include <libbutl/utility.hxx> // operator<<(ostream, exception) +#include <libbutl/optional.hxx> #include <libbpkg/manifest.hxx> +#undef NDEBUG +#include <cassert> + using namespace std; using namespace butl; @@ -22,11 +24,12 @@ namespace bpkg using butl::nullopt; static bool - bad_version (const string& v) + bad_version (const string& v, + version::flags fl = version::fold_zero_revision) { try { - version bv (v); + version bv (v, fl); return false; } catch (const invalid_argument&) @@ -136,6 +139,16 @@ namespace bpkg assert (bad_version (0, "", "", 0)); // Same. assert (bad_version (0, "", "", 0, 1)); // Unexpected iteration. + assert (bad_version ("1.0.0#1")); // Iteration disallowed. + + // Bad iteration. + // + assert (bad_version ("1.0.0#a", version::allow_iteration)); + assert (bad_version ("1.0.0#1a", version::allow_iteration)); + assert (bad_version ("1.0.0#", version::allow_iteration)); + assert (bad_version ("1.0.0#5000000000", version::allow_iteration)); + assert (bad_version ("1.0.0#+1", version::allow_iteration)); + { version v1; assert (v1.empty ()); @@ -256,7 +269,7 @@ namespace bpkg assert (test_constructor (v)); } { - version v ("+10-B+0", false /* fold_zero_revision */); + version v ("+10-B+0", version::none); assert (v.string () == "+10-B+0"); assert (v.canonical_upstream == "b"); assert (test_constructor (v)); @@ -405,6 +418,9 @@ namespace bpkg assert (version (1, "2.0", nullopt, 3, 4).compare ( version (1, "2.0", nullopt, 5, 6), true) == 0); + + assert (version ("1.1.1-a.0.1+2#34", version::flags::allow_iteration) == + version (1, "1.1.1", string ("a.0.1"), 2, 34)); } catch (const exception& e) { |