The golang mock package has been archived and is now maintained by uber. > Update, June 2023: This repo and tool are no longer maintained. Please > see go.uber.org/mock for a maintained fork instead. [1] https://github.com/golang/mock [2] https://github.com/uber-go/mock
23 lines
364 B
Go
23 lines
364 B
Go
package wrapper
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"go.uber.org/mock/gomock"
|
|
)
|
|
|
|
func TestProxyChargeMeter(t *testing.T) {
|
|
ctrl := gomock.NewController(t)
|
|
defer ctrl.Finish()
|
|
|
|
tc := []float64{600, 1000, 2000}
|
|
m := ChargeMeter{}
|
|
|
|
for _, f := range tc {
|
|
m.SetPower(f)
|
|
|
|
if p, err := m.CurrentPower(); p != f || err != nil {
|
|
t.Errorf("power: %.1f %v", p, err)
|
|
}
|
|
}
|
|
}
|