github.com/searKing/golang/go@v1.2.117/exp/math/limits_test.go (about)

     1  // Copyright 2023 The searKing Author. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package math_test
     6  
     7  import (
     8  	"math"
     9  	"testing"
    10  
    11  	math_ "github.com/searKing/golang/go/exp/math"
    12  )
    13  
    14  func TestMaxInt(t *testing.T) {
    15  	{
    16  		got := math_.MaxInt[int]()
    17  		want := math.MaxInt
    18  		if got != want {
    19  			t.Errorf("math_.MaxInt[%T] = %v, want %v", got, got, want)
    20  		}
    21  	}
    22  	{
    23  		got := math_.MaxInt[int8]()
    24  		want := int8(math.MaxInt8)
    25  		if got != want {
    26  			t.Errorf("math_.MaxInt8[%T] = %v, want %v", got, got, want)
    27  		}
    28  	}
    29  	{
    30  		got := math_.MaxInt[int16]()
    31  		want := int16(math.MaxInt16)
    32  		if got != want {
    33  			t.Errorf("math_.MaxInt[%T] = %v, want %v", got, got, want)
    34  		}
    35  	}
    36  	{
    37  		got := math_.MaxInt[int32]()
    38  		want := int32(math.MaxInt32)
    39  		if got != want {
    40  			t.Errorf("math_.MaxInt[%T] = %v, want %v", got, got, want)
    41  		}
    42  	}
    43  	{
    44  		got := math_.MaxInt[int64]()
    45  		want := int64(math.MaxInt64)
    46  		if got != want {
    47  			t.Errorf("math_.MaxInt[%T] = %v, want %v", got, got, want)
    48  		}
    49  	}
    50  
    51  	{
    52  		got := math_.MaxInt[uint]()
    53  		want := uint(math.MaxUint)
    54  		if got != want {
    55  			t.Errorf("math_.MaxInt[%T] = %v, want %v", got, got, want)
    56  		}
    57  	}
    58  	{
    59  		got := math_.MaxInt[uint8]()
    60  		want := uint8(math.MaxUint8)
    61  		if got != want {
    62  			t.Errorf("math_.MaxInt[%T] = %v, want %v", got, got, want)
    63  		}
    64  	}
    65  	{
    66  		got := math_.MaxInt[uint16]()
    67  		want := uint16(math.MaxUint16)
    68  		if got != want {
    69  			t.Errorf("math_.MaxInt[%T] = %v, want %v", got, got, want)
    70  		}
    71  	}
    72  	{
    73  		got := math_.MaxInt[uint32]()
    74  		want := uint32(math.MaxUint32)
    75  		if got != want {
    76  			t.Errorf("math_.MaxInt[%T] = %v, want %v", got, got, want)
    77  		}
    78  	}
    79  	{
    80  		got := math_.MaxInt[uint64]()
    81  		want := uint64(math.MaxUint64)
    82  		if got != want {
    83  			t.Errorf("math_.MaxInt[%T] = %v, want %v", got, got, want)
    84  		}
    85  	}
    86  }
    87  
    88  func TestMinInt(t *testing.T) {
    89  	{
    90  		got := math_.MinInt[int]()
    91  		want := math.MinInt
    92  		if got != math.MinInt {
    93  			t.Errorf("math_.MinInt[%T] = %v, want %v", got, got, want)
    94  		}
    95  	}
    96  	{
    97  		got := math_.MinInt[int8]()
    98  		want := int8(math.MinInt8)
    99  		if got != want {
   100  			t.Errorf("math_.MinInt8[%T] = %v, want %v", got, got, want)
   101  		}
   102  	}
   103  	{
   104  		got := math_.MinInt[int16]()
   105  		want := int16(math.MinInt16)
   106  		if got != want {
   107  			t.Errorf("math_.MinInt[%T] = %v, want %v", got, got, want)
   108  		}
   109  	}
   110  	{
   111  		got := math_.MinInt[int32]()
   112  		want := int32(math.MinInt32)
   113  		if got != want {
   114  			t.Errorf("math_.MinInt[%T] = %v, want %v", got, got, want)
   115  		}
   116  	}
   117  	{
   118  		got := math_.MinInt[int64]()
   119  		want := int64(math.MinInt64)
   120  		if got != want {
   121  			t.Errorf("math_.MinInt[%T] = %v, want %v", got, got, want)
   122  		}
   123  	}
   124  
   125  	{
   126  		got := math_.MinInt[uint]()
   127  		want := uint(0)
   128  		if got != want {
   129  			t.Errorf("math_.MinInt[%T] = %v, want %v", got, got, want)
   130  		}
   131  	}
   132  	{
   133  		got := math_.MinInt[uint8]()
   134  		want := uint8(0)
   135  		if got != want {
   136  			t.Errorf("math_.MinInt[%T] = %v, want %v", got, got, want)
   137  		}
   138  	}
   139  	{
   140  		got := math_.MinInt[uint16]()
   141  		want := uint16(0)
   142  		if got != want {
   143  			t.Errorf("math_.MinInt[%T] = %v, want %v", got, got, want)
   144  		}
   145  	}
   146  	{
   147  		got := math_.MinInt[uint32]()
   148  		want := uint32(0)
   149  		if got != want {
   150  			t.Errorf("math_.MinInt[%T] = %v, want %v", got, got, want)
   151  		}
   152  	}
   153  	{
   154  		got := math_.MinInt[uint64]()
   155  		want := uint64(0)
   156  		if got != want {
   157  			t.Errorf("math_.MinInt[%T] = %v, want %v", got, got, want)
   158  		}
   159  	}
   160  }