File: dtostrf-01.c

package info (click to toggle)
avr-libc 1%3A1.6.2.cvs20080610-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 14,848 kB
  • ctags: 55,619
  • sloc: ansic: 92,267; asm: 6,692; sh: 4,131; makefile: 2,481; python: 976; pascal: 426; perl: 116
file content (34 lines) | stat: -rw-r--r-- 850 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Tests for 'dtostrf'.
   $Id: dtostrf-01.c,v 1.1 2007/02/06 12:36:58 dmix Exp $
*/
#include <stdlib.h>
#include <string.h>
#include "progmem.h"
#include "dtostrf.h"

PROGMEM static const struct dtostrf_s t[] = {

/* Nonregular cases.	*/
    { { .fl = 1.0 }, 0, 0,	"1" },
    { { .fl = 0.0 }, 0, 0,	"0" },
    { { .fl = 1.1 }, 0, 1,	"1.1" },
    { { .fl = 1.2 }, 4, 1,	" 1.2" },
    { { .fl = 0.5 }, 0, 1,	"0.5" },
    { { .fl = 0.5 }, 0, 2,	"0.50" },
    { { .fl = 0.5 }, 0, 8,	"0.50000000" },
    { { .fl = 0.5 }, 0, 9,	"0.500000000" },
    { { .fl = 123.45 }, 0, 2,	"123.45" },
    { { .fl = 0.999999 }, 0, 6,	"0.999999"	},
    
    { { .fl = 1.234 }, -8, 3,	"1.234   "	},
    { { .fl = -1.234 }, -8, 3,	"-1.234  "	},

};

int main ()
{
    int i;
    for (i= 0; (size_t)i != sizeof(t)/sizeof(t[0]); i++)
	run_dtostrf (t+i, i+1);
    return 0;
}