author | Raj@rajib-bhattacharjeas-computer.local |
Sun, 25 Mar 2007 13:11:20 -0400 | |
changeset 372 | c242f488ef0b |
parent 367 | be64c89ac945 |
child 675 | a5878de7d71c |
permissions | -rw-r--r-- |
150
663120712cd9
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
144
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2005,2006 INRIA |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* All rights reserved. |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* This program is free software; you can redistribute it and/or modify |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* it under the terms of the GNU General Public License version 2 as |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation; |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* along with this program; if not, write to the Free Software |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
*/ |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
#include "time.h" |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
#include "simulator.h" |
372
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
23 |
#include "ns3/fatal-error.h" |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
|
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
namespace ns3 { |
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
|
372
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
27 |
TimeUnit<1>::TimeUnit(const std::string& s) |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
28 |
{ |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
29 |
std::string::size_type n = s.find_first_not_of("0123456789."); |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
30 |
if (n != std::string::npos) |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
31 |
{ // Found non-numeric |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
32 |
double r = atof(s.substr(0, n).c_str()); |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
33 |
std::string trailer = s.substr(n, std::string::npos); |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
34 |
if (trailer == std::string("s")) |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
35 |
{ |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
36 |
m_data = HighPrecision (r * 1000000000.0); |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
37 |
return; |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
38 |
} |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
39 |
if (trailer == std::string("ms")) |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
40 |
{ |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
41 |
m_data = HighPrecision ((int64_t)(r * 1000000), false); |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
42 |
return; |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
43 |
} |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
44 |
if (trailer == std::string("us")) |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
45 |
{ |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
46 |
m_data = HighPrecision ((int64_t)(r * 1000), false); |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
47 |
return; |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
48 |
} |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
49 |
if (trailer == std::string("ns")) |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
50 |
{ |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
51 |
m_data = HighPrecision ((int64_t)r, false); |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
52 |
return; |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
53 |
} |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
54 |
NS_FATAL_ERROR("Can't Parse Time "<<s); |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
55 |
} |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
56 |
//else |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
57 |
//they didn't provide units, assume seconds |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
58 |
m_data = HighPrecision (atof(s.c_str()) * 1000000000.0); |
c242f488ef0b
Added back corrected version of TimeUnit(string)
Raj@rajib-bhattacharjeas-computer.local
parents:
367
diff
changeset
|
59 |
} |
143
552ff26b4224
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
60 |
double |
339
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
61 |
TimeUnit<1>::GetSeconds (void) const |
36
e622fb7a8262
use ns as internal time and export time as ns.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
25
diff
changeset
|
62 |
{ |
215
462cdd13a69e
optimize Time::Get methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
212
diff
changeset
|
63 |
double ns = GetHighPrecision ().GetDouble (); |
462cdd13a69e
optimize Time::Get methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
212
diff
changeset
|
64 |
return ns/1000000000.0; |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
65 |
} |
156
3b1563e95ea7
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
151
diff
changeset
|
66 |
int32_t |
339
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
67 |
TimeUnit<1>::GetMilliSeconds (void) const |
36
e622fb7a8262
use ns as internal time and export time as ns.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
25
diff
changeset
|
68 |
{ |
215
462cdd13a69e
optimize Time::Get methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
212
diff
changeset
|
69 |
int64_t ns = GetHighPrecision ().GetInteger (); |
462cdd13a69e
optimize Time::Get methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
212
diff
changeset
|
70 |
ns /= 1000000; |
462cdd13a69e
optimize Time::Get methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
212
diff
changeset
|
71 |
return ns; |
143
552ff26b4224
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
72 |
} |
144
f07f6fb0f660
fix Time::ApproximateTo* return type
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
143
diff
changeset
|
73 |
int64_t |
339
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
74 |
TimeUnit<1>::GetMicroSeconds (void) const |
143
552ff26b4224
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
75 |
{ |
215
462cdd13a69e
optimize Time::Get methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
212
diff
changeset
|
76 |
int64_t ns = GetHighPrecision ().GetInteger (); |
462cdd13a69e
optimize Time::Get methods
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
212
diff
changeset
|
77 |
return ns/1000; |
36
e622fb7a8262
use ns as internal time and export time as ns.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
25
diff
changeset
|
78 |
} |
144
f07f6fb0f660
fix Time::ApproximateTo* return type
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
143
diff
changeset
|
79 |
int64_t |
339
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
80 |
TimeUnit<1>::GetNanoSeconds (void) const |
25
9b3bb088c560
first cut at george's ideas on api
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
81 |
{ |
170
9f68cb694f40
implement 128 bit arithmetic with cairo's internal types
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
163
diff
changeset
|
82 |
return GetHighPrecision ().GetInteger (); |
36
e622fb7a8262
use ns as internal time and export time as ns.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
25
diff
changeset
|
83 |
} |
143
552ff26b4224
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
84 |
|
209
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
85 |
std::ostream& |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
86 |
operator<< (std::ostream& os, Time const& time) |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
87 |
{ |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
88 |
os << time.GetNanoSeconds () << "ns"; |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
89 |
return os; |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
90 |
} |
143
552ff26b4224
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
91 |
|
209
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
92 |
Time Seconds (double seconds) |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
93 |
{ |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
94 |
return Time (HighPrecision (seconds * 1000000000.0)); |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
95 |
} |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
96 |
Time MilliSeconds (uint32_t ms) |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
97 |
{ |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
98 |
return Time (HighPrecision (ms * 1000000, false)); |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
99 |
} |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
100 |
Time MicroSeconds (uint64_t us) |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
101 |
{ |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
102 |
return Time (HighPrecision (us * 1000, false)); |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
103 |
} |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
104 |
Time NanoSeconds (uint64_t ns) |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
105 |
{ |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
106 |
return Time (HighPrecision (ns, false)); |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
107 |
} |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
108 |
Time Now (void) |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
109 |
{ |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
110 |
return Time (Simulator::Now ()); |
8b343b9727d7
fix EventId::IsExpired and Simulator::IsExpired, add EventId::IsRunning, add relevant tests, replace Seconds, MilliSeconds, MicroSeconds, and, NanoSeconds classes by functions named similarly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
199
diff
changeset
|
111 |
} |
156
3b1563e95ea7
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
151
diff
changeset
|
112 |
|
339
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
113 |
TimeUnit<0>::TimeUnit (double scalar) |
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
114 |
: m_data (HighPrecision (scalar)) |
143
552ff26b4224
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
115 |
{} |
156
3b1563e95ea7
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
151
diff
changeset
|
116 |
|
158
47af319de4b8
implement Scalar::GetDouble
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
157
diff
changeset
|
117 |
double |
339
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
118 |
TimeUnit<0>::GetDouble (void) const |
158
47af319de4b8
implement Scalar::GetDouble
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
157
diff
changeset
|
119 |
{ |
47af319de4b8
implement Scalar::GetDouble
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
157
diff
changeset
|
120 |
return GetHighPrecision ().GetDouble (); |
47af319de4b8
implement Scalar::GetDouble
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
157
diff
changeset
|
121 |
} |
47af319de4b8
implement Scalar::GetDouble
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
157
diff
changeset
|
122 |
|
156
3b1563e95ea7
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
151
diff
changeset
|
123 |
}; // namespace ns3 |
143
552ff26b4224
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
124 |
|
552ff26b4224
new Time implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
131
diff
changeset
|
125 |
|
157
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
126 |
#ifdef RUN_SELF_TESTS |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
127 |
|
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
128 |
#include "ns3/test.h" |
211
395e8b0d32a9
add a few more tests for the Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
129 |
//#include <iostream> |
157
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
130 |
|
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
131 |
namespace ns3 { |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
132 |
|
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
133 |
class TimeTests : public Test |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
134 |
{ |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
135 |
public: |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
136 |
TimeTests (); |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
137 |
virtual ~TimeTests (); |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
138 |
virtual bool RunTests (void); |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
139 |
}; |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
140 |
|
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
141 |
TimeTests::TimeTests () |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
142 |
: Test ("Time") |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
143 |
{} |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
144 |
TimeTests::~TimeTests () |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
145 |
{} |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
146 |
bool TimeTests::RunTests (void) |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
147 |
{ |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
148 |
bool ok = true; |
176
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
149 |
|
157
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
150 |
Time t0 = Seconds (10.0); |
176
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
151 |
//std::cout << "t0="<<t0.GetSeconds ()<<" (expected 10.0)"<<std::endl; |
157
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
152 |
Time t1 = Seconds (11.0); |
176
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
153 |
//std::cout << "t1="<<t1.GetSeconds ()<<" (expected 11.0)"<<std::endl; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
154 |
t0 = Seconds (1.5); |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
155 |
//std::cout << "t0="<<t0.GetSeconds ()<<" (expected +1.5)"<<std::endl; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
156 |
t0 = Seconds (-1.5); |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
157 |
//std::cout << "t0="<<t0.GetSeconds ()<<" (expected -1.5)"<<std::endl; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
158 |
|
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
159 |
t0 = Seconds (10.0); |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
160 |
t1 = Seconds (11.0); |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
161 |
|
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
162 |
Time t2, t3; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
163 |
|
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
164 |
t2 = t1 - t0; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
165 |
if (!t2.IsStrictlyPositive ()) |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
166 |
{ |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
167 |
ok = false; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
168 |
} |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
169 |
t2 = t1 - t1; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
170 |
if (!t2.IsZero ()) |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
171 |
{ |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
172 |
ok = false; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
173 |
} |
157
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
174 |
t2 = t0 - t1; |
176
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
175 |
if (!t2.IsStrictlyNegative ()) |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
176 |
{ |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
177 |
ok = false; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
178 |
} |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
179 |
|
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
180 |
t2 = t0 - t1; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
181 |
t3 = t2 * t0 / t1; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
182 |
t3 = t0 * t2 / t1; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
183 |
t3 = t0 * t1 / t2; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
184 |
t3 = t0 * (t1 / t2); |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
185 |
t3 = (t0 * t1) / t2; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
186 |
t3 = t0 / t1 * t2; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
187 |
t3 = (t0 / t1) * t2; |
229
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
188 |
TimeInvert ti0; |
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
189 |
ti0 = t0 / (t1 * t2); |
176
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
190 |
t3 = t0 * Scalar (10.0); |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
191 |
t3 = Scalar (10.0) * t0; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
192 |
t3 = Scalar (10.0) * t0 / t2 * t1; |
74494759f122
more tests for Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
170
diff
changeset
|
193 |
t3 = (Scalar (10.0) * t0 ) / t2 * t1; |
157
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
194 |
Scalar s0 = t0 / t1; |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
195 |
Scalar s1; |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
196 |
s1 = t0 * t1 / (t2 * t0); |
229
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
197 |
TimeUnit<0> tu0; |
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
198 |
tu0 = s0; |
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
199 |
TimeUnit<1> tu1; |
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
200 |
tu1 = t0; |
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
201 |
TimeUnit<2> tu2; |
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
202 |
tu2 = t0 * t1; |
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
203 |
TimeUnit<3> tu3; |
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
204 |
tu3 = t0 * tu2; |
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
205 |
TimeUnit<-2> tu4; |
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
206 |
tu4 = t0 / tu3; |
157
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
207 |
|
211
395e8b0d32a9
add a few more tests for the Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
208 |
Time tmp = MilliSeconds (0); |
395e8b0d32a9
add a few more tests for the Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
209 |
if ((tmp != NanoSeconds (0)) || |
395e8b0d32a9
add a few more tests for the Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
210 |
(tmp > NanoSeconds (0)) || |
395e8b0d32a9
add a few more tests for the Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
211 |
(tmp < NanoSeconds (0))) |
395e8b0d32a9
add a few more tests for the Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
212 |
{ |
395e8b0d32a9
add a few more tests for the Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
213 |
ok = false; |
395e8b0d32a9
add a few more tests for the Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
214 |
} |
395e8b0d32a9
add a few more tests for the Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
215 |
|
229
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
216 |
Time t4; |
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
217 |
t4 = Seconds (10.0) * Scalar (1.5); |
211
395e8b0d32a9
add a few more tests for the Time class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
209
diff
changeset
|
218 |
//std::cout << "10.0s * 1.5 = " << t4.GetSeconds () << "s" << std::endl; |
229
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
219 |
Time t5; |
37f1ee32c76f
avoid unused variable compiler warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
215
diff
changeset
|
220 |
t5 = NanoSeconds (10) * Scalar (1.5); |
339
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
221 |
//std::cout << "10ns * 1.5 = " << t5.GetNanoSeconds () << "ns" << |
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
222 |
//std::endl; |
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
223 |
|
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
224 |
double foo = (t1 + t2).GetSeconds (); |
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
225 |
foo += (t4 == t5)? 1 : 0; |
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
226 |
|
0ce0402e419f
make TimeUnit<1>.GetSeconds() work, and similar for scalars. Patch by Gustavo Carneiro.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
229
diff
changeset
|
227 |
foo = (t1/t2).GetDouble (); |
157
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
228 |
|
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
229 |
return ok; |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
230 |
} |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
231 |
|
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
232 |
static TimeTests g_time_tests; |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
233 |
|
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
234 |
}; |
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
235 |
|
19ffb62f521e
add a bunch of tests for Time classes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
156
diff
changeset
|
236 |
#endif /* RUN_SELF_TESTS */ |