You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by sc...@apache.org on 2008/12/03 23:49:22 UTC
svn commit: r723112 - in /incubator/etch/trunk:
binding-csharp/runtime/src/test/csharp/Etch/Util/TestAlarmManager.cs
util/src/test/java/etch/util/TestAlarmManager.java
Author: sccomer
Date: Wed Dec 3 14:49:22 2008
New Revision: 723112
URL: http://svn.apache.org/viewvc?rev=723112&view=rev
Log:
do the right math related to relative timing tests.
Modified:
incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Util/TestAlarmManager.cs
incubator/etch/trunk/util/src/test/java/etch/util/TestAlarmManager.java
Modified: incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Util/TestAlarmManager.cs
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Util/TestAlarmManager.cs?rev=723112&r1=723111&r2=723112&view=diff
==============================================================================
--- incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Util/TestAlarmManager.cs (original)
+++ incubator/etch/trunk/binding-csharp/runtime/src/test/csharp/Etch/Util/TestAlarmManager.cs Wed Dec 3 14:49:22 2008
@@ -33,9 +33,6 @@
private readonly Object s2 = new Object();
- //private readonly MyAlarmListener listener = new MyAlarmListener(0);
-
-
[Test]
public void start1()
{
@@ -45,7 +42,6 @@
Assert.IsTrue(am.IsStarted());
}
-
[Test]
[ExpectedException(typeof(Exception))]
public void start2()
@@ -58,7 +54,6 @@
am.Start();
}
-
[Test]
[ExpectedException(typeof(Exception))]
public void stop1()
@@ -69,7 +64,6 @@
am.Stop();
}
-
[Test]
public void stop2()
{
@@ -81,7 +75,6 @@
Assert.IsFalse(am.IsStarted());
}
-
[Test]
public void static1()
{
@@ -105,7 +98,6 @@
AlarmManager.shutdown();
}
-
[Test]
public void listener1()
{
@@ -129,7 +121,6 @@
Assert.AreEqual(1, listener1.delay);
}
-
[Test]
[ExpectedException(typeof(Exception))]
public void add1()
@@ -142,7 +133,6 @@
am.Add(listener, null, Q1);
}
-
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void add2()
@@ -154,7 +144,6 @@
am.Add(null, null, Q1);
}
-
[Test]
[ExpectedException(typeof(ArgumentException))]
public void add3()
@@ -168,7 +157,6 @@
am.Add(listener, null, -1);
}
-
[Test]
public void add4()
{
@@ -188,13 +176,6 @@
Assert.IsNull(listener.state);
}
- private static readonly long t0 = HPTimer.Now();
-
- //public static void Log(string msg)
- //{
- // Console.WriteLine("{0} happened at {1}", msg, (HPTimer.Now()-t0)/1000000.0);
- //}
-
[Test]
public void add5()
{
@@ -212,7 +193,6 @@
Assert.AreSame(s1, listener.state);
}
-
[Test]
public void add6()
{
@@ -234,7 +214,6 @@
Assert.AreSame(s2, listener.state);
}
-
[Test]
public void add7()
{
@@ -253,7 +232,6 @@
Assert.AreSame(s1, listener.state);
}
-
[Test]
[ExpectedException(typeof(Exception))]
public void remove1()
@@ -266,7 +244,6 @@
am.Remove(listener);
}
-
[Test]
public void remove2()
{
@@ -278,7 +255,6 @@
am.Remove(listener);
}
-
[Test]
public void remove3()
{
@@ -300,7 +276,6 @@
Assert.IsNull(listener.state);
}
-
[Test]
public void repeat1()
{
@@ -335,10 +310,10 @@
Console.WriteLine("due4 = {0}", listener.due);
long d4 = listener.due - t0;
- long m1 = d1 / d1;
- long m2 = d2 / d1;
- long m3 = d3 / d1;
- long m4 = d4 / d1;
+ long m1 = (long) Math.Round(d1 / (double)d1);
+ long m2 = (long) Math.Round(d2 / (double)d1);
+ long m3 = (long) Math.Round(d3 / (double)d1);
+ long m4 = (long) Math.Round(d4 / (double)d1);
Console.WriteLine("times {0} {1} {2} {3} {4}", t0, d1, d2, d3, d4);
@@ -348,7 +323,6 @@
Assert.AreEqual(4, m4);
}
-
[Test]
public void repeat2()
{
@@ -383,10 +357,10 @@
Console.WriteLine("due4 = {0}", listener.due);
long d4 = listener.due - t0;
- long m1 = d1 / d1;
- long m2 = d2 / d1;
- long m3 = d3 / d1;
- long m4 = d4 / d1;
+ long m1 = (long) Math.Round(d1 / (double)d1);
+ long m2 = (long) Math.Round(d2 / (double)d1);
+ long m3 = (long) Math.Round(d3 / (double)d1);
+ long m4 = (long) Math.Round(d4 / (double)d1);
Console.WriteLine("times {0} {1} {2} {3} {4}", t0, d1, d2, d3, d4);
@@ -396,7 +370,6 @@
Assert.AreEqual(4, m4);
}
-
[Test]
[ExpectedException(typeof(ThreadInterruptedException))]
public void repeat3()
@@ -446,7 +419,6 @@
public int Wakeup(AlarmManager manager, object state, long due)
{
- //TestAlarmManager.Log("Wakeup");
this.state = state;
this.due = due;
wake.Set(true);
Modified: incubator/etch/trunk/util/src/test/java/etch/util/TestAlarmManager.java
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/util/src/test/java/etch/util/TestAlarmManager.java?rev=723112&r1=723111&r2=723112&view=diff
==============================================================================
--- incubator/etch/trunk/util/src/test/java/etch/util/TestAlarmManager.java (original)
+++ incubator/etch/trunk/util/src/test/java/etch/util/TestAlarmManager.java Wed Dec 3 14:49:22 2008
@@ -300,10 +300,10 @@
System.out.printf( "due4 = %d\n", listener.due );
long d4 = listener.due - t0;
- long m1 = d1/d1;
- long m2 = d2/d1;
- long m3 = d3/d1;
- long m4 = d4/d1;
+ long m1 = Math.round( d1/(double) d1 );
+ long m2 = Math.round( d2/(double) d1 );
+ long m3 = Math.round( d3/(double) d1 );
+ long m4 = Math.round( d4/(double) d1 );
System.out.printf( "times %d %d %d %d %d\n", t0, d1, d2, d3, d4 );
@@ -346,10 +346,10 @@
System.out.printf( "due4 = %d\n", listener.due );
long d4 = listener.due - t0;
- long m1 = d1/d1;
- long m2 = d2/d1;
- long m3 = d3/d1;
- long m4 = d4/d1;
+ long m1 = Math.round( d1/(double) d1 );
+ long m2 = Math.round( d2/(double) d1 );
+ long m3 = Math.round( d3/(double) d1 );
+ long m4 = Math.round( d4/(double) d1 );
System.out.printf( "times %d %d %d %d %d\n", t0, d1, d2, d3, d4 );