source: trunk/oldtest/src/RpChoice_test.cc @ 4503

Last change on this file since 4503 was 3177, checked in by mmc, 12 years ago

Updated all of the copyright notices to reference the transfer to
the new HUBzero Foundation, LLC.

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