aboutsummaryrefslogtreecommitdiff
path: root/tests/package-version
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-06-27 23:51:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-07-21 08:52:19 +0200
commit6e3bfe103968390bd486293df93b381a13ad34df (patch)
treeb9c45daca9800499b201a745fd56389ed7aaf754 /tests/package-version
parentccad54fefd2d8c980c61ae487dd3bcc9237a6137 (diff)
Adopt for use as ODB value types
Diffstat (limited to 'tests/package-version')
-rw-r--r--tests/package-version/driver.cxx36
1 files changed, 36 insertions, 0 deletions
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"));