/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1999-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* *18***********************************************************************/19#include "sftest.h"2021tmain()22{23Sfdouble_t f, v;24int i, flag;25Sfio_t *fp;2627if(!(fp = sfopen(NIL(Sfio_t*), tstfile("sf", 0), "w+")) )28terror("Can't open temp file");2930#define BEGV (Sfdouble_t)(1e-10)31#define ENDV (Sfdouble_t)(1e-10 + 1)32#define INCR (Sfdouble_t)(1e-3)3334for(f = BEGV; f < ENDV; f += INCR)35if(sfputd(fp,f) < 0)36terror("Writing %.12Lf",f);3738sfseek(fp,(Sfoff_t)0,0);39for(flag = 0, f = BEGV, i = 0; f < ENDV; ++i, f += INCR)40{ if((v = sfgetd(fp)) == f)41continue;42if(v <= (f - 1e-10) || v >= (f + 1e-10) )43terror("Element=%d Input=%.12Lf, Expect=%.12Lf",i,v,f);44else if(!flag)45{ twarn("Element=%d Input=%.12Lf, Expect=%.12Lf\n",i,v,f);46flag = 1;47}48}4950texit(0);51}525354