MCPcopy Create free account
hub / github.com/cockroachdb/apd / ParseDecTest

Function ParseDecTest

gda_test.go:76–161  ·  view source on GitHub ↗
(r io.Reader)

Source from the content-addressed store, hash-verified

74}
75
76func ParseDecTest(r io.Reader) ([]TestCase, error) {
77 scanner := bufio.NewScanner(r)
78 tc := TestCase{
79 Extended: true,
80 }
81 var err error
82 var res []TestCase
83
84 for scanner.Scan() {
85 text := scanner.Text()
86 // TODO(mjibson): support these test cases
87 if strings.Contains(text, "#") {
88 continue
89 }
90 line := strings.Fields(strings.ToLower(text))
91 for i, t := range line {
92 if strings.HasPrefix(t, "--") {
93 line = line[:i]
94 break
95 }
96 }
97 if len(line) == 0 {
98 continue
99 }
100 if strings.HasSuffix(line[0], ":") {
101 if len(line) != 2 {
102 return nil, fmt.Errorf("expected 2 tokens, got %q", text)
103 }
104 switch directive := line[0]; directive[:len(directive)-1] {
105 case "precision":
106 tc.Precision, err = strconv.Atoi(line[1])
107 if err != nil {
108 return nil, err
109 }
110 case "maxexponent":
111 tc.MaxExponent, err = strconv.Atoi(line[1])
112 if err != nil {
113 return nil, err
114 }
115 case "minexponent":
116 tc.MinExponent, err = strconv.Atoi(line[1])
117 if err != nil {
118 return nil, err
119 }
120 case "rounding":
121 tc.Rounding = line[1]
122 case "version":
123 // ignore
124 case "extended":
125 tc.Extended = line[1] == "1"
126 case "clamp":
127 tc.Clamp = line[1] == "1"
128 default:
129 return nil, fmt.Errorf("unsupported directive: %s", directive)
130 }
131 } else {
132 if len(line) < 5 {
133 return nil, fmt.Errorf("short test case line: %q", text)

Callers 2

TestParseDecTestFunction · 0.85
readGDAFunction · 0.85

Calls 4

cleanNumberFunction · 0.85
ErrMethod · 0.80
ScanMethod · 0.45
TextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…