I'd go with a tolerance value, but rather then set it immediately I'll leave it for later, when we detect differences. I'd start with a tolerance of 0.
--strk; On Tue, Apr 04, 2006 at 12:33:19AM +0200, Mateusz Å?oskot wrote: > Hi, > > Simply question, do you think it is safe to use static values for > results comparison in Unit Tests. > In example, I want to test length/area calculations, so I need to > compare result with some well known value. > > The simplest solution is to use: > // ... > const double length = 14.142135623730951; > > line.getLength() == length > > Is this safe regarding double prec. numbers representation > on different architectures? > > Another option is to to check the closure of expected result. > A little descriptive example of this concept: > > // value of result returned by getLength or getArea > double result = 14.13873095113561; > > // well-known and expected result for some test case > const double expected = 14.142135623730951; > > // Check equality with accuracy of 0.001 > double ab = fabs(result - expected); > if (ab > 0.001) > cout << "EQUAL\n"; > else > cout << "NOT EQUAL\n"; > > or something similar. > > What approach would you recommend? > > Cheers > -- > Mateusz Åoskot > http://mateusz.loskot.net > _______________________________________________ > geos-devel mailing list > geos-devel@geos.refractions.net > http://geos.refractions.net/mailman/listinfo/geos-devel -- /"\ ASCII Ribbon Campaign \ / Respect for low technology. X Keep e-mail messages readable by any computer system. / \ Keep it ASCII. _______________________________________________ geos-devel mailing list geos-devel@geos.refractions.net http://geos.refractions.net/mailman/listinfo/geos-devel