Repository: Masterminds/semver
Pull request #112 (2019-09-03 13:44:02)

Restoring v1 Go package API
There have been issues reported by those installing applications
using go get where semver no longer works because the API changed.
This commit restores the Go API to the old interface.

Note, some of the performance improvement (including allocations
and speed) were lost in this change.

Some functions were renamed including:
* CoerceNewVersion -> NewVersion
* NewVersion -> StrictNewVersion


Patch:
diff --git a/collection.go b/collection.go
index 459fbe0..a782358 100644
--- a/collection.go
+++ b/collection.go
@@ -3,7 +3,7 @@ package semver
 // Collection is a collection of Version instances and implements the sort
 // interface. See the sort package for more details.
 // https://golang.org/pkg/sort/
-type Collection []Version
+type Collection []*Version
 
 // Len returns the length of a collection. The number of Version instances
 // on the slice.
diff --git a/constraints.go b/constraints.go
index 45b9cb4..2344286 100644
--- a/constraints.go
+++ b/constraints.go
@@ -41,7 +41,7 @@ func NewConstraint(c string) (*Constraints, error) {
 }
 
 // Check tests if a version satisfies the constraints.
-func (cs Constraints) Check(v Version) bool {
+func (cs Constraints) Check(v *Version) bool {
 	// loop over the ORs and check the inner ANDs
 	for _, o := range cs.constraints {
 		joy := true
@@ -62,7 +62,7 @@ func (cs Constraints) Check(v Version) bool {
 
 // Validate checks if a version satisfies a constraint. If not a slice of
 // reasons for the failure are returned in addition to a bool.
-func (cs Constraints) Validate(v Version) (bool, []error) {
+func (cs Constraints) Validate(v *Version) (bool, []error) {
 	// loop over the ORs and check the inner ANDs
 	var e []error
 
@@ -160,7 +160,7 @@ type constraint struct {
 
 	// The version used in the constraint check. For example, if a constraint
 	// is '<= 2.0.0' the con a version instance representing 2.0.0.
-	con Version
+	con *Version
 
 	// The original parsed version (e.g., 4.x from != 4.x)
 	orig string
@@ -172,11 +172,11 @@ type constraint struct {
 }
 
 // Check if a version meets the constraint
-func (c *constraint) check(v Version) bool {
+func (c *constraint) check(v *Version) bool {
 	return c.function(v, c)
 }
 
-type cfunc func(v Version, c *constraint) bool
+type cfunc func(v *Version, c *constraint) bool
 
 func parseConstraint(c string) (*constraint, error) {
 	m := constraintRegex.FindStringSubmatch(c)
@@ -202,7 +202,7 @@ func parseConstraint(c string) (*constraint, error) {
 		ver = fmt.Sprintf("%s%s.0%s", m[3], m[4], m[6])
 	}
 
-	con, err := CoerceNewVersion(ver)
+	con, err := NewVersion(ver)
 	if err != nil {
 
 		// The constraintRegex should catch any regex parsing errors. So,
@@ -223,7 +223,7 @@ func parseConstraint(c string) (*constraint, error) {
 }
 
 // Constraint functions
-func constraintNotEqual(v Version, c *constraint) bool {
+func constraintNotEqual(v *Version, c *constraint) bool {
 	if c.dirty {
 
 		// If there is a pre-release on the version but the constraint isn't looking
@@ -254,7 +254,7 @@ func constraintNotEqual(v Version, c *constraint) bool {
 	return !v.Equal(c.con)
 }
 
-func constraintGreaterThan(v Version, c *constraint) bool {
+func constraintGreaterThan(v *Version, c *constraint) bool {
 
 	// If there is a pre-release on the version but the constraint isn't looking
 	// for them assume that pre-releases are not compatible. See issue 21 for
@@ -286,7 +286,7 @@ func constraintGreaterThan(v Version, c *constraint) bool {
 	return v.Compare(c.con) == 1
 }
 
-func constraintLessThan(v Version, c *constraint) bool {
+func constraintLessThan(v *Version, c *constraint) bool {
 	// If there is a pre-release on the version but the constraint isn't looking
 	// for them assume that pre-releases are not compatible. See issue 21 for
 	// more details.
@@ -297,7 +297,7 @@ func constraintLessThan(v Version, c *constraint) bool {
 	return v.Compare(c.con) < 0
 }
 
-func constraintGreaterThanEqual(v Version, c *constraint) bool {
+func constraintGreaterThanEqual(v *Version, c *constraint) bool {
 
 	// If there is a pre-release on the version but the constraint isn't looking
 	// for them assume that pre-releases are not compatible. See issue 21 for
@@ -309,7 +309,7 @@ func constraintGreaterThanEqual(v Version, c *constraint) bool {
 	return v.Compare(c.con) >= 0
 }
 
-func constraintLessThanEqual(v Version, c *constraint) bool {
+func constraintLessThanEqual(v *Version, c *constraint) bool {
 	// If there is a pre-release on the version but the constraint isn't looking
 	// for them assume that pre-releases are not compatible. See issue 21 for
 	// more details.
@@ -336,7 +336,7 @@ func constraintLessThanEqual(v Version, c *constraint) bool {
 // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0, <1.3.0
 // ~1.2.3, ~>1.2.3 --> >=1.2.3, <1.3.0
 // ~1.2.0, ~>1.2.0 --> >=1.2.0, <1.3.0
-func constraintTilde(v Version, c *constraint) bool {
+func constraintTilde(v *Version, c *constraint) bool {
 	// If there is a pre-release on the version but the constraint isn't looking
 	// for them assume that pre-releases are not compatible. See issue 21 for
 	// more details.
@@ -368,7 +368,7 @@ func constraintTilde(v Version, c *constraint) bool {
 
 // When there is a .x (dirty) status it automatically opts in to ~. Otherwise
 // it's a straight =
-func constraintTildeOrEqual(v Version, c *constraint) bool {
+func constraintTildeOrEqual(v *Version, c *constraint) bool {
 	// If there is a pre-release on the version but the constraint isn't looking
 	// for them assume that pre-releases are not compatible. See issue 21 for
 	// more details.
@@ -389,7 +389,7 @@ func constraintTildeOrEqual(v Version, c *constraint) bool {
 // ^1.2, ^1.2.x --> >=1.2.0, <2.0.0
 // ^1.2.3 --> >=1.2.3, <2.0.0
 // ^1.2.0 --> >=1.2.0, <2.0.0
-func constraintCaret(v Version, c *constraint) bool {
+func constraintCaret(v *Version, c *constraint) bool {
 	// If there is a pre-release on the version but the constraint isn't looking
 	// for them assume that pre-releases are not compatible. See issue 21 for
 	// more details.
diff --git a/version.go b/version.go
index 5aa2e44..3c0a2df 100644
--- a/version.go
+++ b/version.go
@@ -63,26 +63,26 @@ func init() {
 const num string = "0123456789"
 const allowed string = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-" + num
 
-// NewVersion parses a given version and returns an instance of Version or
+// StrictNewVersion parses a given version and returns an instance of Version or
 // an error if unable to parse the version. Only parses valid semantic versions.
 // Performs checking that can find errors within the version.
 // If you want to coerce a version, such as 1 or 1.2, and perse that as the 1.x
-// releases of semver provided use the CoerceNewSemver() function.
-func NewVersion(v string) (Version, error) {
+// releases of semver provided use the NewSemver() function.
+func StrictNewVersion(v string) (*Version, error) {
 	// Parsing here does not use RegEx in order to increase performance and reduce
 	// allocations.
 
 	if len(v) == 0 {
-		return Version{}, ErrEmptyString
+		return nil, ErrEmptyString
 	}
 
 	// Split the parts into [0]major, [1]minor, and [2]patch,prerelease,build
 	parts := strings.SplitN(v, ".", 3)
 	if len(parts) != 3 {
-		return Version{}, ErrInvalidSemVer
+		return nil, ErrInvalidSemVer
 	}
 
-	sv := Version{
+	sv := &Version{
 		original: v,
 	}
 
@@ -109,11 +109,11 @@ func NewVersion(v string) (Version, error) {
 	// numbers and no leading 0's.
 	for _, p := range parts {
 		if !containsOnly(p, num) {
-			return Version{}, ErrInvalidCharacters
+			return nil, ErrInvalidCharacters
 		}
 
 		if len(p) > 1 && p[0] == '0' {
-			return Version{}, ErrSegmentStartsZero
+			return nil, ErrSegmentStartsZero
 		}
 	}
 
@@ -121,17 +121,17 @@ func NewVersion(v string) (Version, error) {
 	var err error
 	sv.major, err = strconv.ParseUint(parts[0], 10, 64)
 	if err != nil {
-		return Version{}, err
+		return nil, err
 	}
 
 	sv.minor, err = strconv.ParseUint(parts[1], 10, 64)
 	if err != nil {
-		return Version{}, err
+		return nil, err
 	}
 
 	sv.patch, err = strconv.ParseUint(parts[2], 10, 64)
 	if err != nil {
-		return Version{}, err
+		return nil, err
 	}
 
 	// No prerelease or build metadata found so returning now as a fastpath.
@@ -148,10 +148,10 @@ func NewVersion(v string) (Version, error) {
 		for _, p := range eparts {
 			if containsOnly(p, num) {
 				if len(p) > 1 && p[0] == '0' {
-					return Version{}, ErrSegmentStartsZero
+					return nil, ErrSegmentStartsZero
 				}
 			} else if !containsOnly(p, allowed) {
-				return Version{}, ErrInvalidCharacters
+				return nil, ErrInvalidCharacters
 			}
 		}
 	}
@@ -164,7 +164,7 @@ func NewVersion(v string) (Version, error) {
 		eparts := strings.Split(sv.metadata, ".")
 		for _, p := range eparts {
 			if !containsOnly(p, allowed) {
-				return Version{}, ErrInvalidCharacters
+				return nil, ErrInvalidCharacters
 			}
 		}
 	}
@@ -172,16 +172,17 @@ func NewVersion(v string) (Version, error) {
 	return sv, nil
 }
 
-// CoerceNewVersion parses a given version and returns an instance of Version or
+// NewVersion parses a given version and returns an instance of Version or
 // an error if unable to parse the version. If the version is SemVer-ish it
-// attempts to convert it to SemVer.
-func CoerceNewVersion(v string) (Version, error) {
+// attempts to convert it to SemVer. If you want  to validate it was a strict
+// semantic version at parse time see StrictNewVersion().
+func NewVersion(v string) (*Version, error) {
 	m := versionRegex.FindStringSubmatch(v)
 	if m == nil {
-		return Version{}, ErrInvalidSemVer
+		return nil, ErrInvalidSemVer
 	}
 
-	sv := Version{
+	sv := &Version{
 		metadata: m[8],
 		pre:      m[5],
 		original: v,
@@ -190,13 +191,13 @@ func CoerceNewVersion(v string) (Version, error) {
 	var err error
 	sv.major, err = strconv.ParseUint(m[1], 10, 64)
 	if err != nil {
-		return Version{}, fmt.Errorf("Error parsing version segment: %s", err)
+		return nil, fmt.Errorf("Error parsing version segment: %s", err)
 	}
 
 	if m[2] != "" {
 		sv.minor, err = strconv.ParseUint(strings.TrimPrefix(m[2], "."), 10, 64)
 		if err != nil {
-			return Version{}, fmt.Errorf("Error parsing version segment: %s", err)
+			return nil, fmt.Errorf("Error parsing version segment: %s", err)
 		}
 	} else {
 		sv.minor = 0
@@ -205,7 +206,7 @@ func CoerceNewVersion(v string) (Version, error) {
 	if m[3] != "" {
 		sv.patch, err = strconv.ParseUint(strings.TrimPrefix(m[3], "."), 10, 64)
 		if err != nil {
-			return Version{}, fmt.Errorf("Error parsing version segment: %s", err)
+			return nil, fmt.Errorf("Error parsing version segment: %s", err)
 		}
 	} else {
 		sv.patch = 0
@@ -223,10 +224,10 @@ func CoerceNewVersion(v string) (Version, error) {
 		for _, p := range eparts {
 			if containsOnly(p, num) {
 				if len(p) > 1 && p[0] == '0' {
-					return Version{}, ErrSegmentStartsZero
+					return nil, ErrSegmentStartsZero
 				}
 			} else if !containsOnly(p, allowed) {
-				return Version{}, ErrInvalidCharacters
+				return nil, ErrInvalidCharacters
 			}
 		}
 	}
@@ -239,7 +240,7 @@ func CoerceNewVersion(v string) (Version, error) {
 		eparts := strings.Split(sv.metadata, ".")
 		for _, p := range eparts {
 			if !containsOnly(p, allowed) {
-				return Version{}, ErrInvalidCharacters
+				return nil, ErrInvalidCharacters
 			}
 		}
 	}
@@ -248,7 +249,7 @@ func CoerceNewVersion(v string) (Version, error) {
 }
 
 // MustParse parses a given version and panics on error.
-func MustParse(v string) Version {
+func MustParse(v string) *Version {
 	sv, err := NewVersion(v)
 	if err != nil {
 		panic(err)
@@ -395,19 +396,19 @@ func (v Version) SetMetadata(metadata string) (Version, error) {
 }
 
 // LessThan tests if one version is less than another one.
-func (v *Version) LessThan(o Version) bool {
+func (v *Version) LessThan(o *Version) bool {
 	return v.Compare(o) < 0
 }
 
 // GreaterThan tests if one version is greater than another one.
-func (v *Version) GreaterThan(o Version) bool {
+func (v *Version) GreaterThan(o *Version) bool {
 	return v.Compare(o) > 0
 }
 
 // Equal tests if two versions are equal to each other.
 // Note, versions can be equal with different metadata since metadata
 // is not considered part of the comparable version.
-func (v *Version) Equal(o Version) bool {
+func (v *Version) Equal(o *Version) bool {
 	return v.Compare(o) == 0
 }
 
@@ -416,7 +417,7 @@ func (v *Version) Equal(o Version) bool {
 //
 // Versions are compared by X.Y.Z. Build metadata is ignored. Prerelease is
 // lower than the version without a prerelease.
-func (v *Version) Compare(o Version) int {
+func (v *Version) Compare(o *Version) int {
 	// Compare the major, minor, and patch version for differences. If a
 	// difference is found return the comparison.
 	if d := compareSegment(v.Major(), o.Major()); d != 0 {


Test patch:
diff --git a/benchmark_test.go b/benchmark_test.go
index 6b964b6..c15d095 100644
--- a/benchmark_test.go
+++ b/benchmark_test.go
@@ -194,9 +194,9 @@ func benchNewVersion(v string, b *testing.B) {
 	}
 }
 
-func benchCoerceNewVersion(v string, b *testing.B) {
+func benchStrictNewVersion(v string, b *testing.B) {
 	for i := 0; i < b.N; i++ {
-		_, _ = semver.CoerceNewVersion(v)
+		_, _ = semver.StrictNewVersion(v)
 	}
 }
 
@@ -209,7 +209,7 @@ func BenchmarkNewVersionSimple(b *testing.B) {
 func BenchmarkCoerceNewVersionSimple(b *testing.B) {
 	b.ReportAllocs()
 	b.ResetTimer()
-	benchCoerceNewVersion("1.0.0", b)
+	benchStrictNewVersion("1.0.0", b)
 }
 
 func BenchmarkNewVersionPre(b *testing.B) {
@@ -218,10 +218,10 @@ func BenchmarkNewVersionPre(b *testing.B) {
 	benchNewVersion("1.0.0-alpha", b)
 }
 
-func BenchmarkCoerceNewVersionPre(b *testing.B) {
+func BenchmarkStrictNewVersionPre(b *testing.B) {
 	b.ReportAllocs()
 	b.ResetTimer()
-	benchCoerceNewVersion("1.0.0-alpha", b)
+	benchStrictNewVersion("1.0.0-alpha", b)
 }
 
 func BenchmarkNewVersionMeta(b *testing.B) {
@@ -230,10 +230,10 @@ func BenchmarkNewVersionMeta(b *testing.B) {
 	benchNewVersion("1.0.0+metadata", b)
 }
 
-func BenchmarkCoerceNewVersionMeta(b *testing.B) {
+func BenchmarkStrictNewVersionMeta(b *testing.B) {
 	b.ReportAllocs()
 	b.ResetTimer()
-	benchCoerceNewVersion("1.0.0+metadata", b)
+	benchStrictNewVersion("1.0.0+metadata", b)
 }
 
 func BenchmarkNewVersionMetaDash(b *testing.B) {
@@ -242,8 +242,8 @@ func BenchmarkNewVersionMetaDash(b *testing.B) {
 	benchNewVersion("1.0.0-alpha.1+meta.data", b)
 }
 
-func BenchmarkCoerceNewVersionMetaDash(b *testing.B) {
+func BenchmarkStrictNewVersionMetaDash(b *testing.B) {
 	b.ReportAllocs()
 	b.ResetTimer()
-	benchCoerceNewVersion("1.0.0-alpha.1+meta.data", b)
+	benchStrictNewVersion("1.0.0-alpha.1+meta.data", b)
 }
diff --git a/collection_test.go b/collection_test.go
index 2abc2e1..71b909c 100644
--- a/collection_test.go
+++ b/collection_test.go
@@ -15,9 +15,9 @@ func TestCollection(t *testing.T) {
 		"0.4.2",
 	}
 
-	vs := make([]Version, len(raw))
+	vs := make([]*Version, len(raw))
 	for i, r := range raw {
-		v, err := CoerceNewVersion(r)
+		v, err := NewVersion(r)
 		if err != nil {
 			t.Errorf("Error parsing version: %s", err)
 		}
diff --git a/constraints_test.go b/constraints_test.go
index 75eeeb9..17ee9b7 100644
--- a/constraints_test.go
+++ b/constraints_test.go
@@ -142,7 +142,7 @@ func TestConstraintCheck(t *testing.T) {
 			continue
 		}
 
-		v, err := CoerceNewVersion(tc.version)
+		v, err := NewVersion(tc.version)
 		if err != nil {
 			t.Errorf("err: %s", err)
 			continue
@@ -296,7 +296,7 @@ func TestConstraintsCheck(t *testing.T) {
 			continue
 		}
 
-		v, err := CoerceNewVersion(tc.version)
+		v, err := NewVersion(tc.version)
 		if err != nil {
 			t.Errorf("err: %s", err)
 			continue
@@ -432,7 +432,7 @@ func TestConstraintsValidate(t *testing.T) {
 			continue
 		}
 
-		v, err := CoerceNewVersion(tc.version)
+		v, err := NewVersion(tc.version)
 		if err != nil {
 			t.Errorf("err: %s", err)
 			continue
@@ -452,7 +452,7 @@ func TestConstraintsValidate(t *testing.T) {
 		// }
 	}
 
-	v, err := NewVersion("1.2.3")
+	v, err := StrictNewVersion("1.2.3")
 	if err != nil {
 		t.Errorf("err: %s", err)
 	}
@@ -517,7 +517,7 @@ func TestConstraintsValidate(t *testing.T) {
 			continue
 		}
 
-		v, err := NewVersion(tc.version)
+		v, err := StrictNewVersion(tc.version)
 		if err != nil {
 			t.Errorf("err: %s", err)
 			continue
diff --git a/version_test.go b/version_test.go
index b44e305..3ea0e5f 100644
--- a/version_test.go
+++ b/version_test.go
@@ -6,7 +6,7 @@ import (
 	"testing"
 )
 
-func TestNewVersion(t *testing.T) {
+func TestStrictNewVersion(t *testing.T) {
 	tests := []struct {
 		version string
 		err     bool
@@ -43,7 +43,7 @@ func TestNewVersion(t *testing.T) {
 	}
 
 	for _, tc := range tests {
-		_, err := NewVersion(tc.version)
+		_, err := StrictNewVersion(tc.version)
 		if tc.err && err == nil {
 			t.Fatalf("expected error for version: %s", tc.version)
 		} else if !tc.err && err != nil {
@@ -52,7 +52,7 @@ func TestNewVersion(t *testing.T) {
 	}
 }
 
-func TestCoerceNewVersion(t *testing.T) {
+func TestNewVersion(t *testing.T) {
 	tests := []struct {
 		version string
 		err     bool
@@ -89,7 +89,7 @@ func TestCoerceNewVersion(t *testing.T) {
 	}
 
 	for _, tc := range tests {
-		_, err := CoerceNewVersion(tc.version)
+		_, err := NewVersion(tc.version)
 		if tc.err && err == nil {
 			t.Fatalf("expected error for version: %s", tc.version)
 		} else if !tc.err && err != nil {
@@ -119,7 +119,7 @@ func TestOriginal(t *testing.T) {
 	}
 
 	for _, tc := range tests {
-		v, err := CoerceNewVersion(tc)
+		v, err := NewVersion(tc)
 		if err != nil {
 			t.Errorf("Error parsing version %s", tc)
 		}
@@ -132,7 +132,7 @@ func TestOriginal(t *testing.T) {
 }
 
 func TestParts(t *testing.T) {
-	v, err := CoerceNewVersion("1.2.3-beta.1+build.123")
+	v, err := NewVersion("1.2.3-beta.1+build.123")
 	if err != nil {
 		t.Error("Error parsing version 1.2.3-beta.1+build.123")
 	}
@@ -178,7 +178,7 @@ func TestCoerceString(t *testing.T) {
 	}
 
 	for _, tc := range tests {
-		v, err := CoerceNewVersion(tc.version)
+		v, err := NewVersion(tc.version)
 		if err != nil {
 			t.Errorf("Error parsing version %s", tc)
 		}
@@ -218,12 +218,12 @@ func TestCompare(t *testing.T) {
 	}
 
 	for _, tc := range tests {
-		v1, err := CoerceNewVersion(tc.v1)
+		v1, err := NewVersion(tc.v1)
 		if err != nil {
 			t.Errorf("Error parsing version: %s", err)
 		}
 
-		v2, err := CoerceNewVersion(tc.v2)
+		v2, err := NewVersion(tc.v2)
 		if err != nil {
 			t.Errorf("Error parsing version: %s", err)
 		}
@@ -251,12 +251,12 @@ func TestLessThan(t *testing.T) {
 	}
 
 	for _, tc := range tests {
-		v1, err := CoerceNewVersion(tc.v1)
+		v1, err := NewVersion(tc.v1)
 		if err != nil {
 			t.Errorf("Error parsing version: %s", err)
 		}
 
-		v2, err := CoerceNewVersion(tc.v2)
+		v2, err := NewVersion(tc.v2)
 		if err != nil {
 			t.Errorf("Error parsing version: %s", err)
 		}
@@ -289,12 +289,12 @@ func TestGreaterThan(t *testing.T) {
 	}
 
 	for _, tc := range tests {
-		v1, err := CoerceNewVersion(tc.v1)
+		v1, err := NewVersion(tc.v1)
 		if err != nil {
 			t.Errorf("Error parsing version: %s", err)
 		}
 
-		v2, err := CoerceNewVersion(tc.v2)
+		v2, err := NewVersion(tc.v2)
 		if err != nil {
 			t.Errorf("Error parsing version: %s", err)
 		}
@@ -323,12 +323,12 @@ func TestEqual(t *testing.T) {
 	}
 
 	for _, tc := range tests {
-		v1, err := CoerceNewVersion(tc.v1)
+		v1, err := NewVersion(tc.v1)
 		if err != nil {
 			t.Errorf("Error parsing version: %s", err)
 		}
 
-		v2, err := CoerceNewVersion(tc.v2)
+		v2, err := NewVersion(tc.v2)
 		if err != nil {
 			t.Errorf("Error parsing version: %s", err)
 		}
@@ -367,7 +367,7 @@ func TestInc(t *testing.T) {
 	}
 
 	for _, tc := range tests {
-		v1, err := CoerceNewVersion(tc.v1)
+		v1, err := NewVersion(tc.v1)
 		if err != nil {
 			t.Errorf("Error parsing version: %s", err)
 		}
@@ -416,7 +416,7 @@ func TestSetPrerelease(t *testing.T) {
 	}
 
 	for _, tc := range tests {
-		v1, err := CoerceNewVersion(tc.v1)
+		v1, err := NewVersion(tc.v1)
 		if err != nil {
 			t.Errorf("Error parsing version: %s", err)
 		}
@@ -461,7 +461,7 @@ func TestSetMetadata(t *testing.T) {
 	}
 
 	for _, tc := range tests {
-		v1, err := CoerceNewVersion(tc.v1)
+		v1, err := NewVersion(tc.v1)
 		if err != nil {
 			t.Errorf("Error parsing version: %s", err)
 		}
@@ -501,7 +501,7 @@ func TestOriginalVPrefix(t *testing.T) {
 	}
 
 	for _, tc := range tests {
-		v1, _ := CoerceNewVersion(tc.version)
+		v1, _ := NewVersion(tc.version)
 		a := v1.originalVPrefix()
 		e := tc.vprefix
 		if a != e {
@@ -512,7 +512,7 @@ func TestOriginalVPrefix(t *testing.T) {
 
 func TestJsonMarshal(t *testing.T) {
 	sVer := "1.1.1"
-	x, err := NewVersion(sVer)
+	x, err := StrictNewVersion(sVer)
 	if err != nil {
 		t.Errorf("Error creating version: %s", err)
 	}