Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
gostnops
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wei.xuan
gostnops
Commits
406517db
Commit
406517db
authored
Jan 01, 2020
by
Ming Deng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Review
parent
ec07452d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
10 deletions
+10
-10
sort.go
gxsort/sort.go
+1
-1
sort_test.go
gxsort/sort_test.go
+1
-1
compare.go
math/compare.go
+2
-2
compare_test.go
math/compare_test.go
+6
-6
No files found.
math
/sort.go
→
gxsort
/sort.go
View file @
406517db
...
...
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package
math
package
gxsort
import
(
"sort"
...
...
math
/sort_test.go
→
gxsort
/sort_test.go
View file @
406517db
...
...
@@ -15,7 +15,7 @@
* limitations under the License.
*/
package
math
package
gxsort
import
(
"testing"
...
...
math/compare.go
View file @
406517db
...
...
@@ -18,14 +18,14 @@
package
math
// equivalent to math.Abs(expected - actual) <= delta
func
CompareFloat64
(
expected
float64
,
actual
float64
,
delta
float64
)
bool
{
func
Delta
CompareFloat64
(
expected
float64
,
actual
float64
,
delta
float64
)
bool
{
if
expected
>
actual
{
return
expected
-
actual
<=
delta
}
return
actual
-
expected
<=
delta
}
func
CompareFloat32
(
expected
float32
,
actual
float32
,
delta
float32
)
bool
{
func
Delta
CompareFloat32
(
expected
float32
,
actual
float32
,
delta
float32
)
bool
{
if
expected
>
actual
{
return
expected
-
actual
<=
delta
}
...
...
math/compare_test.go
View file @
406517db
...
...
@@ -26,13 +26,13 @@ import (
)
func
TestFloat64
(
t
*
testing
.
T
)
{
assert
.
True
(
t
,
CompareFloat64
(
12.3334
,
12.3344
,
0.01
))
assert
.
True
(
t
,
CompareFloat64
(
12.3334
,
12.32981
,
0.01
))
assert
.
False
(
t
,
CompareFloat64
(
12.3334
,
12.0325
,
0.01
))
assert
.
True
(
t
,
Delta
CompareFloat64
(
12.3334
,
12.3344
,
0.01
))
assert
.
True
(
t
,
Delta
CompareFloat64
(
12.3334
,
12.32981
,
0.01
))
assert
.
False
(
t
,
Delta
CompareFloat64
(
12.3334
,
12.0325
,
0.01
))
}
func
TestCompareFloat32
(
t
*
testing
.
T
)
{
assert
.
True
(
t
,
CompareFloat32
(
12.3334
,
12.3344
,
0.01
))
assert
.
True
(
t
,
CompareFloat32
(
12.3334
,
12.32981
,
0.01
))
assert
.
False
(
t
,
CompareFloat64
(
12.3334
,
12.0325
,
0.01
))
assert
.
True
(
t
,
Delta
CompareFloat32
(
12.3334
,
12.3344
,
0.01
))
assert
.
True
(
t
,
Delta
CompareFloat32
(
12.3334
,
12.32981
,
0.01
))
assert
.
False
(
t
,
Delta
CompareFloat64
(
12.3334
,
12.0325
,
0.01
))
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment