Skip to content

Commit 8959c7c

Browse files
committed
chore: rename isComparable to isOrderable.
1 parent b5f69b0 commit 8959c7c

File tree

5 files changed

+31
-27
lines changed

5 files changed

+31
-27
lines changed

.DS_Store

6 KB
Binary file not shown.

compare.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -454,17 +454,3 @@ func isTrue(v any) bool {
454454
return !rv.IsZero()
455455
}
456456
}
457-
458-
// isComparable gets the type of the value, and checks whether the type is comparable or not.
459-
func isComparable(v any) bool {
460-
switch v.(type) {
461-
case
462-
int, int8, int16, int32, int64, // Signed integer
463-
uint, uint8, uint16, uint32, uint64, uintptr, // Unsigned integer
464-
float32, float64, // Floating-point number
465-
string: // string
466-
return true
467-
default:
468-
return false
469-
}
470-
}

compare_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -327,16 +327,3 @@ func TestIsTrue(t *testing.T) {
327327
assert.NotTrue(isTrue(""))
328328
assert.True(isTrue(func() {}))
329329
}
330-
331-
func TestIsComparable(t *testing.T) {
332-
assert := New(t)
333-
334-
assert.Equal(isComparable(1), true)
335-
assert.Equal(isComparable(int64(1)), true)
336-
assert.Equal(isComparable(uint64(1)), true)
337-
assert.Equal(isComparable(float32(1.0)), true)
338-
assert.Equal(isComparable(1.0), true)
339-
assert.Equal(isComparable("Hello"), true)
340-
assert.Equal(isComparable([]byte{'H', 'e', 'l', 'l', 'o'}), false)
341-
assert.Equal(isComparable([]int{1, 2, 3}), false)
342-
}

order.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package assert
2+
3+
// isOrderable gets the type of the value, and checks whether the type is comparable or not.
4+
func isOrderable(v any) bool {
5+
switch v.(type) {
6+
case
7+
int, int8, int16, int32, int64, // Signed integer
8+
uint, uint8, uint16, uint32, uint64, uintptr, // Unsigned integer
9+
float32, float64, // Floating-point number
10+
string: // string
11+
return true
12+
default:
13+
return false
14+
}
15+
}

order_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package assert
2+
3+
import "testing"
4+
5+
func TestIsOrderable(t *testing.T) {
6+
assert := New(t)
7+
8+
assert.Equal(isOrderable(1), true)
9+
assert.Equal(isOrderable(int64(1)), true)
10+
assert.Equal(isOrderable(uint64(1)), true)
11+
assert.Equal(isOrderable(float32(1.0)), true)
12+
assert.Equal(isOrderable(1.0), true)
13+
assert.Equal(isOrderable("Hello"), true)
14+
assert.Equal(isOrderable([]byte{'H', 'e', 'l', 'l', 'o'}), false)
15+
assert.Equal(isOrderable([]int{1, 2, 3}), false)
16+
}

0 commit comments

Comments
 (0)