21 lines
421 B
Go
21 lines
421 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
"math"
|
|
)
|
|
|
|
func TestReverse(t *testing.T) {
|
|
if res := reverse(123); res != 321 {
|
|
t.Fatalf("%v != 321", res)
|
|
}
|
|
if res := reverse(-123); res != -321 {
|
|
t.Fatalf("%v != -321", res)
|
|
}
|
|
if res := reverse(120); res != 21 {
|
|
t.Fatalf("%v != 12", res)
|
|
}
|
|
if res := reverse(math.MaxInt32); res != 0 {
|
|
t.Fatalf("%v != 0", res)
|
|
}
|
|
}
|