Commit 406517db authored by Ming Deng's avatar Ming Deng

Fix Review

parent ec07452d
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package math package gxsort
import ( import (
"sort" "sort"
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package math package gxsort
import ( import (
"testing" "testing"
......
...@@ -18,14 +18,14 @@ ...@@ -18,14 +18,14 @@
package math package math
// equivalent to math.Abs(expected - actual) <= delta // equivalent to math.Abs(expected - actual) <= delta
func CompareFloat64(expected float64, actual float64, delta float64) bool { func DeltaCompareFloat64(expected float64, actual float64, delta float64) bool {
if expected > actual { if expected > actual {
return expected-actual <= delta return expected-actual <= delta
} }
return actual-expected <= delta return actual-expected <= delta
} }
func CompareFloat32(expected float32, actual float32, delta float32) bool { func DeltaCompareFloat32(expected float32, actual float32, delta float32) bool {
if expected > actual { if expected > actual {
return expected-actual <= delta return expected-actual <= delta
} }
......
...@@ -26,13 +26,13 @@ import ( ...@@ -26,13 +26,13 @@ import (
) )
func TestFloat64(t *testing.T) { func TestFloat64(t *testing.T) {
assert.True(t, CompareFloat64(12.3334, 12.3344, 0.01)) assert.True(t, DeltaCompareFloat64(12.3334, 12.3344, 0.01))
assert.True(t, CompareFloat64(12.3334, 12.32981, 0.01)) assert.True(t, DeltaCompareFloat64(12.3334, 12.32981, 0.01))
assert.False(t, CompareFloat64(12.3334, 12.0325, 0.01)) assert.False(t, DeltaCompareFloat64(12.3334, 12.0325, 0.01))
} }
func TestCompareFloat32(t *testing.T) { func TestCompareFloat32(t *testing.T) {
assert.True(t, CompareFloat32(12.3334, 12.3344, 0.01)) assert.True(t, DeltaCompareFloat32(12.3334, 12.3344, 0.01))
assert.True(t, CompareFloat32(12.3334, 12.32981, 0.01)) assert.True(t, DeltaCompareFloat32(12.3334, 12.32981, 0.01))
assert.False(t, CompareFloat64(12.3334, 12.0325, 0.01)) assert.False(t, DeltaCompareFloat64(12.3334, 12.0325, 0.01))
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment