source: trunk/test/src/RpChoice_test.cc @ 43

Last change on this file since 43 was 40, checked in by dkearney, 19 years ago

initial add for test directory which will hold test cases for using rappture

File size: 2.8 KB
Line 
1#include "RpChoice.h"
2
3int test_setPath(RpChoice* myChoice);
4int test_setDefaultValue(RpChoice* myChoice);
5int test_setCurrentValue(RpChoice* myChoice);
6int test_setOption(RpChoice* myChoice);
7int test_deleteOption(RpChoice* myChoice);
8
9int test_setPath(RpChoice* myChoice)
10{
11    std::cout << "Path " << myChoice->getPath() << std::endl;
12    myChoice->setPath("input.(ambiant)");
13    std::cout << "Path " << myChoice->getPath() << std::endl;
14
15    return 1;
16}
17
18int test_setDefaultValue(RpChoice* myChoice)
19{
20    std::cout << "defaultVal " << myChoice->getDefaultValue() << std::endl;
21    myChoice->setDefaultValue("new default value");
22    std::cout << "defaultVal " << myChoice->getDefaultValue() << std::endl;
23
24    return 1;
25}
26
27int test_setCurrentValue(RpChoice* myChoice)
28{
29    std::cout << "currentVal " << myChoice->getCurrentValue() << std::endl;
30    myChoice->setCurrentValue("new current value");
31    std::cout << "currentVal " << myChoice->getCurrentValue() << std::endl;
32
33    return 1;
34}
35
36int test_setOption(RpChoice* myChoice)
37{
38    unsigned int optListSize = myChoice->getOptListSize();
39    myChoice->setOption("newOpt");
40    std::string tmpOpt= myChoice->getFirstOption();
41    std::string optList;
42
43    std::cout << "begin setOption optListSize = " << optListSize << std::endl;
44
45    while (tmpOpt != "") {
46        optList += tmpOpt + " ";
47        tmpOpt= myChoice->getNextOption();
48    }
49
50    std::cout << "setOption List = " << optList << std::endl;
51    std::cout << "end setOption optListSize = " << myChoice->getOptListSize() << std::endl;
52
53    return 1;
54}
55
56int test_deleteOption(RpChoice* myChoice)
57{
58    std::string tmpOpt= myChoice->getFirstOption();
59
60    std::cout << "begin deleteOption optListSize = " << myChoice->getOptListSize() << std::endl;
61    myChoice->deleteOption("newOpt");
62    std::cout << "end deleteOption optListSize = " << myChoice->getOptListSize() << std::endl;
63
64    return 1;
65}
66
67int main ()
68{
69
70    RpChoice* T1 = new RpChoice("input.(ambient).(temperature)",
71                                "default-string",
72                                "opt1,opt2,opt3");
73    RpChoice* T2 = new RpChoice("input.(ambient).(temperature)",
74                                "default-string",
75                                "string3's label",
76                                "string3's desc",
77                                "opt4,opt5,opt6");
78   
79
80    std::cout << "T1 run" << std::endl;
81    test_setPath(T1);
82    test_setDefaultValue(T1);
83    test_setCurrentValue(T1);
84    test_setOption(T1);
85    test_deleteOption(T1);
86
87    std::cout << std::endl;
88
89    std::cout << "T2 run" << std::endl;
90    test_setPath(T2);
91    test_setDefaultValue(T2);
92    test_setCurrentValue(T2);
93    test_setOption(T2);
94    test_deleteOption(T2);
95
96    std::cout << std::endl;
97    std::cout << std::endl;
98
99    return 0;
100}
Note: See TracBrowser for help on using the repository browser.