summaryrefslogtreecommitdiff
path: root/src/tests/formula.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-01-23 22:02:15 +0000
committerMike Buland <eichlan@xagasoft.com>2009-01-23 22:02:15 +0000
commitd4cf48613dd9b1338e174edbf4f47a7736bb2505 (patch)
tree404daa83485d75325ef76019e557e5203ba522d4 /src/tests/formula.cpp
parentb94a6a42c1024c00fab7b678cccaecfaa7604d56 (diff)
downloadlibbu++-d4cf48613dd9b1338e174edbf4f47a7736bb2505.tar.gz
libbu++-d4cf48613dd9b1338e174edbf4f47a7736bb2505.tar.bz2
libbu++-d4cf48613dd9b1338e174edbf4f47a7736bb2505.tar.xz
libbu++-d4cf48613dd9b1338e174edbf4f47a7736bb2505.zip
Fixed a peculiar formula residue bug...eeew, formula residue. Also added a
clear function to Bu::Stack
Diffstat (limited to 'src/tests/formula.cpp')
-rw-r--r--src/tests/formula.cpp27
1 files changed, 23 insertions, 4 deletions
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[] )
18 Bu::Formula<uint32_t> uForm; 18 Bu::Formula<uint32_t> uForm;
19 Bu::Formula<double> dForm; 19 Bu::Formula<double> dForm;
20 20
21 class CeilFunc : public Bu::Formula<double>::Func 21 class DblCeilFunc : public Bu::Formula<double>::Func
22 { 22 {
23 public: 23 public:
24 virtual double operator()( double x ) 24 virtual double operator()( double x )
@@ -27,10 +27,29 @@ int main( int argc, char *argv[] )
27 } 27 }
28 }; 28 };
29 29
30 dForm.hFunc.insert( "ceil", new CeilFunc() ); 30 dForm.hFunc.insert( "ceil", new DblCeilFunc() );
31
32 class IntCeilFunc : public Bu::Formula<uint32_t>::Func
33 {
34 public:
35 virtual uint32_t operator()( uint32_t x )
36 {
37 return x;
38 }
39 };
31 40
32// printf("u: %s = %u\n", argv[1], uForm.run( argv[1] ) ); 41 uForm.hFunc.insert( "ceil", new IntCeilFunc() );
33 printf("d: %s = %f\n", argv[1], dForm.run( argv[1] ) ); 42
43 uForm.hVars.insert("x", 10 );
44 dForm.hVars.insert("x", 10.00 );
45 uForm.hVars.insert("y", 10 );
46 dForm.hVars.insert("y", 10.00 );
47
48 for( int j = 1; j < argc; j++ )
49 {
50 printf("u: %s = %u\n", argv[j], uForm.run( argv[j] ) );
51 printf("d: %s = %f\n", argv[j], dForm.run( argv[j] ) );
52 }
34 53
35 return 0; 54 return 0;
36} 55}