Skip to content

Commit

Permalink
Fix several test output messages: Fatal to Fatalf. Added comments to …
Browse files Browse the repository at this point in the history
…asc and desc package exported methods
  • Loading branch information
umpc committed Jul 4, 2017
1 parent c636819 commit 7d63621
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 41 deletions.
12 changes: 12 additions & 0 deletions asc/numeric.go
Original file line number Diff line number Diff line change
@@ -1,49 +1,61 @@
package asc

// Uint8 is a less than comparison function for the Uint8 numeric type.
func Uint8(i, j interface{}) bool {
return i.(uint8) < j.(uint8)
}

// Uint16 is a less than comparison function for the Uint16 numeric type.
func Uint16(i, j interface{}) bool {
return i.(uint16) < j.(uint16)
}

// Uint32 is a less than comparison function for the Uint32 numeric type.
func Uint32(i, j interface{}) bool {
return i.(uint32) < j.(uint32)
}

// Uint64 is a less than comparison function for the Uint64 numeric type.
func Uint64(i, j interface{}) bool {
return i.(uint64) < j.(uint64)
}

// Int8 is a less than comparison function for the Int8 numeric type.
func Int8(i, j interface{}) bool {
return i.(int8) < j.(int8)
}

// Int16 is a less than comparison function for the Int16 numeric type.
func Int16(i, j interface{}) bool {
return i.(int16) < j.(int16)
}

// Int32 is a less than comparison function for the Int32 numeric type.
func Int32(i, j interface{}) bool {
return i.(int32) < j.(int32)
}

// Int64 is a less than comparison function for the Int64 numeric type.
func Int64(i, j interface{}) bool {
return i.(int64) < j.(int64)
}

// Float32 is a less than comparison function for the Float32 numeric type.
func Float32(i, j interface{}) bool {
return i.(float32) < j.(float32)
}

// Float64 is a less than comparison function for the Float64 numeric type.
func Float64(i, j interface{}) bool {
return i.(float64) < j.(float64)
}

// Uint is a less than comparison function for the Uint numeric type.
func Uint(i, j interface{}) bool {
return i.(uint) < j.(uint)
}

// Int is a less than comparison function for the Int numeric type.
func Int(i, j interface{}) bool {
return i.(int) < j.(int)
}
24 changes: 12 additions & 12 deletions asc/numeric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,72 +4,72 @@ import "testing"

func TestUint8(t *testing.T) {
if Uint8(uint8(1), uint8(0)) {
t.Fatal("asc.TestUint8 failed: %v", greaterThanErr)
t.Fatalf("asc.TestUint8 failed: %v\n", greaterThanErr)
}
}

func TestUint16(t *testing.T) {
if Uint16(uint16(1), uint16(0)) {
t.Fatal("asc.TestUint16 failed: %v", greaterThanErr)
t.Fatalf("asc.TestUint16 failed: %v\n", greaterThanErr)
}
}

func TestUint32(t *testing.T) {
if Uint32(uint32(1), uint32(0)) {
t.Fatal("asc.TestUint32 failed: %v", greaterThanErr)
t.Fatalf("asc.TestUint32 failed: %v\n", greaterThanErr)
}
}

func TestUint64(t *testing.T) {
if Uint64(uint64(1), uint64(0)) {
t.Fatal("asc.TestUint64 failed: %v", greaterThanErr)
t.Fatalf("asc.TestUint64 failed: %v\n", greaterThanErr)
}
}

func TestInt8(t *testing.T) {
if Int8(int8(1), int8(0)) {
t.Fatal("asc.TestInt8 failed: %v", greaterThanErr)
t.Fatalf("asc.TestInt8 failed: %v\n", greaterThanErr)
}
}

func TestInt16(t *testing.T) {
if Int16(int16(1), int16(0)) {
t.Fatal("asc.TestInt16 failed: %v", greaterThanErr)
t.Fatalf("asc.TestInt16 failed: %v\n", greaterThanErr)
}
}

func TestInt32(t *testing.T) {
if Int32(int32(1), int32(0)) {
t.Fatal("asc.TestInt32 failed: %v", greaterThanErr)
t.Fatalf("asc.TestInt32 failed: %v\n", greaterThanErr)
}
}

func TestInt64(t *testing.T) {
if Int64(int64(1), int64(0)) {
t.Fatal("asc.TestInt64 failed: %v", greaterThanErr)
t.Fatalf("asc.TestInt64 failed: %v\n", greaterThanErr)
}
}

func TestFloat32(t *testing.T) {
if Float32(float32(1), float32(0)) {
t.Fatal("asc.TestFloat32 failed: %v", greaterThanErr)
t.Fatalf("asc.TestFloat32 failed: %v\n", greaterThanErr)
}
}

func TestFloat64(t *testing.T) {
if Float64(float64(1), float64(0)) {
t.Fatal("asc.TestFloat64 failed: %v", greaterThanErr)
t.Fatalf("asc.TestFloat64 failed: %v\n", greaterThanErr)
}
}

func TestUint(t *testing.T) {
if Uint(uint(1), uint(0)) {
t.Fatal("asc.TestUint failed: %v", greaterThanErr)
t.Fatalf("asc.TestUint failed: %v\n", greaterThanErr)
}
}

func TestInt(t *testing.T) {
if Int(int(1), 0) {
t.Fatal("asc.TestInt failed: %v", greaterThanErr)
t.Fatalf("asc.TestInt failed: %v\n", greaterThanErr)
}
}
1 change: 1 addition & 0 deletions asc/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package asc

import "time"

// Time is a less than comparison function for the time.Time type.
func Time(i, j interface{}) bool {
return i.(time.Time).Before(j.(time.Time))
}
12 changes: 12 additions & 0 deletions desc/numeric.go
Original file line number Diff line number Diff line change
@@ -1,49 +1,61 @@
package desc

// Uint8 is a greater than comparison function for the Uint8 numeric type.
func Uint8(i, j interface{}) bool {
return i.(uint8) > j.(uint8)
}

// Uint16 is a greater than comparison function for the Uint16 numeric type.
func Uint16(i, j interface{}) bool {
return i.(uint16) > j.(uint16)
}

// Uint32 is a greater than comparison function for the Uint32 numeric type.
func Uint32(i, j interface{}) bool {
return i.(uint32) > j.(uint32)
}

// Uint64 is a greater than comparison function for the Uint64 numeric type.
func Uint64(i, j interface{}) bool {
return i.(uint64) > j.(uint64)
}

// Int8 is a greater than comparison function for the Int8 numeric type.
func Int8(i, j interface{}) bool {
return i.(int8) > j.(int8)
}

// Int16 is a greater than comparison function for the Int16 numeric type.
func Int16(i, j interface{}) bool {
return i.(int16) > j.(int16)
}

// Int32 is a greater than comparison function for the Int32 numeric type.
func Int32(i, j interface{}) bool {
return i.(int32) > j.(int32)
}

// Int64 is a greater than comparison function for the Int64 numeric type.
func Int64(i, j interface{}) bool {
return i.(int64) > j.(int64)
}

// Float32 is a greater than comparison function for the Float32 numeric type.
func Float32(i, j interface{}) bool {
return i.(float32) > j.(float32)
}

// Float64 is a greater than comparison function for the Float64 numeric type.
func Float64(i, j interface{}) bool {
return i.(float64) > j.(float64)
}

// Uint is a greater than comparison function for the Uint numeric type.
func Uint(i, j interface{}) bool {
return i.(uint) > j.(uint)
}

// Int is a greater than comparison function for the Int numeric type.
func Int(i, j interface{}) bool {
return i.(int) > j.(int)
}
24 changes: 12 additions & 12 deletions desc/numeric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,72 +4,72 @@ import "testing"

func TestUint8(t *testing.T) {
if Uint8(uint8(0), uint8(1)) {
t.Fatal("desc.TestUint8 failed: %v", greaterThanErr)
t.Fatalf("desc.TestUint8 failed: %v\n", greaterThanErr)
}
}

func TestUint16(t *testing.T) {
if Uint16(uint16(0), uint16(1)) {
t.Fatal("desc.TestUint16 failed: %v", greaterThanErr)
t.Fatalf("desc.TestUint16 failed: %v\n", greaterThanErr)
}
}

func TestUint32(t *testing.T) {
if Uint32(uint32(0), uint32(1)) {
t.Fatal("desc.TestUint32 failed: %v", greaterThanErr)
t.Fatalf("desc.TestUint32 failed: %v\n", greaterThanErr)
}
}

func TestUint64(t *testing.T) {
if Uint64(uint64(0), uint64(1)) {
t.Fatal("desc.TestUint64 failed: %v", greaterThanErr)
t.Fatalf("desc.TestUint64 failed: %v\n", greaterThanErr)
}
}

func TestInt8(t *testing.T) {
if Int8(int8(0), int8(1)) {
t.Fatal("desc.TestInt8 failed: %v", greaterThanErr)
t.Fatalf("desc.TestInt8 failed: %v\n", greaterThanErr)
}
}

func TestInt16(t *testing.T) {
if Int16(int16(0), int16(1)) {
t.Fatal("desc.TestInt16 failed: %v", greaterThanErr)
t.Fatalf("desc.TestInt16 failed: %v\n", greaterThanErr)
}
}

func TestInt32(t *testing.T) {
if Int32(int32(0), int32(1)) {
t.Fatal("desc.TestInt32 failed: %v", greaterThanErr)
t.Fatalf("desc.TestInt32 failed: %v\n", greaterThanErr)
}
}

func TestInt64(t *testing.T) {
if Int64(int64(0), int64(1)) {
t.Fatal("desc.TestInt64 failed: %v", greaterThanErr)
t.Fatalf("desc.TestInt64 failed: %v\n", greaterThanErr)
}
}

func TestFloat32(t *testing.T) {
if Float32(float32(0), float32(1)) {
t.Fatal("desc.TestFloat32 failed: %v", greaterThanErr)
t.Fatalf("desc.TestFloat32 failed: %v\n", greaterThanErr)
}
}

func TestFloat64(t *testing.T) {
if Float64(float64(0), float64(1)) {
t.Fatal("desc.TestFloat64 failed: %v", greaterThanErr)
t.Fatalf("desc.TestFloat64 failed: %v\n", greaterThanErr)
}
}

func TestUint(t *testing.T) {
if Uint(uint(0), uint(1)) {
t.Fatal("desc.TestUint failed: %v", greaterThanErr)
t.Fatalf("desc.TestUint failed: %v\n", greaterThanErr)
}
}

func TestInt(t *testing.T) {
if Int(int(0), 0) {
t.Fatal("desc.TestInt failed: %v", greaterThanErr)
t.Fatalf("desc.TestInt failed: %v\n", greaterThanErr)
}
}
1 change: 1 addition & 0 deletions desc/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package desc

import "time"

// Time is a greater than comparison function for the time.Time type.
func Time(i, j interface{}) bool {
return i.(time.Time).After(j.(time.Time))
}
Loading

0 comments on commit 7d63621

Please sign in to comment.