From 5870fb0c99371982fa77dd394e6d51fcb62a372c Mon Sep 17 00:00:00 2001 From: David Hamilton Date: Thu, 12 Dec 2019 02:00:25 +1300 Subject: [PATCH] Added tests for lastSent and lastReceived get/set Validate the new behaviour when these atomic vars have not been set yet. --- candidate_test.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/candidate_test.go b/candidate_test.go index 16c9900..e3d41f6 100644 --- a/candidate_test.go +++ b/candidate_test.go @@ -1,6 +1,11 @@ package ice -import "testing" +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" +) func TestCandidatePriority(t *testing.T) { for _, test := range []struct { @@ -49,3 +54,19 @@ func TestCandidatePriority(t *testing.T) { } } } + +func TestCandidateLastSent(t *testing.T) { + candidate := candidateBase{} + assert.Equal(t, candidate.LastSent(), time.Time{}) + now := time.Now() + candidate.setLastSent(now) + assert.Equal(t, candidate.LastSent(), now) +} + +func TestCandidateLastReceived(t *testing.T) { + candidate := candidateBase{} + assert.Equal(t, candidate.LastReceived(), time.Time{}) + now := time.Now() + candidate.setLastReceived(now) + assert.Equal(t, candidate.LastReceived(), now) +}