New Upstream Release - golang-github-viant-assertly

Ready changes

Summary

Merged new upstream version: 0.9.0 (was: 0.5.4).

Resulting package

Built on 2023-01-16T17:08 (took 4m0s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-releases golang-github-viant-assertly-dev

Lintian Result

Diff

diff --git a/CHANGELOG.md b/CHANGELOG.md
index d3f212b..bb52608 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,6 @@
+## Jan 18 2020 - v0.6.0
+    * patched float assertion
+
 ## Jan 18 2020 - v0.5.2
     * modify @length directive to support arbitrary path
     
diff --git a/debian/changelog b/debian/changelog
index 2573444..6014024 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,6 @@
-golang-github-viant-assertly (0.5.4-2) UNRELEASED; urgency=medium
+golang-github-viant-assertly (0.9.0-1) UNRELEASED; urgency=medium
 
+  [ Aloïs Micard ]
   * debian/control:
     - Bump debhelper-compat to 13.
     - Update my uploader name.
@@ -7,7 +8,10 @@ golang-github-viant-assertly (0.5.4-2) UNRELEASED; urgency=medium
     - Fix typo.
     - Bump Standards-Version.
 
- -- Aloïs Micard <alois@micard.lu>  Wed, 22 Jul 2020 19:30:06 +0000
+  [ Debian Janitor ]
+  * New upstream release.
+
+ -- Aloïs Micard <alois@micard.lu>  Mon, 16 Jan 2023 17:04:41 -0000
 
 golang-github-viant-assertly (0.5.4-1) unstable; urgency=medium
 
diff --git a/directive.go b/directive.go
index 94754a2..5d4cd5a 100644
--- a/directive.go
+++ b/directive.go
@@ -44,7 +44,7 @@ type Directive struct {
 	Lengths               map[string]int
 	SwitchBy              []string
 	CoalesceWithZero      bool
-	NumericPrecisionPoint int
+	NumericPrecisionPoint *int
 	IndexBy               []string
 	Source                string
 	SortText              bool
@@ -68,7 +68,7 @@ func (d *Directive) mergeFrom(source *Directive) {
 		d.IndexBy = source.IndexBy
 	}
 
-	if d.NumericPrecisionPoint == 0 {
+	if d.NumericPrecisionPoint != nil {
 		d.NumericPrecisionPoint = source.NumericPrecisionPoint
 	}
 	if d.TimeLayout == "" {
@@ -162,8 +162,8 @@ func (d *Directive) Add(target map[string]interface{}) {
 		target[IndexByDirective] = d.IndexBy
 	}
 
-	if d.NumericPrecisionPoint > 0 {
-		target[NumericPrecisionPointDirective] = d.NumericPrecisionPoint
+	if d.NumericPrecisionPoint  != nil  && *d.NumericPrecisionPoint  > 0 {
+		target[NumericPrecisionPointDirective] = *d.NumericPrecisionPoint
 	}
 
 	if d.CoalesceWithZero {
@@ -238,7 +238,8 @@ func (d *Directive) ExtractDirectives(aMap map[string]interface{}) bool {
 		}
 
 		if k == NumericPrecisionPointDirective {
-			d.NumericPrecisionPoint = toolbox.AsInt(v)
+			val :=  toolbox.AsInt(v)
+			d.NumericPrecisionPoint = &val
 			continue
 		}
 
@@ -337,8 +338,8 @@ func (d *Directive) Apply(aMap map[string]interface{}) error {
 	if err := d.applyTimeFormat(aMap); err != nil {
 		return err
 	}
-	if d.NumericPrecisionPoint != 0 {
-		aMap[NumericPrecisionPointDirective] = d.NumericPrecisionPoint
+	if d.NumericPrecisionPoint != nil {
+		aMap[NumericPrecisionPointDirective] = *d.NumericPrecisionPoint
 	}
 	if d.CoalesceWithZero {
 		aMap[CoalesceWithZeroDirective] = d.CoalesceWithZero
@@ -450,6 +451,7 @@ func NewDirective(path DataPath) *Directive {
 		KeyCaseSensitive: true,
 		CaseSensitive:    true,
 		AssertPaths:      make([]*AssertPath, 0),
+
 	}
 	if dataPath != nil {
 		dataPath.directive = result
@@ -470,7 +472,7 @@ func NewDirective(path DataPath) *Directive {
 	path.Each(func(path DataPath) bool {
 		directive := path.Directive()
 		if directive != nil {
-			if directive.NumericPrecisionPoint != 0 {
+			if directive.NumericPrecisionPoint != nil {
 				result.NumericPrecisionPoint = directive.NumericPrecisionPoint
 				return false
 			}
diff --git a/validator.go b/validator.go
index ae2a060..1896990 100644
--- a/validator.go
+++ b/validator.go
@@ -408,6 +408,16 @@ func assertFloat(expected, actual interface{}, path DataPath, context *Context,
 		expectedFloat = 0
 		expected = 0
 	}
+
+
+
+	if actualFloat, ok := actual.(float64); ok && directive.NumericPrecisionPoint  == nil  {
+		if isEqual := expectedErr == nil &&  expectedFloat == actualFloat; !isEqual {
+			validation.AddFailure(NewFailure(path.Source(), path.Path(), EqualViolation, expected, actual))
+			return
+		}
+	}
+
 	actualFloat, actualErr := toolbox.ToFloat(actual)
 
 	if toolbox.IsNilPointerError(actualErr) {
@@ -417,8 +427,9 @@ func assertFloat(expected, actual interface{}, path DataPath, context *Context,
 			actual = 0
 		}
 	}
-	if directive != nil {
-		precisionPoint := float64(directive.NumericPrecisionPoint)
+
+	if directive != nil && directive.NumericPrecisionPoint != nil {
+		precisionPoint := float64(*directive.NumericPrecisionPoint)
 		if expectedErr == nil && actualErr == nil && precisionPoint >= 0 {
 			unit := 1 / math.Pow(10, precisionPoint)
 			expectedFloat = math.Round(expectedFloat/unit) * unit
@@ -426,6 +437,7 @@ func assertFloat(expected, actual interface{}, path DataPath, context *Context,
 		}
 	}
 
+
 	isEqual := expectedErr == nil && actualErr == nil && expectedFloat == actualFloat
 	if !isEqual {
 		if text, ok := expected.(string); ok {
diff --git a/validator_test.go b/validator_test.go
index e288a71..8b60cd2 100644
--- a/validator_test.go
+++ b/validator_test.go
@@ -1302,6 +1302,13 @@ func TestAssertNumericPrecission(t *testing.T) {
 			PassedCount: 1,
 			FailedCount: 0,
 		},
+		{
+			Description: "float assert",
+			Expected: 1.0,
+			Actual: 1.1,
+			PassedCount: 0,
+			FailedCount: 1,
+		},
 	}
 
 	context := assertly.NewDefaultContext()

Debdiff

File lists identical (after any substitutions)

No differences were encountered in the control files

More details

Full run details