Skip to content

Commit

Permalink
Note change and add a few more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
theory committed Jul 17, 2024
1 parent 3676b25 commit ac5e2b5
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 45 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Revision history for PostgreSQL extension semver.
- Changed the tests to use `CREATE EXTENSION` instead of loading the
SQL source file directory. The latter was required for Postgres 9.0
and lower, which have not been supported since v0.20.0 back in 2018.
- Fixed a bug that rejected pre-releases starting with a zero but
eventually include a dash, e.g., `1.2.3-02-3`. Thanks to Dylan
Bourque for the pull request (#70)!

0.32.1 2023-08-01T23:20:31Z
- Fixed compilation issue on Postgres 16.
Expand Down
1 change: 1 addition & 0 deletions src/semver.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* + Sam Vilain <sam@vilain.net>
* + Tom Davis <tom@recursivedream.com>
* + Xavier Caron <xcaron@gmail.com>
* + David Wheeler <david@justatheory.com>
*
* Copyright 2010-2024 The pg-semver Maintainers. This program is Free
* Software; see the LICENSE file for the license conditions.
Expand Down
93 changes: 50 additions & 43 deletions test/expected/corpus.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
\set ECHO none
1..71
1..75
ok 1 - "0.0.4" is a valid semver
ok 2 - "1.2.3" is a valid semver
ok 3 - "10.20.30" is a valid semver
Expand Down Expand Up @@ -31,46 +31,53 @@ ok 28 - "1.2.3----RC-SNAPSHOT.12.9.1--.12" is a valid semver
ok 29 - "1.0.0+0.build.1-rc.10000aaa-kk-0.1" is a valid semver
ok 30 - "1.0.0-0A.is.legal" is a valid semver
ok 31 - "1.0.0-0010-1234" is a valid semver
not ok 32 - "99999999999999999999999.999999999999999999.99999999999999999" is a valid semver # TODO Large versions overflow integer bounds
# Failed (TODO) test 32: ""99999999999999999999999.999999999999999999.99999999999999999" is a valid semver"
ok 32 - "1.0.0-1.2.3-1234" is a valid semver
ok 33 - "1.0.0-1234" is a valid semver
ok 34 - "1.0.0-4321" is a valid semver
not ok 35 - "99999999999999999999999.999999999999999999.99999999999999999" is a valid semver # TODO Large versions overflow integer bounds
# Failed (TODO) test 35: ""99999999999999999999999.999999999999999999.99999999999999999" is a valid semver"
# died: XX000: bad semver value '99999999999999999999999.999999999999999999.99999999999999999': version number exceeds 31-bit range
ok 33 - "1" is not a valid semver
ok 34 - "1.2" is not a valid semver
ok 35 - "1.2.3-0123" is not a valid semver
ok 36 - "1.2.3-0123.0123" is not a valid semver
ok 37 - "1.1.2+.123" is not a valid semver
ok 38 - "+invalid" is not a valid semver
ok 39 - "-invalid" is not a valid semver
ok 40 - "-invalid+invalid" is not a valid semver
ok 41 - "-invalid.01" is not a valid semver
ok 42 - "alpha" is not a valid semver
ok 43 - "alpha.beta" is not a valid semver
ok 44 - "alpha.beta.1" is not a valid semver
ok 45 - "alpha.1" is not a valid semver
ok 46 - "alpha+beta" is not a valid semver
ok 47 - "alpha_beta" is not a valid semver
ok 48 - "alpha." is not a valid semver
ok 49 - "alpha.." is not a valid semver
ok 50 - "beta" is not a valid semver
ok 51 - "1.0.0-alpha_beta" is not a valid semver
ok 52 - "-alpha." is not a valid semver
ok 53 - "1.0.0-alpha.." is not a valid semver
ok 54 - "1.0.0-alpha..1" is not a valid semver
ok 55 - "1.0.0-alpha...1" is not a valid semver
ok 56 - "1.0.0-alpha....1" is not a valid semver
ok 57 - "1.0.0-alpha.....1" is not a valid semver
ok 58 - "1.0.0-alpha......1" is not a valid semver
ok 59 - "1.0.0-alpha.......1" is not a valid semver
ok 60 - "01.1.1" is not a valid semver
ok 61 - "1.01.1" is not a valid semver
ok 62 - "1.1.01" is not a valid semver
ok 63 - "1.2" is not a valid semver
ok 64 - "1.2.3.DEV" is not a valid semver
ok 65 - "1.2-SNAPSHOT" is not a valid semver
ok 66 - "1.2.31.2.3----RC-SNAPSHOT.12.09.1--..12+788" is not a valid semver
ok 67 - "1.2-RC-SNAPSHOT" is not a valid semver
ok 68 - "-1.0.3-gamma+b7718" is not a valid semver
ok 69 - "+justmeta" is not a valid semver
ok 70 - "9.8.7+meta+meta" is not a valid semver
ok 71 - "9.8.7-whatever+meta+meta" is not a valid semver
ok 72 - "99999999999999999999999.999999999999999999.99999999999999999----RC-SNAPSHOT.12.09.1--------------------------------..12" is not a valid semver
ok 36 - "1" is not a valid semver
ok 37 - "1.2" is not a valid semver
not ok 38 - "1.2.3-0123" is not a valid semver
# Failed test 38: ""1.2.3-0123" is not a valid semver"
# caught: no exception
# wanted: an exception
ok 39 - "1.2.3-0123.0123" is not a valid semver
ok 40 - "1.1.2+.123" is not a valid semver
ok 41 - "+invalid" is not a valid semver
ok 42 - "-invalid" is not a valid semver
ok 43 - "-invalid+invalid" is not a valid semver
ok 44 - "-invalid.01" is not a valid semver
ok 45 - "alpha" is not a valid semver
ok 46 - "alpha.beta" is not a valid semver
ok 47 - "alpha.beta.1" is not a valid semver
ok 48 - "alpha.1" is not a valid semver
ok 49 - "alpha+beta" is not a valid semver
ok 50 - "alpha_beta" is not a valid semver
ok 51 - "alpha." is not a valid semver
ok 52 - "alpha.." is not a valid semver
ok 53 - "beta" is not a valid semver
ok 54 - "1.0.0-alpha_beta" is not a valid semver
ok 55 - "-alpha." is not a valid semver
ok 56 - "1.0.0-alpha.." is not a valid semver
ok 57 - "1.0.0-alpha..1" is not a valid semver
ok 58 - "1.0.0-alpha...1" is not a valid semver
ok 59 - "1.0.0-alpha....1" is not a valid semver
ok 60 - "1.0.0-alpha.....1" is not a valid semver
ok 61 - "1.0.0-alpha......1" is not a valid semver
ok 62 - "1.0.0-alpha.......1" is not a valid semver
ok 63 - "01.1.1" is not a valid semver
ok 64 - "1.01.1" is not a valid semver
ok 65 - "1.1.01" is not a valid semver
ok 66 - "1.2" is not a valid semver
ok 67 - "1.2.3.DEV" is not a valid semver
ok 68 - "1.2-SNAPSHOT" is not a valid semver
ok 69 - "1.2.31.2.3----RC-SNAPSHOT.12.09.1--..12+788" is not a valid semver
ok 70 - "1.2-RC-SNAPSHOT" is not a valid semver
ok 71 - "-1.0.3-gamma+b7718" is not a valid semver
ok 72 - "+justmeta" is not a valid semver
ok 73 - "9.8.7+meta+meta" is not a valid semver
ok 74 - "9.8.7-whatever+meta+meta" is not a valid semver
ok 75 - "99999999999999999999999.999999999999999999.99999999999999999----RC-SNAPSHOT.12.09.1--------------------------------..12" is not a valid semver
# Looks like you failed 1 test of 75
7 changes: 5 additions & 2 deletions test/sql/corpus.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ BEGIN;
\i test/pgtap-core.sql
CREATE EXTENSION semver;

SELECT plan(71);
SELECT plan(75);
--SELECT * FROM no_plan();

-- Valid Semantic Versions
Expand Down Expand Up @@ -44,7 +44,10 @@ SELECT lives_ok(
'1.2.3----RC-SNAPSHOT.12.9.1--.12',
'1.0.0+0.build.1-rc.10000aaa-kk-0.1',
'1.0.0-0A.is.legal',
'1.0.0-0010-1234'
'1.0.0-0010-1234',
'1.0.0-1.2.3-1234',
'1.0.0-1234',
'1.0.0-4321'
--
]) AS v;

Expand Down

0 comments on commit ac5e2b5

Please sign in to comment.