const_test.go 1001 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package mhayaActor
  2. import (
  3. "fmt"
  4. "strings"
  5. "sync/atomic"
  6. "testing"
  7. )
  8. type testActor struct {
  9. Base
  10. }
  11. func TestActorSystem(t *testing.T) {
  12. actorSystem := NewSystem()
  13. ta := &testActor{}
  14. actorSystem.CreateActor("aaa", ta)
  15. fmt.Println(ta.Base.path)
  16. }
  17. func Test1111(t *testing.T) {
  18. a := [...]int{1, 2, 3}
  19. square(&a)
  20. fmt.Println(a)
  21. }
  22. func square(arr *[3]int) {
  23. for i, num := range *arr {
  24. (*arr)[i] = num * num
  25. }
  26. }
  27. func TestActorIDValidate1(t *testing.T) {
  28. s := "/aaa/bbb"
  29. str := "-"
  30. index := strings.Index(s, str)
  31. fmt.Println(index)
  32. }
  33. func TestActorIDValidate(t *testing.T) {
  34. idList := []string{
  35. "",
  36. " ",
  37. "@",
  38. "/",
  39. "a/1",
  40. "a",
  41. "A",
  42. "1",
  43. "aaaa1111",
  44. "1111aaaaa",
  45. "a.b.c",
  46. }
  47. checkActorID := func(id string) bool {
  48. return len(id) > 0
  49. }
  50. for _, s := range idList {
  51. fmt.Println(s, "->", checkActorID(s))
  52. }
  53. }
  54. func TestUint32(t *testing.T) {
  55. var id uint32 = 4294967290
  56. for i := 0; i < 20; i++ {
  57. atomic.AddUint32(&id, 1)
  58. fmt.Println(id)
  59. }
  60. }