summaryrefslogtreecommitdiff
path: root/ACE/tests/Env_Value_Test.cpp
diff options
context:
space:
mode:
authorTimothy Simpson <simpsont@objectcomputing.com>2019-11-19 15:06:13 -0600
committerTimothy Simpson <simpsont@objectcomputing.com>2019-11-19 15:06:13 -0600
commitef30d3489375812369b540e90a2fcd3dabdab9a6 (patch)
tree56a6a3fb5386d9766fe352f02d9f85edae5cb7fe /ACE/tests/Env_Value_Test.cpp
parent1caa160ec30e221b7e6b747d40040c8dc252874e (diff)
downloadATCD-ef30d3489375812369b540e90a2fcd3dabdab9a6.tar.gz
Avoid the use of unmanaged strings in ACE_Env_Helper
Diffstat (limited to 'ACE/tests/Env_Value_Test.cpp')
-rw-r--r--ACE/tests/Env_Value_Test.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/ACE/tests/Env_Value_Test.cpp b/ACE/tests/Env_Value_Test.cpp
index 3e21b3ffd3a..1cdce917768 100644
--- a/ACE/tests/Env_Value_Test.cpp
+++ b/ACE/tests/Env_Value_Test.cpp
@@ -17,6 +17,7 @@
#include "ace/OS_NS_string.h"
#include "ace/Process.h"
#include "ace/Env_Value_T.h"
+#include "ace/SString.h"
#define TEST_THIS(type, varname, defval, expval) \
do { \
@@ -61,13 +62,25 @@ run_main (int, ACE_TCHAR* [])
TEST_THIS (short, ACE_TEXT ("TEST_VALUE_NEGATIVE"), 0, -10);
TEST_THIS (unsigned short, ACE_TEXT ("TEST_VALUE_NEGATIVE"), 0, (unsigned short) -10);
- const ACE_TCHAR *defstr = ACE_TEXT ("Sarah Cleeland is Two!");
- ACE_Env_Value<const ACE_TCHAR *> sval (ACE_TEXT ("This_Shouldnt_Be_Set_Hopefully"),
- defstr);
- if (ACE_OS::strcmp (sval, defstr) != 0)
+ const ACE_TCHAR* const defstr = ACE_TEXT ("Sarah Cleeland is Two!");
+
+ ACE_Env_Value<ACE_TString> sval1 (ACE_TEXT ("This_Shouldnt_Be_Set_Hopefully"),
+ defstr);
+ if (ACE_OS::strcmp (static_cast<ACE_TString>(sval1).c_str(), defstr) != 0) {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Mismatch: %s should be %s\n"),
+ static_cast<ACE_TString>(sval1).c_str(), defstr));
+ }
+
+ const ACE_TString strval(ACE_TEXT("-10.2"));
+
+ ACE_Env_Value<ACE_TString> sval2 (ACE_TEXT ("TEST_VALUE_NEGATIVE"),
+ defstr);
+ if (ACE_OS::strcmp (static_cast<ACE_TString>(sval2).c_str(), strval.c_str()) != 0) {
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Mismatch: %s should be %s\n"),
- (const ACE_TCHAR *)sval, defstr));
+ static_cast<ACE_TString>(sval2).c_str(), strval.c_str()));
+ }
ACE_END_TEST;
}
#endif // ACE_LACKS_PUTENV