source: trunk/oldtest/src/RpNumber_test.cc @ 2038

Last change on this file since 2038 was 115, checked in by mmc, 16 years ago

Updated all copyright notices.

File size: 3.7 KB
Line 
1/*
2 * ======================================================================
3 *  Copyright (c) 2004-2005  Purdue Research Foundation
4 *
5 *  See the file "license.terms" for information on usage and
6 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7 * ======================================================================
8 */
9#include "RpNumber.h"
10
11int test_getPath(RpNumber* myNumber);
12int test_getUnits(RpNumber* myNumber);
13int test_getDefaultValue(RpNumber* myNumber);
14int test_getCurrentValue(RpNumber* myNumber);
15int test_getMin(RpNumber* myNumber);
16int test_getMax(RpNumber* myNumber);
17int test_getLabel(RpNumber* myNumber);
18int test_getDesc(RpNumber* myNumber);
19int test_convert(RpNumber* myNumber);
20
21int test_getPath(RpNumber* myNumber)
22{
23    std::cout << "Path " << myNumber->getPath() << std::endl;
24
25    return 1;
26}
27
28int test_getUnits(RpNumber* myNumber)
29{
30    std::cout << "units " << myNumber->getUnits() << std::endl;
31
32    return 1;
33}
34
35int test_getDefaultValue(RpNumber* myNumber)
36{
37    std::cout << "defaultVal " << myNumber->getDefaultValue() << std::endl;
38
39    return 1;
40}
41
42int test_getCurrentValue(RpNumber* myNumber)
43{
44    std::cout << "currentVal " << myNumber->getCurrentValue() << std::endl;
45
46    return 1;
47}
48
49int test_getMin(RpNumber* myNumber)
50{
51    std::cout << "min " << myNumber->getMin() << std::endl;
52
53    return 1;
54}
55
56int test_getMax(RpNumber* myNumber)
57{
58    std::cout << "max " << myNumber->getMax() << std::endl;
59
60    return 1;
61}
62
63int test_getLabel(RpNumber* myNumber)
64{
65    std::cout << "label " << myNumber->getLabel() << std::endl;
66
67    return 1;
68}
69
70int test_getDesc(RpNumber* myNumber)
71{
72    std::cout << "desc " << myNumber->getDesc() << std::endl;
73
74    return 1;
75}
76
77int test_convert(RpNumber* myNumber)
78{
79    int result = 0;
80    double newVal = myNumber->convert("C",1,&result);
81
82    if (result) {
83        std::cout << "newVal = " << newVal << std::endl;
84    }
85    else {
86        std::cout << "newVal has a bad result" << std::endl;
87    }
88
89    return result;
90}
91
92void define_some_units()
93{
94    const RpUnits * meters = RpUnits::define("m", NULL);
95    RpUnits::makeMetric(meters);
96    RpUnits::define("V", NULL);
97    RpUnits::define("s", NULL);
98    RpUnits::define("cm2/Vs", NULL);
99    const RpUnits* angstrom = RpUnits::define("A", NULL);
100    RpUnits::define(angstrom, meters, angstrom2meter, meter2angstrom);
101    const RpUnits* fahrenheit = RpUnits::define("F", NULL);
102    const RpUnits* celcius = RpUnits::define("C", NULL);
103    const RpUnits* kelvin = RpUnits::define("K", NULL);
104    RpUnits::define(fahrenheit, celcius, fahrenheit2centigrade, centigrade2fahrenheit);
105    RpUnits::define(celcius, kelvin, centigrade2kelvin, kelvin2centigrade);
106}
107
108
109int main ()
110{
111
112    define_some_units();
113
114    RpNumber* T1 = new RpNumber("input.(ambient).(temperature)","K",300.00);
115    RpNumber* T2 = new RpNumber("input.(ambient).(temperature)",
116                                "K",
117                                300.00,
118                                0.00,
119                                1000.00,
120                                "Temperature",
121                                "Ambient Temperature, value between 0 and 1000"
122                                );
123   
124
125    test_getPath(T1);
126    test_getUnits(T1);
127    test_getDefaultValue(T1);
128    test_getCurrentValue(T1);
129    test_getMin(T1);
130    test_getMax(T1);
131    test_getLabel(T1);
132    test_getDesc(T1);
133    test_convert(T1);
134    test_getCurrentValue(T1);
135    test_getUnits(T1);
136
137    std::cout << std::endl;
138
139    test_getPath(T2);
140    test_getUnits(T2);
141    test_getDefaultValue(T2);
142    test_getCurrentValue(T2);
143    test_getMin(T2);
144    test_getMax(T2);
145    test_getLabel(T2);
146    test_getDesc(T2);
147    test_convert(T2);
148
149    std::cout << std::endl;
150
151    return 0;
152}
Note: See TracBrowser for help on using the repository browser.