aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/csharp/GrpcCoreTests/TimespecTest.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/csharp/GrpcCoreTests/TimespecTest.cs')
-rw-r--r--src/csharp/GrpcCoreTests/TimespecTest.cs31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/csharp/GrpcCoreTests/TimespecTest.cs b/src/csharp/GrpcCoreTests/TimespecTest.cs
index 484bad7ca1..cab59fa5b3 100644
--- a/src/csharp/GrpcCoreTests/TimespecTest.cs
+++ b/src/csharp/GrpcCoreTests/TimespecTest.cs
@@ -1,5 +1,6 @@
using System;
using NUnit.Framework;
+using System.Runtime.InteropServices;
using Google.GRPC.Core.Internal;
namespace Google.GRPC.Core.Internal.Tests
@@ -13,30 +14,42 @@ namespace Google.GRPC.Core.Internal.Tests
}
[Test]
+ public void InfFuture()
+ {
+ var timespec = Timespec.InfFuture;
+ }
+
+ [Test]
+ public void TimespecSizeIsNativeSize()
+ {
+ Assert.AreEqual(Timespec.NativeSize, Marshal.SizeOf(typeof(Timespec)));
+ }
+
+ [Test]
public void Add()
{
- var t = new Timespec { tv_sec = 12345, tv_nsec = 123456789 };
+ var t = new Timespec { tv_sec = new IntPtr(12345), tv_nsec = new IntPtr(123456789) };
var result = t.Add(TimeSpan.FromTicks(TimeSpan.TicksPerSecond * 10));
- Assert.AreEqual(result.tv_sec, 12355);
- Assert.AreEqual(result.tv_nsec, 123456789);
+ Assert.AreEqual(result.tv_sec, new IntPtr(12355));
+ Assert.AreEqual(result.tv_nsec, new IntPtr(123456789));
}
[Test]
public void Add_Nanos()
{
- var t = new Timespec { tv_sec = 12345, tv_nsec = 123456789 };
+ var t = new Timespec { tv_sec = new IntPtr(12345), tv_nsec = new IntPtr(123456789) };
var result = t.Add(TimeSpan.FromTicks(10));
- Assert.AreEqual(result.tv_sec, 12345);
- Assert.AreEqual(result.tv_nsec, 123456789 + 1000);
+ Assert.AreEqual(result.tv_sec, new IntPtr(12345));
+ Assert.AreEqual(result.tv_nsec, new IntPtr(123456789 + 1000));
}
[Test]
public void Add_NanosOverflow()
{
- var t = new Timespec { tv_sec = 12345, tv_nsec = 999999999 };
+ var t = new Timespec { tv_sec = new IntPtr(12345), tv_nsec = new IntPtr(999999999) };
var result = t.Add(TimeSpan.FromTicks(TimeSpan.TicksPerSecond * 10 + 10));
- Assert.AreEqual(result.tv_sec, 12356);
- Assert.AreEqual(result.tv_nsec, 999);
+ Assert.AreEqual(result.tv_sec, new IntPtr(12356));
+ Assert.AreEqual(result.tv_nsec, new IntPtr(999));
}
}
}