4 const char * strings
[] =
30 const double results
[] =
55 const int ptroffset
[] =
80 const char * newlinetest_rn
= "\t-2.700264 -1.792122 -2.037897\r\n\t-0.084267 0.081827 0.584534\r\n";
81 const char * newlinetest_n
= "\t-2.700264 -1.792122 -2.037897\n\t-0.084267 0.081827 0.584534\n";
83 const double newlinetestresults
[] =
94 const int newlinetestptroffset_rn
[] =
107 const int newlinetestptroffset_n
[] =
120 #define TESTLINELINE_I 6
122 void testnewline(const char * buffer
, const int * ptroffset
)
124 int i
= 0; char * src
= NULL
; char *next
;
125 for(src
= (char *)buffer
; i
< (TESTLINELINE_I
+ 2); i
++, src
= next
)
127 double f
= strtod(src
, &next
);
128 if ((float)newlinetestresults
[i
] != (float)f
)
129 printf("RESULT FAILURE @ %s, should be %f was %f\n", src
, newlinetestresults
[i
], f
);
130 if (ptroffset
[i
] != (next
- src
))
131 printf("OFFSET FAILURE @ %s, should be %d was %d\n", src
, ptroffset
[i
], (int)(next
- src
));
132 if(next
<= src
) break;
135 if (TESTLINELINE_I
!= i
)
136 printf("ITER FAILURE @ %s, should be %d was %d\n", buffer
, TESTLINELINE_I
, i
);
141 char * float_end
= NULL
;
144 const char * str
= NULL
;
146 while((str
= strings
[i
]) != NULL
)
148 f
= strtod(str
, &float_end
);
150 printf("RESULT FAILURE @ %s, should be %f was %f\n", str
, results
[i
], f
);
151 if ((float_end
- str
) != ptroffset
[i
])
152 printf("OFFSET FAILURE @ %s, should be %d was %d\n", str
, ptroffset
[i
], (int)(float_end
- str
));
156 /* Check bahavior with new-lined strings */
157 testnewline(newlinetest_rn
, newlinetestptroffset_rn
);
158 testnewline(newlinetest_n
, newlinetestptroffset_n
);