1
/* Header+source file to test the dtostrf() function.
2
$Id: dtostrf.h,v 1.1 2007/02/06 12:36:58 dmix Exp $
6
# define PATTERN_SIZE 15
16
char pattern[PATTERN_SIZE];
24
/* This function is intended for run of test cases on the host computer.
26
char * dtostrf (double val, signed char width, unsigned char prec, char *s)
28
char fmt[16]; /* "%-110.100F" */
30
sprintf (fmt, "%%%d.%dF", width, prec);
31
sprintf (s, fmt, val);
36
#define PZLEN 5 /* protected zone length */
38
void run_dtostrf (const struct dtostrf_s *pt, int testno)
46
static char s[2*PZLEN + sizeof(pt->pattern)];
50
memset (s, testno, sizeof(s));
53
val.lo = pgm_read_dword (& pt->lo);
54
width = pgm_read_byte (& pt->width);
55
prec = pgm_read_byte (& pt->prec);
61
ps = dtostrf (val.fl, width, prec, s + PZLEN);
64
exit (testno + 0x1000);
65
for (ps = s; ps != s + PZLEN; ps++) {
66
if ((unsigned char)*ps != (testno & 0377))
67
exit (testno + 0x2000);
73
c = pgm_read_byte(pv++);
75
exit (testno + 0x3000);
82
printf ("*** testno= %d: must= %s was= %s\n",
83
testno, pt->pattern, s + PZLEN);
84
exit (testno + 0x3000);
89
for (; ps != s + sizeof(s); ps++) {
90
if ((unsigned char)*ps != (testno & 0377))
91
exit (testno + 0x4000);