2002-02-01 20:43:41 +00:00
|
|
|
// const_test.cpp (Equal() test functions)
|
2002-01-29 02:49:14 +00:00
|
|
|
//
|
|
|
|
|
// The WorldForge Project
|
|
|
|
|
// Copyright (C) 2002 The WorldForge Project
|
|
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program; if not, write to the Free Software
|
2016-05-16 14:12:35 +02:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2002-01-29 02:49:14 +00:00
|
|
|
//
|
|
|
|
|
// For information about WorldForge and its authors, please contact
|
|
|
|
|
// the Worldforge Web Site at http://www.worldforge.org.
|
|
|
|
|
|
|
|
|
|
// Author: Ron Steinke
|
|
|
|
|
// Created: 2002-1-28
|
|
|
|
|
|
2011-03-28 12:53:51 +01:00
|
|
|
#ifdef NDEBUG
|
|
|
|
|
#undef NDEBUG
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef DEBUG
|
|
|
|
|
#define DEBUG
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-10-02 16:32:47 +02:00
|
|
|
#include "wfmath/const.h"
|
2002-01-29 02:49:14 +00:00
|
|
|
|
2009-01-07 01:26:09 +00:00
|
|
|
#include <cassert>
|
|
|
|
|
|
2002-01-29 02:49:14 +00:00
|
|
|
using namespace WFMath;
|
|
|
|
|
|
|
|
|
|
// TestEqual() directly stolen from Numbers.cpp in Willow (thanks, Jesse!)
|
|
|
|
|
|
|
|
|
|
static void TestEqual()
|
|
|
|
|
{
|
2002-02-01 20:43:41 +00:00
|
|
|
assert( Equal(1.0001, 1.0, 1.0e-3));
|
|
|
|
|
assert(!Equal(1.0001, 1.0, 1.0e-5));
|
2002-01-29 02:49:14 +00:00
|
|
|
|
2002-02-01 20:43:41 +00:00
|
|
|
assert( Equal(0.00010000, 0.00010002, 1.0e-3));
|
|
|
|
|
assert(!Equal(0.00010000, 0.00010002, 1.0e-6));
|
2002-01-29 02:49:14 +00:00
|
|
|
|
2002-02-12 21:44:05 +00:00
|
|
|
assert( Equal(1000100.0, 1000000.0, 1.0e-3));
|
|
|
|
|
assert(!Equal(1000100.0, 1000000.0, 1.0e-6));
|
2002-01-29 02:49:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
TestEqual();
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|