mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 09:52:26 -05:00 
			
		
		
		
	Grand test fixup (#138)
* start fixing up tests * fix up tests + automate with drone * fiddle with linting * messing about with drone.yml * some more fiddling * hmmm * add cache * add vendor directory * verbose * ci updates * update some little things * update sig
This commit is contained in:
		
					parent
					
						
							
								329a5e8144
							
						
					
				
			
			
				commit
				
					
						98263a7de6
					
				
			
		
					 2677 changed files with 1090869 additions and 219 deletions
				
			
		
							
								
								
									
										105
									
								
								vendor/github.com/goccy/go-json/decode_number.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										105
									
								
								vendor/github.com/goccy/go-json/decode_number.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,105 @@ | |||
| package json | ||||
| 
 | ||||
| import ( | ||||
| 	"strconv" | ||||
| 	"unsafe" | ||||
| ) | ||||
| 
 | ||||
| type numberDecoder struct { | ||||
| 	stringDecoder *stringDecoder | ||||
| 	op            func(unsafe.Pointer, Number) | ||||
| 	structName    string | ||||
| 	fieldName     string | ||||
| } | ||||
| 
 | ||||
| func newNumberDecoder(structName, fieldName string, op func(unsafe.Pointer, Number)) *numberDecoder { | ||||
| 	return &numberDecoder{ | ||||
| 		stringDecoder: newStringDecoder(structName, fieldName), | ||||
| 		op:            op, | ||||
| 		structName:    structName, | ||||
| 		fieldName:     fieldName, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (d *numberDecoder) decodeStream(s *stream, depth int64, p unsafe.Pointer) error { | ||||
| 	bytes, err := d.decodeStreamByte(s) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	if _, err := strconv.ParseFloat(*(*string)(unsafe.Pointer(&bytes)), 64); err != nil { | ||||
| 		return errSyntax(err.Error(), s.totalOffset()) | ||||
| 	} | ||||
| 	d.op(p, Number(string(bytes))) | ||||
| 	s.reset() | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (d *numberDecoder) decode(buf []byte, cursor, depth int64, p unsafe.Pointer) (int64, error) { | ||||
| 	bytes, c, err := d.decodeByte(buf, cursor) | ||||
| 	if err != nil { | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	if _, err := strconv.ParseFloat(*(*string)(unsafe.Pointer(&bytes)), 64); err != nil { | ||||
| 		return 0, errSyntax(err.Error(), c) | ||||
| 	} | ||||
| 	cursor = c | ||||
| 	s := *(*string)(unsafe.Pointer(&bytes)) | ||||
| 	d.op(p, Number(s)) | ||||
| 	return cursor, nil | ||||
| } | ||||
| 
 | ||||
| func (d *numberDecoder) decodeStreamByte(s *stream) ([]byte, error) { | ||||
| 	for { | ||||
| 		switch s.char() { | ||||
| 		case ' ', '\n', '\t', '\r': | ||||
| 			s.cursor++ | ||||
| 			continue | ||||
| 		case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': | ||||
| 			return floatBytes(s), nil | ||||
| 		case 'n': | ||||
| 			if err := nullBytes(s); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			return nil, nil | ||||
| 		case '"': | ||||
| 			return d.stringDecoder.decodeStreamByte(s) | ||||
| 		case nul: | ||||
| 			if s.read() { | ||||
| 				continue | ||||
| 			} | ||||
| 			goto ERROR | ||||
| 		default: | ||||
| 			goto ERROR | ||||
| 		} | ||||
| 	} | ||||
| ERROR: | ||||
| 	return nil, errUnexpectedEndOfJSON("json.Number", s.totalOffset()) | ||||
| } | ||||
| 
 | ||||
| func (d *numberDecoder) decodeByte(buf []byte, cursor int64) ([]byte, int64, error) { | ||||
| 	for { | ||||
| 		switch buf[cursor] { | ||||
| 		case ' ', '\n', '\t', '\r': | ||||
| 			cursor++ | ||||
| 			continue | ||||
| 		case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': | ||||
| 			start := cursor | ||||
| 			cursor++ | ||||
| 			for floatTable[buf[cursor]] { | ||||
| 				cursor++ | ||||
| 			} | ||||
| 			num := buf[start:cursor] | ||||
| 			return num, cursor, nil | ||||
| 		case 'n': | ||||
| 			if err := validateNull(buf, cursor); err != nil { | ||||
| 				return nil, 0, err | ||||
| 			} | ||||
| 			cursor += 4 | ||||
| 			return nil, cursor, nil | ||||
| 		case '"': | ||||
| 			return d.stringDecoder.decodeByte(buf, cursor) | ||||
| 		default: | ||||
| 			return nil, 0, errUnexpectedEndOfJSON("json.Number", cursor) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue