diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-06-27 23:51:09 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-07-21 08:52:19 +0200 |
commit | 6e3bfe103968390bd486293df93b381a13ad34df (patch) | |
tree | b9c45daca9800499b201a745fd56389ed7aaf754 /tests | |
parent | ccad54fefd2d8c980c61ae487dd3bcc9237a6137 (diff) |
Adopt for use as ODB value types
Diffstat (limited to 'tests')
-rw-r--r-- | tests/manifest-parser/driver.cxx | 4 | ||||
-rw-r--r-- | tests/manifest-roundtrip/driver.cxx | 2 | ||||
-rw-r--r-- | tests/package-version/driver.cxx | 36 |
3 files changed, 39 insertions, 3 deletions
diff --git a/tests/manifest-parser/driver.cxx b/tests/manifest-parser/driver.cxx index c54e2f0..0fd64f4 100644 --- a/tests/manifest-parser/driver.cxx +++ b/tests/manifest-parser/driver.cxx @@ -132,8 +132,8 @@ main () {{"","1"},{"a","x\\\\"},{"b",""},{"",""},{"",""}})); } -static std::ostream& -operator<< (std::ostream& os, const pairs& ps) +static ostream& +operator<< (ostream& os, const pairs& ps) { os << '{'; diff --git a/tests/manifest-roundtrip/driver.cxx b/tests/manifest-roundtrip/driver.cxx index f8a95bd..d7c7707 100644 --- a/tests/manifest-roundtrip/driver.cxx +++ b/tests/manifest-roundtrip/driver.cxx @@ -49,7 +49,7 @@ main (int argc, char* argv[]) cerr << "io failure" << endl; return 1; } - catch (const std::exception& e) + catch (const exception& e) { cerr << e.what () << endl; return 1; diff --git a/tests/package-version/driver.cxx b/tests/package-version/driver.cxx index 5508c20..d9a54d0 100644 --- a/tests/package-version/driver.cxx +++ b/tests/package-version/driver.cxx @@ -4,6 +4,7 @@ #include <string> #include <cassert> +#include <cstdint> // uint16 #include <iostream> #include <exception> #include <stdexcept> // invalid_argument @@ -27,6 +28,26 @@ bad_version (const string& v) } } +static bool +bad_version (uint16_t e, const string& u, uint16_t r) +{ + try + { + version bv (e, u, r); + return false; + } + catch (const invalid_argument&) + { + return true; + } +} + +static bool +test_constructor (const version& v) +{ + return v == version (v.epoch (), v.upstream (), v.revision ()); +} + int main (int argc, char* argv[]) { @@ -62,83 +83,98 @@ main (int argc, char* argv[]) assert (bad_version ("a-3s")); // Same. assert (bad_version ("a.")); // Not completed upstream. assert (bad_version ("a..b")); // Empty upstream component. + assert (bad_version (1, "1+1.1", 2)); // Epoch in upstream. + assert (bad_version (1, "1.1-1", 2)); // Revision in upstream. { version v ("a"); assert (v.string () == "a"); assert (v.canonical_upstream () == "a"); + assert (test_constructor (v)); } { version v ("65535+ab-65535"); assert (v.string () == "65535+ab-65535"); assert (v.canonical_upstream () == "ab"); + assert (test_constructor (v)); } { version v ("1"); assert (v.string () == "1"); assert (v.canonical_upstream () == "00000001"); + assert (test_constructor (v)); } { version v ("0"); assert (v.string () == "0"); assert (v.canonical_upstream ().empty ()); + assert (test_constructor (v)); } { version v ("0.0.0"); assert (v.string () == "0.0.0"); assert (v.canonical_upstream ().empty ()); + assert (test_constructor (v)); } { version v ("1.0.0"); assert (v.string () == "1.0.0"); assert (v.canonical_upstream () == "00000001"); + assert (test_constructor (v)); } { version v ("0.1.00"); assert (v.string () == "0.1.00"); assert (v.canonical_upstream () == "00000000.00000001"); + assert (test_constructor (v)); } { version v ("0.0a.00"); assert (v.string () == "0.0a.00"); assert (v.canonical_upstream () == "00000000.0a"); + assert (test_constructor (v)); } { version v ("0.a00.00"); assert (v.string () == "0.a00.00"); assert (v.canonical_upstream () == "00000000.a00"); + assert (test_constructor (v)); } { version v ("1+0"); assert (v.string () == "1+0"); assert (v.canonical_upstream ().empty ()); + assert (test_constructor (v)); } { version v ("0+A-1"); assert (v.string () == "A-1"); assert (v.canonical_upstream () == "a"); + assert (test_constructor (v)); } { version v ("10+B-0"); assert (v.string () == "10+B"); assert (v.canonical_upstream () == "b"); + assert (test_constructor (v)); } { version v ("3+1A.31.0.4.0-7"); assert (v.string () == "3+1A.31.0.4.0-7"); assert (v.canonical_upstream () == "1a.00000031.00000000.00000004"); + assert (test_constructor (v)); } assert (version ("a") == version ("a")); |