mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
f212144310
Some checks are pending
CodeQL / Analyze (go) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
Contributors / contributors (push) Waiting to run
Sync / sync-to-jihulab (push) Waiting to run
Run Tests / tests (macos) (push) Waiting to run
Run Tests / tests (ubuntu) (push) Waiting to run
Run Tests / tests (windows) (push) Waiting to run
27 lines
527 B
Go
27 lines
527 B
Go
package controller
|
|
|
|
import (
|
|
"sync/atomic"
|
|
"testing"
|
|
)
|
|
|
|
func TestWs(t *testing.T) {
|
|
onlineUsers := new(atomic.Uint64)
|
|
onlineUsers.Add(1)
|
|
if onlineUsers.Load() != 1 {
|
|
t.Error("onlineUsers.Add(1) failed")
|
|
}
|
|
onlineUsers.Add(1)
|
|
if onlineUsers.Load() != 2 {
|
|
t.Error("onlineUsers.Add(1) failed")
|
|
}
|
|
onlineUsers.Add(^uint64(0))
|
|
if onlineUsers.Load() != 1 {
|
|
t.Error("onlineUsers.Add(^uint64(0)) failed")
|
|
}
|
|
onlineUsers.Add(^uint64(0))
|
|
if onlineUsers.Load() != 0 {
|
|
t.Error("onlineUsers.Add(^uint64(0)) failed")
|
|
}
|
|
}
|