github.com/ericwq/aprilsh@v0.0.0-20240517091432-958bc568daa0/network/state_test.go (about) 1 // Copyright 2022~2023 wangqi. All rights reserved. 2 // Use of this source code is governed by a MIT-style 3 // license that can be found in the LICENSE file. 4 5 package network 6 7 import ( 8 "testing" 9 "time" 10 11 "github.com/ericwq/aprilsh/statesync" 12 ) 13 14 func TestTimestampedStaeGetxxx(t *testing.T) { 15 blank := &statesync.UserStream{} 16 17 now := time.Now().UnixMilli() 18 expectNum := uint64(4) 19 s := TimestampedState[*statesync.UserStream]{state: blank, num: expectNum, timestamp: now} 20 21 if s.GetTimestamp() != now { 22 t.Errorf("#test GetTimestamp() expect %d, got %d\n", now, s.GetTimestamp()) 23 } 24 25 if s.GetState() != blank { 26 t.Errorf("#test GetState() expect %v, got %v\n", blank, s.GetState()) 27 } 28 }