187d2adbcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
387d2adbcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
487d2adbcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
587d2adbcSAndrew Rist  * distributed with this work for additional information
687d2adbcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
787d2adbcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
887d2adbcSAndrew Rist  * "License"); you may not use this file except in compliance
987d2adbcSAndrew Rist  * with the License.  You may obtain a copy of the License at
1087d2adbcSAndrew Rist  *
1187d2adbcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1287d2adbcSAndrew Rist  *
1387d2adbcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
1487d2adbcSAndrew Rist  * software distributed under the License is distributed on an
1587d2adbcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1687d2adbcSAndrew Rist  * KIND, either express or implied.  See the License for the
1787d2adbcSAndrew Rist  * specific language governing permissions and limitations
1887d2adbcSAndrew Rist  * under the License.
1987d2adbcSAndrew Rist  *
2087d2adbcSAndrew Rist  *************************************************************/
2187d2adbcSAndrew Rist 
2287d2adbcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir 
25cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
26cdf0e10cSrcweir #include "precompiled_sal.hxx"
27cdf0e10cSrcweir // This is a test of helperfunctions
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <osl/time.h>
30cdf0e10cSrcweir #include <osl/thread.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "stringhelper.hxx"
33cdf0e10cSrcweir 
34*faf81e80SDamjan Jovanovic #include "gtest/gtest.h"
35cdf0e10cSrcweir 
36cdf0e10cSrcweir // void isJaBloed()
37cdf0e10cSrcweir // {
38*faf81e80SDamjan Jovanovic //     printf("Ist ja echt bloed.\n");
39cdf0e10cSrcweir // }
40cdf0e10cSrcweir 
t_abs64(sal_Int64 _nValue)41cdf0e10cSrcweir inline sal_Int64 t_abs64(sal_Int64 _nValue)
42cdf0e10cSrcweir {
43cdf0e10cSrcweir     // std::abs() seems to have some ambiguity problems (so-texas)
44cdf0e10cSrcweir     // return abs(_nValue);
45*faf81e80SDamjan Jovanovic     printf("t_abs64(%ld)\n", _nValue);
46*faf81e80SDamjan Jovanovic     // ASSERT_TRUE(_nValue < 2147483647);
47cdf0e10cSrcweir 
48cdf0e10cSrcweir     if (_nValue < 0)
49cdf0e10cSrcweir     {
50cdf0e10cSrcweir         _nValue = -_nValue;
51cdf0e10cSrcweir     }
52cdf0e10cSrcweir     return _nValue;
53cdf0e10cSrcweir }
54cdf0e10cSrcweir 
printf64(sal_Int64 n)55*faf81e80SDamjan Jovanovic void printf64(sal_Int64 n)
56cdf0e10cSrcweir {
57cdf0e10cSrcweir     if (n < 0)
58cdf0e10cSrcweir     {
59cdf0e10cSrcweir         // negativ
60cdf0e10cSrcweir         printf("-");
61cdf0e10cSrcweir         n = -n;
62cdf0e10cSrcweir     }
63cdf0e10cSrcweir     if (n > 2147483647)
64cdf0e10cSrcweir     {
65cdf0e10cSrcweir         sal_Int64 n64 = n >> 32;
66cdf0e10cSrcweir         sal_uInt32 n32 = n64 & 0xffffffff;
67cdf0e10cSrcweir         printf("0x%.8x ", n32);
68cdf0e10cSrcweir         n32 = n & 0xffffffff;
69cdf0e10cSrcweir         printf("%.8x (64bit)", n32);
70cdf0e10cSrcweir     }
71cdf0e10cSrcweir     else
72cdf0e10cSrcweir     {
73cdf0e10cSrcweir         sal_uInt32 n32 = n & 0xffffffff;
74cdf0e10cSrcweir         printf("0x%.8x (32bit) ", n32);
75cdf0e10cSrcweir     }
76cdf0e10cSrcweir     printf("\n");
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir // -----------------------------------------------------------------------------
80cdf0e10cSrcweir namespace testOfHelperFunctions
81cdf0e10cSrcweir {
82*faf81e80SDamjan Jovanovic     class test_t_abs64 : public ::testing::Test
83cdf0e10cSrcweir     {
84cdf0e10cSrcweir     };
85cdf0e10cSrcweir 
TEST_F(test_t_abs64,test0)86*faf81e80SDamjan Jovanovic     TEST_F(test_t_abs64, test0)
87cdf0e10cSrcweir     {
88cdf0e10cSrcweir         // this values has an overrun!
89cdf0e10cSrcweir         sal_Int32 n32 = 2147483648;
90*faf81e80SDamjan Jovanovic         printf("n32 should be -2^31 is: %d\n", n32);
91*faf81e80SDamjan Jovanovic         ASSERT_TRUE(n32 == -2147483648 ) << "n32!=2147483648";
92cdf0e10cSrcweir     }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 
TEST_F(test_t_abs64,test1_0)95*faf81e80SDamjan Jovanovic     TEST_F(test_t_abs64,test1_0)
96cdf0e10cSrcweir     {
97cdf0e10cSrcweir         sal_Int64 n;
98cdf0e10cSrcweir         n = 1073741824;
99cdf0e10cSrcweir         n <<= 9;
100*faf81e80SDamjan Jovanovic         printf("Value of n is ");
101*faf81e80SDamjan Jovanovic         printf64(n);
102*faf81e80SDamjan Jovanovic         ASSERT_TRUE(t_abs64(n) > 0) << "n=2^30 << 9";
103cdf0e10cSrcweir     }
104cdf0e10cSrcweir 
TEST_F(test_t_abs64,test1)105*faf81e80SDamjan Jovanovic     TEST_F(test_t_abs64, test1)
106cdf0e10cSrcweir     {
107cdf0e10cSrcweir         sal_Int64 n;
108cdf0e10cSrcweir         n = 2147483648 << 8;
109*faf81e80SDamjan Jovanovic         printf("Value of n is ");
110*faf81e80SDamjan Jovanovic         printf64(n);
111*faf81e80SDamjan Jovanovic         ASSERT_TRUE(t_abs64(n) > 0) << "n=2^31 << 8";
112cdf0e10cSrcweir     }
TEST_F(test_t_abs64,test1_1)113*faf81e80SDamjan Jovanovic     TEST_F(test_t_abs64, test1_1)
114cdf0e10cSrcweir     {
115cdf0e10cSrcweir         sal_Int64 n;
116cdf0e10cSrcweir         n = sal_Int64(2147483648) << 8;
117*faf81e80SDamjan Jovanovic         printf("Value of n is ");
118*faf81e80SDamjan Jovanovic         printf64(n);
119*faf81e80SDamjan Jovanovic         ASSERT_TRUE(t_abs64(n) > 0) << "n=2^31 << 8";
120cdf0e10cSrcweir     }
121cdf0e10cSrcweir 
TEST_F(test_t_abs64,test2)122*faf81e80SDamjan Jovanovic     TEST_F(test_t_abs64, test2)
123cdf0e10cSrcweir     {
124cdf0e10cSrcweir         sal_Int64 n;
125cdf0e10cSrcweir         n = 2147483648 << 1;
126*faf81e80SDamjan Jovanovic         printf("Value of n is ");
127*faf81e80SDamjan Jovanovic         printf64(n);
128cdf0e10cSrcweir 
129*faf81e80SDamjan Jovanovic         ASSERT_TRUE(n != 0) << "(2147483648 << 1) is != 0";
130cdf0e10cSrcweir 
131cdf0e10cSrcweir         sal_Int64 n2 = 2147483648 * 2;
132*faf81e80SDamjan Jovanovic         ASSERT_TRUE(n2 != 0) << "2147483648 * 2 is != 0";
133cdf0e10cSrcweir 
134cdf0e10cSrcweir         sal_Int64 n3 = 4294967296LL;
135*faf81e80SDamjan Jovanovic         ASSERT_TRUE(n3 != 0) << "4294967296 is != 0";
136cdf0e10cSrcweir 
137*faf81e80SDamjan Jovanovic         ASSERT_TRUE(n == n2 && n == n3) << "n=2^31 << 1, n2 = 2^31 * 2, n3 = 2^32, all should equal!";
138cdf0e10cSrcweir     }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 
TEST_F(test_t_abs64,test3)141*faf81e80SDamjan Jovanovic     TEST_F(test_t_abs64, test3)
142cdf0e10cSrcweir     {
143cdf0e10cSrcweir         sal_Int64 n = 0;
144*faf81e80SDamjan Jovanovic         ASSERT_TRUE(t_abs64(n) == 0) << "n=0";
145cdf0e10cSrcweir 
146cdf0e10cSrcweir         n = 1;
147*faf81e80SDamjan Jovanovic         ASSERT_TRUE(t_abs64(n) > 0) << "n=1";
148cdf0e10cSrcweir 
149cdf0e10cSrcweir         n = 2147483647;
150*faf81e80SDamjan Jovanovic         ASSERT_TRUE(t_abs64(n) > 0) << "n=2^31 - 1";
151cdf0e10cSrcweir 
152cdf0e10cSrcweir         n = 2147483648;
153*faf81e80SDamjan Jovanovic         ASSERT_TRUE(t_abs64(n) > 0) << "n=2^31";
154cdf0e10cSrcweir     }
155cdf0e10cSrcweir 
TEST_F(test_t_abs64,test4)156*faf81e80SDamjan Jovanovic     TEST_F(test_t_abs64, test4)
157cdf0e10cSrcweir     {
158cdf0e10cSrcweir         sal_Int64 n = 0;
159cdf0e10cSrcweir         n = -1;
160*faf81e80SDamjan Jovanovic         printf("Value of n is -1 : ");
161*faf81e80SDamjan Jovanovic         printf64(n);
162*faf81e80SDamjan Jovanovic         ASSERT_TRUE(t_abs64(n) > 0) << "n=-1";
163cdf0e10cSrcweir 
164cdf0e10cSrcweir         n = -2147483648;
165*faf81e80SDamjan Jovanovic         printf("Value of n is -2^31 : ");
166*faf81e80SDamjan Jovanovic         printf64(n);
167*faf81e80SDamjan Jovanovic         ASSERT_TRUE(t_abs64(n) > 0) << "n=-2^31";
168cdf0e10cSrcweir 
169cdf0e10cSrcweir         n = -8589934592LL;
170*faf81e80SDamjan Jovanovic         printf("Value of n is -2^33 : ");
171*faf81e80SDamjan Jovanovic         printf64(n);
172*faf81e80SDamjan Jovanovic         ASSERT_TRUE(t_abs64(n) > 0) << "n=-2^33";
173cdf0e10cSrcweir     }
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 
176cdf0e10cSrcweir // -----------------------------------------------------------------------------
177*faf81e80SDamjan Jovanovic     class test_printf : public ::testing::Test
178cdf0e10cSrcweir     {
179cdf0e10cSrcweir     };
180cdf0e10cSrcweir 
TEST_F(test_printf,printf_001)181*faf81e80SDamjan Jovanovic     TEST_F(test_printf, printf_001)
182cdf0e10cSrcweir     {
183*faf81e80SDamjan Jovanovic         printf("This is only a test of some helper functions\n");
184cdf0e10cSrcweir         sal_Int32 nValue = 12345;
185*faf81e80SDamjan Jovanovic         printf("a value %d (should be 12345)\n", nValue);
186cdf0e10cSrcweir 
187cdf0e10cSrcweir         rtl::OString sValue("foo bar");
188*faf81e80SDamjan Jovanovic         printf("a String '%s' (should be 'foo bar')\n", sValue.getStr());
189cdf0e10cSrcweir 
190cdf0e10cSrcweir         rtl::OUString suValue(rtl::OUString::createFromAscii("a unicode string"));
191cdf0e10cSrcweir         sValue <<= suValue;
192*faf81e80SDamjan Jovanovic         printf("a String '%s'\n", sValue.getStr());
193cdf0e10cSrcweir     }
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 
196cdf0e10cSrcweir     class StopWatch
197cdf0e10cSrcweir     {
198*faf81e80SDamjan Jovanovic     protected:
199cdf0e10cSrcweir         TimeValue m_aStartTime;
200cdf0e10cSrcweir         TimeValue m_aEndTime;
201cdf0e10cSrcweir         bool m_bStarted;
202cdf0e10cSrcweir     public:
StopWatch()203cdf0e10cSrcweir         StopWatch()
204cdf0e10cSrcweir                 :m_bStarted(false)
205cdf0e10cSrcweir             {
206cdf0e10cSrcweir             }
207cdf0e10cSrcweir 
start()208cdf0e10cSrcweir         void start()
209cdf0e10cSrcweir             {
210cdf0e10cSrcweir                 m_bStarted = true;
211cdf0e10cSrcweir                 osl_getSystemTime(&m_aStartTime);
212cdf0e10cSrcweir             }
stop()213cdf0e10cSrcweir         void stop()
214cdf0e10cSrcweir             {
215cdf0e10cSrcweir                 osl_getSystemTime(&m_aEndTime);
216cdf0e10cSrcweir                 OSL_ENSURE(m_bStarted, "Not Started.");
217cdf0e10cSrcweir                 m_bStarted = false;
218cdf0e10cSrcweir             }
makeTwoDigits(rtl::OString const & _sStr)219cdf0e10cSrcweir         rtl::OString makeTwoDigits(rtl::OString const& _sStr)
220cdf0e10cSrcweir             {
221cdf0e10cSrcweir                 rtl::OString sBack;
222cdf0e10cSrcweir                 if (_sStr.getLength() == 0)
223cdf0e10cSrcweir                 {
224cdf0e10cSrcweir                     sBack = "00";
225cdf0e10cSrcweir                 }
226cdf0e10cSrcweir                 else
227cdf0e10cSrcweir                 {
228cdf0e10cSrcweir                     if (_sStr.getLength() == 1)
229cdf0e10cSrcweir                     {
230cdf0e10cSrcweir                         sBack = "0" + _sStr;
231cdf0e10cSrcweir                     }
232cdf0e10cSrcweir                     else
233cdf0e10cSrcweir                     {
234cdf0e10cSrcweir                         sBack = _sStr;
235cdf0e10cSrcweir                     }
236cdf0e10cSrcweir                 }
237cdf0e10cSrcweir                 return sBack;
238cdf0e10cSrcweir             }
makeThreeDigits(rtl::OString const & _sStr)239cdf0e10cSrcweir         rtl::OString makeThreeDigits(rtl::OString const& _sStr)
240cdf0e10cSrcweir             {
241cdf0e10cSrcweir                 rtl::OString sBack;
242cdf0e10cSrcweir                 if (_sStr.getLength() == 0)
243cdf0e10cSrcweir                 {
244cdf0e10cSrcweir                     sBack = "000";
245cdf0e10cSrcweir                 }
246cdf0e10cSrcweir                 else
247cdf0e10cSrcweir                 {
248cdf0e10cSrcweir                     if (_sStr.getLength() == 1)
249cdf0e10cSrcweir                     {
250cdf0e10cSrcweir                         sBack = "00" + _sStr;
251cdf0e10cSrcweir                     }
252cdf0e10cSrcweir                     else
253cdf0e10cSrcweir                     {
254cdf0e10cSrcweir                         if (_sStr.getLength() == 2)
255cdf0e10cSrcweir                         {
256cdf0e10cSrcweir                             sBack = "0" + _sStr;
257cdf0e10cSrcweir                         }
258cdf0e10cSrcweir                         else
259cdf0e10cSrcweir                         {
260cdf0e10cSrcweir                             sBack = _sStr;
261cdf0e10cSrcweir                         }
262cdf0e10cSrcweir                     }
263cdf0e10cSrcweir                 }
264cdf0e10cSrcweir                 return sBack;
265cdf0e10cSrcweir             }
266cdf0e10cSrcweir 
showTime(const rtl::OString & aWhatStr)267cdf0e10cSrcweir         void  showTime(const rtl::OString & aWhatStr)
268cdf0e10cSrcweir             {
269cdf0e10cSrcweir                 OSL_ENSURE(!m_bStarted, "Not Stopped.");
270cdf0e10cSrcweir 
271cdf0e10cSrcweir                 sal_Int32 nSeconds = m_aEndTime.Seconds - m_aStartTime.Seconds;
272cdf0e10cSrcweir                 sal_Int32 nNanoSec = sal_Int32(m_aEndTime.Nanosec) - sal_Int32(m_aStartTime.Nanosec);
273cdf0e10cSrcweir                 // printf("Seconds: %d Nanosec: %d ", nSeconds, nNanoSec);
274cdf0e10cSrcweir                 if (nNanoSec < 0)
275cdf0e10cSrcweir                 {
276cdf0e10cSrcweir                     nNanoSec = 1000000000 + nNanoSec;
277cdf0e10cSrcweir                     nSeconds--;
278cdf0e10cSrcweir                     // printf(" NEW Seconds: %d Nanosec: %d\n", nSeconds, nNanoSec);
279cdf0e10cSrcweir                 }
280cdf0e10cSrcweir 
281cdf0e10cSrcweir                 rtl::OString aStr = "Time for ";
282cdf0e10cSrcweir                 aStr += aWhatStr;
283cdf0e10cSrcweir                 aStr += " ";
284cdf0e10cSrcweir                 aStr += makeTwoDigits(rtl::OString::valueOf(nSeconds / 3600));
285cdf0e10cSrcweir                 aStr += ":";
286cdf0e10cSrcweir                 aStr += makeTwoDigits(rtl::OString::valueOf((nSeconds % 3600) / 60));
287cdf0e10cSrcweir                 aStr += ":";
288cdf0e10cSrcweir                 aStr += makeTwoDigits(rtl::OString::valueOf((nSeconds % 60)));
289cdf0e10cSrcweir                 aStr += ":";
290cdf0e10cSrcweir                 aStr += makeThreeDigits(rtl::OString::valueOf((nNanoSec % 1000000000) / 1000000));
291cdf0e10cSrcweir                 aStr += ":";
292cdf0e10cSrcweir                 aStr += makeThreeDigits(rtl::OString::valueOf((nNanoSec % 1000000) / 1000));
293cdf0e10cSrcweir                 aStr += ":";
294cdf0e10cSrcweir                 aStr += makeThreeDigits(rtl::OString::valueOf((nNanoSec % 1000)));
295cdf0e10cSrcweir 
296cdf0e10cSrcweir                 printf("%s\n", aStr.getStr());
297cdf0e10cSrcweir                 // cout << aStr.getStr() << endl;
298cdf0e10cSrcweir             }
299cdf0e10cSrcweir 
300cdf0e10cSrcweir     };
301cdf0e10cSrcweir 
isEqualTimeValue(const TimeValue * time1,const TimeValue * time2)302cdf0e10cSrcweir static sal_Bool isEqualTimeValue ( const TimeValue* time1,  const TimeValue* time2)
303cdf0e10cSrcweir {
304cdf0e10cSrcweir 	if( time1->Seconds == time2->Seconds &&
305cdf0e10cSrcweir 		time1->Nanosec == time2->Nanosec)
306cdf0e10cSrcweir 		return sal_True;
307cdf0e10cSrcweir 	else
308cdf0e10cSrcweir 		return sal_False;
309cdf0e10cSrcweir }
310cdf0e10cSrcweir 
isGreaterTimeValue(const TimeValue * time1,const TimeValue * time2)311cdf0e10cSrcweir static sal_Bool isGreaterTimeValue(  const TimeValue* time1,  const TimeValue* time2)
312cdf0e10cSrcweir {
313cdf0e10cSrcweir 	sal_Bool retval= sal_False;
314cdf0e10cSrcweir 	if ( time1->Seconds > time2->Seconds)
315cdf0e10cSrcweir 		retval= sal_True;
316cdf0e10cSrcweir 	else if ( time1->Seconds == time2->Seconds)
317cdf0e10cSrcweir 	{
318cdf0e10cSrcweir 		if( time1->Nanosec > time2->Nanosec)
319cdf0e10cSrcweir 			retval= sal_True;
320cdf0e10cSrcweir 	}
321cdf0e10cSrcweir 	return retval;
322cdf0e10cSrcweir }
323cdf0e10cSrcweir 
isGreaterEqualTimeValue(const TimeValue * time1,const TimeValue * time2)324cdf0e10cSrcweir static sal_Bool isGreaterEqualTimeValue( const TimeValue* time1, const TimeValue* time2)
325cdf0e10cSrcweir {
326cdf0e10cSrcweir 	if( isEqualTimeValue( time1, time2) )
327cdf0e10cSrcweir 		return sal_True;
328cdf0e10cSrcweir 	else if( isGreaterTimeValue( time1, time2))
329cdf0e10cSrcweir 		return sal_True;
330cdf0e10cSrcweir 	else
331cdf0e10cSrcweir 		return sal_False;
332cdf0e10cSrcweir }
333cdf0e10cSrcweir 
isBTimeGreaterATime(TimeValue const & A,TimeValue const & B)334cdf0e10cSrcweir bool isBTimeGreaterATime(TimeValue const& A, TimeValue const& B)
335cdf0e10cSrcweir {
336cdf0e10cSrcweir 	if (B.Seconds > A.Seconds) return true;
337cdf0e10cSrcweir 	if (B.Nanosec > A.Nanosec) return true;
338cdf0e10cSrcweir 
339cdf0e10cSrcweir 	// lower or equal
340cdf0e10cSrcweir 	return false;
341cdf0e10cSrcweir }
342cdf0e10cSrcweir     // -----------------------------------------------------------------------------
343cdf0e10cSrcweir 
344cdf0e10cSrcweir 
345*faf81e80SDamjan Jovanovic     class test_TimeValues : public ::testing::Test
346cdf0e10cSrcweir     {
347cdf0e10cSrcweir     };
348cdf0e10cSrcweir 
TEST_F(test_TimeValues,t_time1)349*faf81e80SDamjan Jovanovic TEST_F(test_TimeValues, t_time1)
350cdf0e10cSrcweir {
351cdf0e10cSrcweir     StopWatch aWatch;
352cdf0e10cSrcweir     aWatch.start();
353cdf0e10cSrcweir     TimeValue aTimeValue={3,0};
354cdf0e10cSrcweir     osl::Thread::wait(aTimeValue);
355cdf0e10cSrcweir     aWatch.stop();
356cdf0e10cSrcweir     aWatch.showTime("Wait for 3 seconds");
357cdf0e10cSrcweir }
358cdf0e10cSrcweir 
TEST_F(test_TimeValues,t_time2)359*faf81e80SDamjan Jovanovic TEST_F(test_TimeValues, t_time2)
360cdf0e10cSrcweir {
361*faf81e80SDamjan Jovanovic     printf("Wait repeats 20 times.\n");
362cdf0e10cSrcweir     int i=0;
363cdf0e10cSrcweir     while(i++<20)
364cdf0e10cSrcweir     {
365cdf0e10cSrcweir         StopWatch aWatch;
366cdf0e10cSrcweir         aWatch.start();
367cdf0e10cSrcweir         TimeValue aTimeValue={0,1000 * 1000 * 500};
368cdf0e10cSrcweir         osl::Thread::wait(aTimeValue);
369cdf0e10cSrcweir         aWatch.stop();
370cdf0e10cSrcweir         aWatch.showTime("wait for 500msec");
371cdf0e10cSrcweir     }
372cdf0e10cSrcweir }
373cdf0e10cSrcweir 
TEST_F(test_TimeValues,t_time3)374*faf81e80SDamjan Jovanovic TEST_F(test_TimeValues, t_time3)
375cdf0e10cSrcweir {
376*faf81e80SDamjan Jovanovic     printf("Wait repeats 100 times.\n");
377cdf0e10cSrcweir     int i=0;
378cdf0e10cSrcweir     while(i++<20)
379cdf0e10cSrcweir     {
380cdf0e10cSrcweir         StopWatch aWatch;
381cdf0e10cSrcweir         aWatch.start();
382cdf0e10cSrcweir         TimeValue aTimeValue={0,1000*1000*100};
383cdf0e10cSrcweir         osl::Thread::wait(aTimeValue);
384cdf0e10cSrcweir         aWatch.stop();
385cdf0e10cSrcweir         aWatch.showTime("wait for 100msec");
386cdf0e10cSrcweir     }
387cdf0e10cSrcweir }
388cdf0e10cSrcweir 
389cdf0e10cSrcweir     // void demoTimeValue()
390cdf0e10cSrcweir     // {
391cdf0e10cSrcweir     //     TimeValue aStartTime, aEndTime;
392cdf0e10cSrcweir     //     osl_getSystemTime(&aStartTime);
393cdf0e10cSrcweir     //     // testSession(xORB, false);
394cdf0e10cSrcweir     //     osl_getSystemTime(&aEndTime);
395cdf0e10cSrcweir     //
396cdf0e10cSrcweir     //     sal_Int32 nSeconds = aEndTime.Seconds - aStartTime.Seconds;
397cdf0e10cSrcweir     //     sal_Int32 nNanoSec = aEndTime.Nanosec - aStartTime.Nanosec;
398cdf0e10cSrcweir     //     if (nNanoSec < 0)
399cdf0e10cSrcweir     //     {
400cdf0e10cSrcweir     //         nNanoSec = 1000000000 - nNanoSec;
401cdf0e10cSrcweir     //         nSeconds++;
402cdf0e10cSrcweir     //     }
403cdf0e10cSrcweir     //
404cdf0e10cSrcweir     //     // cout << "Time: " << nSeconds << ". " << nNanoSec << endl;
405cdf0e10cSrcweir     // }
406cdf0e10cSrcweir 
407cdf0e10cSrcweir 
408cdf0e10cSrcweir } // namespace testOfHelperFunctions
409cdf0e10cSrcweir 
main(int argc,char ** argv)410*faf81e80SDamjan Jovanovic int main(int argc, char **argv)
411*faf81e80SDamjan Jovanovic {
412*faf81e80SDamjan Jovanovic     ::testing::InitGoogleTest(&argc, argv);
413*faf81e80SDamjan Jovanovic     return RUN_ALL_TESTS();
414*faf81e80SDamjan Jovanovic }
415