Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/tests/sfio/tputgetd.c
1810 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1999-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
#include "sftest.h"
21
22
tmain()
23
{
24
Sfdouble_t f, v;
25
int i, flag;
26
Sfio_t *fp;
27
28
if(!(fp = sfopen(NIL(Sfio_t*), tstfile("sf", 0), "w+")) )
29
terror("Can't open temp file");
30
31
#define BEGV (Sfdouble_t)(1e-10)
32
#define ENDV (Sfdouble_t)(1e-10 + 1)
33
#define INCR (Sfdouble_t)(1e-3)
34
35
for(f = BEGV; f < ENDV; f += INCR)
36
if(sfputd(fp,f) < 0)
37
terror("Writing %.12Lf",f);
38
39
sfseek(fp,(Sfoff_t)0,0);
40
for(flag = 0, f = BEGV, i = 0; f < ENDV; ++i, f += INCR)
41
{ if((v = sfgetd(fp)) == f)
42
continue;
43
if(v <= (f - 1e-10) || v >= (f + 1e-10) )
44
terror("Element=%d Input=%.12Lf, Expect=%.12Lf",i,v,f);
45
else if(!flag)
46
{ twarn("Element=%d Input=%.12Lf, Expect=%.12Lf\n",i,v,f);
47
flag = 1;
48
}
49
}
50
51
texit(0);
52
}
53
54