diff options
Diffstat (limited to '')
-rw-r--r-- | src/tests/formula.cpp | 27 |
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 | } |