gitee.com/quant1x/gox@v1.21.2/api/number_test.go (about)

     1  package api
     2  
     3  import "testing"
     4  
     5  func TestParseFloat(t *testing.T) {
     6  	s := "123.456"
     7  	var f64 float64
     8  	f64 = ParseFloat(s)
     9  	if f64 != 123.456 {
    10  		t.Errorf("解析float64到int64失败")
    11  	}
    12  
    13  	s = "123.00"
    14  	f64 = ParseFloat(s)
    15  	if f64 != 123.00 {
    16  		t.Errorf("解析float64到int64失败")
    17  	}
    18  }
    19  
    20  func TestParseUint(t *testing.T) {
    21  	s := "123.456"
    22  	var i64 uint64
    23  	i64 = ParseUint(s)
    24  	if i64 != 123 {
    25  		t.Errorf("解析float64到int64失败")
    26  	}
    27  }
    28  
    29  func TestParseint(t *testing.T) {
    30  	s := "123.456"
    31  	var i64 int64
    32  	i64 = ParseInt(s)
    33  	if i64 != 123 {
    34  		t.Errorf("解析float64到int64失败")
    35  	}
    36  }
    37  
    38  func Test_parseBestEffort(t *testing.T) {
    39  	type args struct {
    40  		s string
    41  	}
    42  	tests := []struct {
    43  		name string
    44  		args args
    45  		want float64
    46  	}{
    47  		// TODO: Add test cases.
    48  	}
    49  	for _, tt := range tests {
    50  		t.Run(tt.name, func(t *testing.T) {
    51  			if got := parseBestEffort(tt.args.s); got != tt.want {
    52  				t.Errorf("parseBestEffort() = %v, want %v", got, tt.want)
    53  			}
    54  		})
    55  	}
    56  }
    57  
    58  func Test_parseInt64BestEffort(t *testing.T) {
    59  	type args struct {
    60  		s string
    61  	}
    62  	tests := []struct {
    63  		name string
    64  		args args
    65  		want int64
    66  	}{
    67  		// TODO: Add test cases.
    68  	}
    69  	for _, tt := range tests {
    70  		t.Run(tt.name, func(t *testing.T) {
    71  			if got := parseInt64BestEffort(tt.args.s); got != tt.want {
    72  				t.Errorf("parseInt64BestEffort() = %v, want %v", got, tt.want)
    73  			}
    74  		})
    75  	}
    76  }
    77  
    78  func Test_parseUint64BestEffort(t *testing.T) {
    79  	type args struct {
    80  		s string
    81  	}
    82  	tests := []struct {
    83  		name string
    84  		args args
    85  		want uint64
    86  	}{
    87  		// TODO: Add test cases.
    88  	}
    89  	for _, tt := range tests {
    90  		t.Run(tt.name, func(t *testing.T) {
    91  			if got := parseUint64BestEffort(tt.args.s); got != tt.want {
    92  				t.Errorf("parseUint64BestEffort() = %v, want %v", got, tt.want)
    93  			}
    94  		})
    95  	}
    96  }