summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty Brandenberg <monty@lindenlab.com>2013-04-10 17:50:42 +0000
committerMonty Brandenberg <monty@lindenlab.com>2013-04-10 17:50:42 +0000
commit6536fe24049248a84447f1f06570f1be1dd24ef9 (patch)
tree614d9dd987cca3f6d208768e0d3cee2f926cb0e4
parentaabda8f3073928980b26530eac9b05eeb85a2207 (diff)
SH-4089 Unit test work. lltimer basis on Windows is zero which
doesn't allow negative offsetting for unit tests. Had to keep things positive. Could do windows-specific test cases but I'm hoping to dump lltimer from the implementation later.
-rw-r--r--indra/llcommon/tests/lldeadmantimer_test.cpp31
1 files changed, 23 insertions, 8 deletions
diff --git a/indra/llcommon/tests/lldeadmantimer_test.cpp b/indra/llcommon/tests/lldeadmantimer_test.cpp
index 571d43825f..40e354115b 100644
--- a/indra/llcommon/tests/lldeadmantimer_test.cpp
+++ b/indra/llcommon/tests/lldeadmantimer_test.cpp
@@ -76,7 +76,7 @@ void deadmantimer_object_t::test<1>()
}
-// Construct with negative horizon - not useful generally but will be useful in testing
+// Construct with zero horizon - not useful generally but will be useful in testing
template<> template<>
void deadmantimer_object_t::test<2>()
{
@@ -142,9 +142,14 @@ void deadmantimer_object_t::test<6>()
U64 count(U64L(8));
LLDeadmanTimer timer(10.0);
- U64 the_past(LLTimer::getCurrentClockCount() - float_time_to_u64(5.0));
+ // Would like to do subtraction on current time but can't because
+ // the implementation on Windows is zero-based. We wrap around
+ // the backside resulting in a large U64 number.
+
+ U64 the_past(LLTimer::getCurrentClockCount());
+ U64 now(the_past + float_time_to_u64(5.0));
timer.start(the_past);
- ensure_equals("isExpired() returns false with 10.0 horizon time starting 5.0 in past", timer.isExpired(started, stopped, count), false);
+ ensure_equals("isExpired() returns false with 10.0 horizon time starting 5.0 in past", timer.isExpired(started, stopped, count, now), false);
ensure_approximately_equals("t6 - isExpired() does not modify started", started, F64(42.0), 2);
ensure_approximately_equals("t6 - isExpired() does not modify stopped", stopped, F64(97.0), 2);
ensure_equals("t6 - isExpired() does not modify count", count, U64L(8));
@@ -159,9 +164,14 @@ void deadmantimer_object_t::test<7>()
U64 count(U64L(8));
LLDeadmanTimer timer(10.0);
- U64 the_past(LLTimer::getCurrentClockCount() - float_time_to_u64(20.0));
+ // Would like to do subtraction on current time but can't because
+ // the implementation on Windows is zero-based. We wrap around
+ // the backside resulting in a large U64 number.
+
+ U64 the_past(LLTimer::getCurrentClockCount());
+ U64 now(the_past + float_time_to_u64(20.0));
timer.start(the_past);
- ensure_equals("isExpired() returns true with 10.0 horizon time starting 20.0 in past", timer.isExpired(started, stopped, count), true);
+ ensure_equals("isExpired() returns true with 10.0 horizon time starting 20.0 in past", timer.isExpired(started, stopped, count, now), true);
ensure_approximately_equals("starting before horizon still gives equal started / stopped", started, stopped, 8);
}
@@ -174,14 +184,19 @@ void deadmantimer_object_t::test<8>()
U64 count(U64L(8));
LLDeadmanTimer timer(10.0);
- U64 the_past(LLTimer::getCurrentClockCount() - float_time_to_u64(20.0));
+ // Would like to do subtraction on current time but can't because
+ // the implementation on Windows is zero-based. We wrap around
+ // the backside resulting in a large U64 number.
+
+ U64 the_past(LLTimer::getCurrentClockCount());
+ U64 now(the_past + float_time_to_u64(20.0));
timer.start(the_past);
- ensure_equals("t8 - isExpired() returns true with 10.0 horizon time starting 20.0 in past", timer.isExpired(started, stopped, count), true);
+ ensure_equals("t8 - isExpired() returns true with 10.0 horizon time starting 20.0 in past", timer.isExpired(started, stopped, count, now), true);
started = 42.0;
stopped = 97.0;
count = U64L(8);
- ensure_equals("t8 - second isExpired() returns false after true", timer.isExpired(started, stopped, count), false);
+ ensure_equals("t8 - second isExpired() returns false after true", timer.isExpired(started, stopped, count, now), false);
ensure_approximately_equals("t8 - 2nd isExpired() does not modify started", started, F64(42.0), 2);
ensure_approximately_equals("t8 - 2nd isExpired() does not modify stopped", stopped, F64(97.0), 2);
ensure_equals("t8 - 2nd isExpired() does not modify count", count, U64L(8));