summaryrefslogtreecommitdiff
path: root/src/tests/formula.cpp
blob: b3b0d5c1db1088497a4cef662b89b8dd557e4e44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * Copyright (C) 2007-2008 Xagasoft, All rights reserved.
 *
 * This file is part of the libbu++ library and is released under the
 * terms of the license contained in the file LICENSE.
 */

#include "bu/formula.h"
#include <math.h>

int main( int argc, char *argv[] )
{
	if( argc < 2 )
	{
		printf("usage: %s <formula>\n", argv[0] );
		return -1;
	}
	Bu::Formula<uint32_t> uForm;
	Bu::Formula<double> dForm;

	class CeilFunc : public Bu::Formula<double>::Func
	{
	public:
		virtual double operator()( double x )
		{
			return ceil( x );
		}
	};

	dForm.hFunc.insert( "ceil", new CeilFunc() );

//	printf("u: %s = %u\n", argv[1], uForm.run( argv[1] ) );
	printf("d: %s = %f\n", argv[1], dForm.run( argv[1] ) );

	return 0;
}