int_test.go 518 B

12345678910111213141516171819202122
  1. package buildin
  2. import "testing"
  3. func TestRangeInt(t *testing.T) {
  4. // Test case 1: min equals max
  5. min1 := uint(5)
  6. max1 := uint(5)
  7. expected1 := 5
  8. result1 := RangeInt(min1, max1)
  9. if result1 != expected1 {
  10. t.Errorf("Test case 1 failed. Expected %v, got %v", expected1, result1)
  11. }
  12. // Test case 2: min is less than max
  13. min2 := uint(1)
  14. max2 := uint(10)
  15. result2 := RangeInt(min2, max2)
  16. if result2 < int(min2) || result2 > int(max2) {
  17. t.Errorf("Test case 2 failed. Result %v is out of range", result2)
  18. }
  19. }