github.com/ks888/tgo@v0.0.0-20190130135156-80bf89407292/tracer/tracingpoints_test.go (about)

     1  package tracer
     2  
     3  import "testing"
     4  
     5  func TestTracingGoRoutines_AddAndRemove(t *testing.T) {
     6  	list := tracingGoRoutines{}
     7  	var id int64 = 1
     8  	list.Add(id)
     9  	if !list.Tracing(id) {
    10  		t.Errorf("go routine id %d is not traced", id)
    11  	}
    12  
    13  	list.Remove(1)
    14  	if list.Tracing(id) {
    15  		t.Errorf("go routine id %d is still traced", id)
    16  	}
    17  }
    18  
    19  func TestTracingGoRoutines_MultipleAddAndRemove(t *testing.T) {
    20  	list := tracingGoRoutines{}
    21  	var id int64 = 1
    22  	list.Add(id)
    23  	if !list.Tracing(id) {
    24  		t.Errorf("go routine id %d is not traced", id)
    25  	}
    26  	list.Add(id)
    27  
    28  	list.Remove(1)
    29  	if !list.Tracing(id) {
    30  		t.Errorf("go routine id %d is not traced", id)
    31  	}
    32  
    33  	list.Remove(1)
    34  	if list.Tracing(id) {
    35  		t.Errorf("go routine id %d is still traced", id)
    36  	}
    37  }