package flow import "testing" func TestFlowAddGet(t *testing.T) { f := &Flow{} f.Add(100, 200) f.Add(50, 80) send, recv := f.Get() if send != 150 { t.Errorf("SendFlow = %d, want 150", send) } if recv != 280 { t.Errorf("RecvFlow = %d, want 280", recv) } } func TestFlowReset(t *testing.T) { f := &Flow{} f.Add(10, 20) send, recv := f.Reset() if send != 10 || recv != 20 { t.Errorf("Reset 返回 = (%d, %d), want (10, 20)", send, recv) } send, recv = f.Get() if send != 0 || recv != 0 { t.Errorf("Reset 后流量 = (%d, %d), want (0, 0)", send, recv) } }