Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 19 for NumError (0.14 sec)

  1. src/strconv/atoi.go

    func syntaxError(fn, str string) *NumError {
    	return &NumError{fn, stringslite.Clone(str), ErrSyntax}
    }
    
    func rangeError(fn, str string) *NumError {
    	return &NumError{fn, stringslite.Clone(str), ErrRange}
    }
    
    func baseError(fn, str string, base int) *NumError {
    	return &NumError{fn, stringslite.Clone(str), errors.New("invalid base " + Itoa(base))}
    }
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Sun May 05 00:24:26 UTC 2024
    - 8.3K bytes
    - Viewed (0)
  2. src/strconv/atoi_test.go

    		if test.err != nil {
    			test.err = &NumError{"ParseUint", test.in, test.err}
    		}
    	}
    	for i := range parseUint64BaseTests {
    		test := &parseUint64BaseTests[i]
    		if test.err != nil {
    			test.err = &NumError{"ParseUint", test.in, test.err}
    		}
    	}
    	for i := range parseInt64Tests {
    		test := &parseInt64Tests[i]
    		if test.err != nil {
    			test.err = &NumError{"ParseInt", test.in, test.err}
    		}
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Feb 21 05:09:21 UTC 2023
    - 17.1K bytes
    - Viewed (0)
  3. src/strconv/atob_test.go

    		b, e := ParseBool(test.in)
    		if test.err != nil {
    			// expect an error
    			if e == nil {
    				t.Errorf("ParseBool(%s) = nil; want %s", test.in, test.err)
    			} else {
    				// NumError assertion must succeed; it's the only thing we return.
    				if e.(*NumError).Err != test.err {
    					t.Errorf("ParseBool(%s) = %s; want %s", test.in, e, test.err)
    				}
    			}
    		} else {
    			if e != nil {
    				t.Errorf("ParseBool(%s) = %s; want nil", test.in, e)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Aug 24 18:08:43 UTC 2023
    - 1.9K bytes
    - Viewed (0)
  4. src/strconv/atoc.go

    const fnParseComplex = "ParseComplex"
    
    // convErr splits an error returned by parseFloatPrefix
    // into a syntax or range error for ParseComplex.
    func convErr(err error, s string) (syntax, range_ error) {
    	if x, ok := err.(*NumError); ok {
    		x.Func = fnParseComplex
    		x.Num = stringslite.Clone(s)
    		if x.Err == ErrRange {
    			return nil, x
    		}
    	}
    	return err, nil
    }
    
    // ParseComplex converts the string s to a complex number
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Sun May 05 00:24:26 UTC 2024
    - 3.1K bytes
    - Viewed (0)
  5. src/cmd/internal/buildid/buildid_test.go

    	buf := make([]byte, 64)
    	buf2 := make([]byte, 64)
    	id := make([]byte, 8)
    	zero := make([]byte, 8)
    	for i := range id {
    		id[i] = byte(i)
    	}
    	numError := 0
    	errorf := func(msg string, args ...any) {
    		t.Errorf(msg, args...)
    		if numError++; numError > 20 {
    			t.Logf("stopping after too many errors")
    			t.FailNow()
    		}
    	}
    	for bufSize := len(id); bufSize <= len(buf); bufSize++ {
    		for j := range buf {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Mar 04 17:31:28 UTC 2024
    - 6.6K bytes
    - Viewed (0)
  6. src/strconv/strconv_test.go

    		{errBool, "ParseBool"},
    		{errFloat, "ParseFloat"},
    		{errInt64, "ParseInt"},
    		{errUint64, "ParseUint"},
    	}
    
    	for _, v := range vectors {
    		nerr, ok := v.err.(*NumError)
    		if !ok {
    			t.Errorf("test %s, error was not a *NumError", v.want)
    			continue
    		}
    		if got := nerr.Func; got != v.want {
    			t.Errorf("mismatching Func: got %s, want %s", got, v.want)
    		}
    	}
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Aug 23 20:29:22 UTC 2022
    - 4.7K bytes
    - Viewed (0)
  7. src/flag/flag.go

    // errRange is returned by Set if a flag's value is out of range.
    // It then gets wrapped through failf to provide more information.
    var errRange = errors.New("value out of range")
    
    func numError(err error) error {
    	ne, ok := err.(*strconv.NumError)
    	if !ok {
    		return err
    	}
    	if ne.Err == strconv.ErrSyntax {
    		return errParse
    	}
    	if ne.Err == strconv.ErrRange {
    		return errRange
    	}
    	return err
    }
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue May 07 18:38:24 UTC 2024
    - 39.7K bytes
    - Viewed (0)
  8. src/strconv/atoc_test.go

    		{"1e+4294967296+1e+4294967296i", infpp, ErrRange},
    		{"1e+4294967296-1e+4294967296i", infpm, ErrRange},
    	}
    	for i := range tests {
    		test := &tests[i]
    		if test.err != nil {
    			test.err = &NumError{Func: "ParseComplex", Num: test.in, Err: test.err}
    		}
    		got, err := ParseComplex(test.in, 128)
    		if !reflect.DeepEqual(err, test.err) {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Nov 03 23:05:51 UTC 2020
    - 6.8K bytes
    - Viewed (0)
  9. src/strconv/atof.go

    // (Parsing a hexadecimal floating-point value only rounds when
    // there are more bits in the hexadecimal representation than
    // will fit in the mantissa.)
    //
    // The errors that ParseFloat returns have concrete type *NumError
    // and include err.Num = s.
    //
    // If s is not syntactically well-formed, ParseFloat returns err.Err = ErrSyntax.
    //
    // If s is syntactically well-formed but is more than 1/2 ULP
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Jun 06 18:50:50 UTC 2022
    - 15.9K bytes
    - Viewed (0)
  10. src/strconv/example_test.go

    	// value: "
    	// multibyte: false
    	// tail: Fran & Freddie's Diner\"
    }
    
    func ExampleNumError() {
    	str := "Not a number"
    	if _, err := strconv.ParseFloat(str, 64); err != nil {
    		e := err.(*strconv.NumError)
    		fmt.Println("Func:", e.Func)
    		fmt.Println("Num:", e.Num)
    		fmt.Println("Err:", e.Err)
    		fmt.Println(err)
    	}
    
    	// Output:
    	// Func: ParseFloat
    	// Num: Not a number
    	// Err: invalid syntax
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Oct 13 22:57:37 UTC 2023
    - 8.9K bytes
    - Viewed (0)
Back to top