github.com/sandwich-go/boost@v1.3.29/xsync/atomic_test.go (about)

     1  package xsync
     2  
     3  import (
     4  	. "github.com/smartystreets/goconvey/convey"
     5  	"testing"
     6  )
     7  
     8  func TestAtomicString(t *testing.T) {
     9  	s := NewAtomicString("")
    10  	if s.Get() != "" {
    11  		t.Errorf("want empty, got %s", s.Get())
    12  	}
    13  	s.Set("a")
    14  	if s.Get() != "a" {
    15  		t.Errorf("want a, got %s", s.Get())
    16  	}
    17  }
    18  
    19  func TestAtomicBool(t *testing.T) {
    20  	Convey("atomic bool", t, func() {
    21  		var b AtomicBool
    22  		So(b.Get(), ShouldBeFalse)
    23  		b.Set(true)
    24  		So(b.Get(), ShouldBeTrue)
    25  		b.Set(false)
    26  		So(b.Get(), ShouldBeFalse)
    27  	})
    28  }