From dad361a3415e88475a78d1b2702133629fb6e548 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 27 Apr 2017 15:11:56 +0300 Subject: Add standard_version_constraint struct --- tests/standard-version/driver.cxx | 10 +++++ tests/standard-version/testscript | 83 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) (limited to 'tests') diff --git a/tests/standard-version/driver.cxx b/tests/standard-version/driver.cxx index 1299090..d301c8c 100644 --- a/tests/standard-version/driver.cxx +++ b/tests/standard-version/driver.cxx @@ -72,11 +72,13 @@ version (const string& s) // argv[0] -a // argv[0] -b // argv[0] -c +// argv[0] -r // argv[0] // // -a output 'y' for alpha-version, 'n' otherwise // -b output 'y' for beta-version, 'n' otherwise // -c output 0 if versions are equal, -1 if the first one is less, 1 otherwise +// -r create version constraints from STDIN lines, and print them to STDOUT // // If no options are specified, then create versions from STDIN lines, and // print them to STDOUT. @@ -117,6 +119,14 @@ try int r (version (argv[2]).compare (version (argv[3]))); cout << r << endl; } + else if (o == "-r") + { + assert (argc == 2); + + string s; + while (getline (cin, s)) + cout << standard_version_constraint (s) << endl; + } else assert (false); diff --git a/tests/standard-version/testscript b/tests/standard-version/testscript index 335bed9..9c80ddb 100644 --- a/tests/standard-version/testscript +++ b/tests/standard-version/testscript @@ -188,3 +188,86 @@ $* '1.2.3-a.1.2.xy' '1.2.3-a.1.2' >'0' : ignore-snapshot-id } } + +: constraints +: +{ + test.options += -r + + : range + : + { + : valid + : + $* <>EOE + [1.2.3 1.2.4] + (1.2.3 1.2.4) + [ 1.2.3 1.2.4 ] + EOI + [1.2.3 1.2.4] + (1.2.3 1.2.4) + [1.2.3 1.2.4] + EOE + + : invalid + : + { + $* <'' 2>'invalid constraint' == 1 : empty + $* <'1' 2>'invalid constraint' == 1 : no-opening + $* <'[ ' 2>'no min version' == 1 : no-min + $* <'[1.2.3' 2>'no max version' == 1 : no-max + $* <'[1.2.3 1.2.4' 2>'no closing bracket' == 1 : no-closing + $* <'[1.2.3 1.2.4)]' 2>'junk after constraint' == 1 : junk + + : invalid-min + : + $* <'[1' 2>"invalid min version: '.' expected after major version" == 1 + + : invalid-max + : + $* <'[1.2.3 1' 2>"invalid max version: '.' expected after major version" == 1 + + : min-gt-max + : + $* <'[1.2.4 1.2.3]' 2>'min version is greater than max version' == 1 + + : open-end + : + $* <'[1.2.3 1.2.3)' 2>'equal version endpoints not closed' == 1 + } + } + + : comparison + : + { + : valid + : + $* <>EOE + == 1.2.3 + >= 1.2.3 + <= 1.2.3 + > 1.2.3 + < 1.2.3 + <=1.2.3 + <1.2.3 + EOI + == 1.2.3 + >= 1.2.3 + <= 1.2.3 + > 1.2.3 + < 1.2.3 + <= 1.2.3 + < 1.2.3 + EOE + + : invalid + : + { + $* <'>=' 2>'no version' == 1 : no-version + + : junk + : + $* <'>= 1.2.3-a.1.1.ads@' 2>'invalid version: junk after version' == 1 + } + } +} -- cgit v1.1