1 #pragma warning (disable: 4786)
2 
3 #include <iostream>
4 #include <vector>
5 #include <string>
6 #include <xparam.h>
7 #include "../include/test_reg_everything.h"
8 
9 using namespace xParam;
10 using namespace std;
11 
main(void)12 int main(void)
13 {
14   try {
15 
16   xparam_init();
17 
18   cout << "Testing constructors..." << endl;
19   {
20     vector<everything> v;
21     float f;
22     double d;
23     ParamSet ps;
24     ps << ioParamVar(v,"v")
25        << ioParamVar(f,"f")
26        << ioParamVar(d,"d");
27     const char* argv[]=
28                  {"progname","v=true, '1', uchar('1'), short(1), ushort(1),",
29                   "1, 1u, 1U, 1l, 1L, 1UL, 1ul, 1uL, 1Ul,",
30                   "1.0, 1.0f, hello,",
31                   "[true], ['1'], [uchar('1')], [short(1)], [ushort(1)],",
32                   "[1], [1u], [1U], [1l], [1L], [1UL], [1ul],",
33                   "[1uL], [1Ul],",
34                   "[1.0], [1.0f], [hello] f=NaNF d=NaN"};
35 
36     ps.input(8,argv);
37     ps.output();
38   }
39 
40   cout << "Testing conversions..." << endl;
41   {
42     vector<bool> vb;
43     vector<char> vc;
44     vector<unsigned char> vuc;
45     vector<short> vs;
46     vector<unsigned short> vus;
47     vector<int> vi;
48     vector<unsigned int> vui;
49     vector<long> vl;
50     vector<unsigned long> vul;
51     vector<float> vf;
52     vector<double> vd;
53     vector<string> vst;
54 
55     ParamSet ps;
56     ps << ioParamVar(vb,"vb")
57        << ioParamVar(vc,"vc")
58        << ioParamVar(vuc,"vuc")
59        << ioParamVar(vs,"vs")
60        << ioParamVar(vus,"vus")
61        << ioParamVar(vi,"vi")
62        << ioParamVar(vui,"vui")
63        << ioParamVar(vl,"vl")
64        << ioParamVar(vul,"vul")
65        << ioParamVar(vf,"vf")
66        << ioParamVar(vd,"vd")
67        << ioParamVar(vst,"vst");
68 
69     char* argv[]={"progname",
70                   "vb=true, 1, 1u, short(1), ushort(1), 1L, 1UL, 1.0, 1.0f",
71                   "vc=char(true), '1',uchar('1'), char(short(1)),",
72                      "char(ushort(1)),char(1),char(1u),char(1l),char(1ul),",
73                      "char(1.0), char(1.0f)",
74 
75                   "vuc=true,uchar('1'),short(1),ushort(1),1,1u,1l,1ul,1.0,",
76                       "1.0f",
77 
78                   "vs=short('1'),uchar('1'),ushort(1),1,1u,1l,1ul,1.0,1.0f",
79                   "vus=ushort('1'),uchar('1'),short(1),1,1u,1l,1ul,1.0,1.0f",
80                   "vi=1,int('1'),uchar('1'),true,short(1),ushort(1),1u,1l,",
81                      "1ul,1.0,1.0f",
82 
83                   "vui=1u,uint('1'),uchar('1'),short(1),ushort(1),1,1l,1ul,",
84                       "1.0,1.0f",
85 
86                   "vl=1l,long('1'),uchar('1'),short(1),ushort(1),1,1u,1ul,",
87                      "1.0,1.0f",
88 
89                   "vul=1ul,uchar('1'),ulong('1'),ushort(1),short(1),1,1u,",
90                       "1l,1.0,1.0f",
91                   "vf=float('1'),uchar('1'),short(1),ushort(1),1,1u,1l,1ul,",
92                      "1.0,1.0f",
93 
94                   "vd=1.0,double('1'),uchar('1'),short(1),ushort(1),1,1u,",
95                      "1l,1ul,1.0f",
96 
97                   "vst=[ hello ]"};
98 
99     ps.input(22,argv);
100     ps.output();
101   }
102 
103   } catch (Error e) {
104     cout << "Unexpected error:" << endl;
105     cout << e.what() << endl;
106   }
107   return 0;
108 }
109