Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 3 of 3 for IsIntKind (0.19 sec)

  1. operator/pkg/util/reflect.go

    	if IsValueNil(val) {
    		return 0, false
    	}
    	v := reflect.ValueOf(val)
    	switch {
    	case IsIntKind(v.Kind()):
    		return int(v.Int()), true
    	case IsUintKind(v.Kind()):
    		return int(v.Uint()), true
    	}
    	return 0, false
    }
    
    // IsIntKind reports whether k is an integer kind of any size.
    func IsIntKind(k reflect.Kind) bool {
    	switch k {
    	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Mon Jul 25 19:30:47 UTC 2022
    - 8.6K bytes
    - Viewed (0)
  2. operator/pkg/util/reflect_test.go

    )
    
    func TestIsInteger(t *testing.T) {
    	tests := []struct {
    		desc     string
    		function func(v reflect.Kind) bool
    		want     []any
    	}{
    		{
    			desc:     "ints",
    			function: IsIntKind,
    			want:     allIntTypes,
    		},
    		{
    			desc:     "uints",
    			function: IsUintKind,
    			want:     allUintTypes,
    		},
    	}
    
    	for _, tt := range tests {
    		var got []any
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Mon Jul 25 19:30:47 UTC 2022
    - 10.2K bytes
    - Viewed (0)
  3. operator/pkg/validate/common.go

    // validateIntRange checks whether val is an integer in [min, max].
    func validateIntRange(path util.Path, val any, min, max int64) util.Errors {
    	k := reflect.TypeOf(val).Kind()
    	var err error
    	switch {
    	case util.IsIntKind(k):
    		v := reflect.ValueOf(val).Int()
    		if v < min || v > max {
    			err = fmt.Errorf("value %s:%v falls outside range [%v, %v]", path, v, min, max)
    		}
    	case util.IsUintKind(k):
    		v := reflect.ValueOf(val).Uint()
    Registered: Fri Jun 14 15:00:06 UTC 2024
    - Last Modified: Thu Aug 10 15:35:03 UTC 2023
    - 11K bytes
    - Viewed (0)
Back to top