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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
// $Id$
// ============================================================================
//
// = LIBRARY
// tests
//
// = DESCRIPTION
// This is a simple test to make sure the Env_Value template is
// working correctly.
//
// = AUTHOR
// Chris Cleeland
//
// ============================================================================
#include "test_config.h"
#include "ace/OS.h"
#include "ace/Process.h"
#include "ace/Env_Value_T.h"
int
main (int argc, char *argv[], char* environ[])
{
if (argc == 1)
{
// No arguments means we're the initial test
ACE_Process_Options options (1);
options.setenv (environ);
char* const* envargv;
options.command_line ("Env_Value_Test run_as_test");
options.setenv("TEST_VALUE_POSITIVE", "%s", "10.2");
options.setenv("TEST_VALUE_NEGATIVE", "%s", "-10.2");
ACE_Process p;
ACE_ASSERT (p.spawn (options) != -1);
p.wait ();
}
else
{
// In this case we're the child
ACE_START_TEST ("Env_Value");
#define TEST_THIS(type,varname,defval,expval) do { ACE_Env_Value<type> val(varname, (defval)); ACE_ASSERT (val == (expval)); } while (0)
TEST_THIS (int, "TEST_VALUE_POSITIVE", 4, 10);
TEST_THIS (double, "TEST_VALUE_POSITIVE", -1.0, 10.2);
TEST_THIS (unsigned long, "TEST_VALUE_POSITIVE", 0, 10);
TEST_THIS (short, "TEST_VALUE_POSITIVE", 0, 10);
TEST_THIS (int, "TEST_VALUE_NEGATIVE", 4, -10);
TEST_THIS (double, "TEST_VALUE_NEGATIVE", -1.0, -10.2);
TEST_THIS (unsigned long, "TEST_VALUE_NEGATIVE", 0, -10);
TEST_THIS (short, "TEST_VALUE_NEGATIVE", 0, -10);
char* defstr = "Sarah Cleeland is Two!";
ACE_Env_Value<char*> sval("This_Shouldnt_Be_Set_Hopefully", defstr);
ACE_ASSERT (ACE_OS::strcmp (sval, defstr) == 0);
ACE_END_TEST;
}
return 0;
}
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class ACE_Env_Value<int>;
template class ACE_Env_Value<double>;
template class ACE_Env_Value<unsigned long>;
template class ACE_Env_Value<short>;
template class ACE_Env_Value<char*>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#pragma instantiate ACE_Env_Value<int>
#pragma instantiate ACE_Env_Value<double>
#pragma instantiate ACE_Env_Value<unsigned long>
#pragma instantiate ACE_Env_Value<short>
#pragma instantiate ACE_Env_Value<char*>
#endif
|