github.com/cnotch/ipchub@v1.1.0/stats/flow_test.go (about)

     1  // Copyright (c) 2019,CAOHONGJU 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 stats
     6  
     7  import (
     8  	"testing"
     9  )
    10  
    11  func TestFlow(t *testing.T) {
    12  	totalFlow := NewFlow()
    13  	sub1 := NewChildFlow(totalFlow)
    14  	sub2 := NewChildFlow(totalFlow)
    15  
    16  	t.Run("", func(t *testing.T) {
    17  		sub1.AddIn(100)
    18  		sample := sub1.GetSample()
    19  		if sample.InBytes != 100 {
    20  			t.Error("InBytes not is 100")
    21  		}
    22  		sub2.AddIn(200)
    23  		sample = totalFlow.GetSample()
    24  		if sample.InBytes != 300 {
    25  			t.Error("InBytes not is 300")
    26  		}
    27  	})
    28  
    29  }