From d4cf48613dd9b1338e174edbf4f47a7736bb2505 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 23 Jan 2009 22:02:15 +0000 Subject: Fixed a peculiar formula residue bug...eeew, formula residue. Also added a clear function to Bu::Stack --- src/tests/formula.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src/tests') diff --git a/src/tests/formula.cpp b/src/tests/formula.cpp index b3b0d5c..40b10a5 100644 --- a/src/tests/formula.cpp +++ b/src/tests/formula.cpp @@ -18,7 +18,7 @@ int main( int argc, char *argv[] ) Bu::Formula uForm; Bu::Formula dForm; - class CeilFunc : public Bu::Formula::Func + class DblCeilFunc : public Bu::Formula::Func { public: virtual double operator()( double x ) @@ -27,10 +27,29 @@ int main( int argc, char *argv[] ) } }; - dForm.hFunc.insert( "ceil", new CeilFunc() ); + dForm.hFunc.insert( "ceil", new DblCeilFunc() ); + + class IntCeilFunc : public Bu::Formula::Func + { + public: + virtual uint32_t operator()( uint32_t x ) + { + return x; + } + }; -// printf("u: %s = %u\n", argv[1], uForm.run( argv[1] ) ); - printf("d: %s = %f\n", argv[1], dForm.run( argv[1] ) ); + uForm.hFunc.insert( "ceil", new IntCeilFunc() ); + + uForm.hVars.insert("x", 10 ); + dForm.hVars.insert("x", 10.00 ); + uForm.hVars.insert("y", 10 ); + dForm.hVars.insert("y", 10.00 ); + + for( int j = 1; j < argc; j++ ) + { + printf("u: %s = %u\n", argv[j], uForm.run( argv[j] ) ); + printf("d: %s = %f\n", argv[j], dForm.run( argv[j] ) ); + } return 0; } -- cgit v1.2.3