summaryrefslogtreecommitdiff
path: root/tests/OS_Test.cpp
diff options
context:
space:
mode:
authorbala <balanatarajan@users.noreply.github.com>2002-08-31 19:05:39 +0000
committerbala <balanatarajan@users.noreply.github.com>2002-08-31 19:05:39 +0000
commit3f8d82485742dea40e584a197235bc8bfb4c727e (patch)
treee5652abe18f7137a20731c930fff1765cf36bbad /tests/OS_Test.cpp
parent7af2d6c38bcc4fd29fc71bd19cf42856301b20e3 (diff)
downloadATCD-3f8d82485742dea40e584a197235bc8bfb4c727e.tar.gz
ChangeLogTag: Sat Aug 31 13:55:52 2002 Balachandran Natarajan <bala@isis-server.vuse.vanderbilt.edu>
Diffstat (limited to 'tests/OS_Test.cpp')
-rw-r--r--tests/OS_Test.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/OS_Test.cpp b/tests/OS_Test.cpp
index 243f40ce846..e1c66e3fb61 100644
--- a/tests/OS_Test.cpp
+++ b/tests/OS_Test.cpp
@@ -473,6 +473,60 @@ string_emulation_test (void)
return 0;
}
+
+static int
+ctime_r_test (void)
+{
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing ctime_r\n")));
+
+ int result = 0;
+
+ // test 'normal' buffer
+ ACE_TCHAR buf[27];
+ buf[26] = 'Z';
+
+ ACE_Time_Value cur_time =
+ ACE_OS::gettimeofday ();
+
+ time_t secs = cur_time.sec ();
+ ACE_OS::ctime_r (&secs, buf, 26);
+
+ if (buf[0] == '\0')
+ {
+ result = -1;
+
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) Truncated input buffer\n")));
+ }
+ else if (buf[26] != 'Z')
+ {
+ result = -1;
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) Wrote past end of input buffer\n")));
+ }
+
+ // test small buffer
+ if (result == 0)
+ {
+ buf[10] = 'Z';
+ ACE_OS::ctime_r (&secs,
+ buf,
+ 10);
+
+ if ((buf[9] != '\0') ||
+ (buf[10] != 'Z'))
+ {
+ result = -1;
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%p|%t) Buffer length limit error\n")));
+ }
+ }
+
+
+ return result;
+}
+
+
int
ACE_TMAIN (int, ACE_TCHAR *[])
{
@@ -487,6 +541,9 @@ ACE_TMAIN (int, ACE_TCHAR *[])
if ((result = string_emulation_test ()) != 0)
status = result;
+ if ((result = ctime_r_test ()) != 0)
+ status = result;
+
ACE_END_TEST;
return status;
}