Add soc push event every 10% charge progress (#2337)
This commit is contained in:
parent
9bb68bd819
commit
479377f0d4
6 changed files with 86 additions and 3 deletions
33
core/progress_test.go
Normal file
33
core/progress_test.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestProgress(t *testing.T) {
|
||||
p := NewProgress(0, 10)
|
||||
|
||||
tc := []struct {
|
||||
value float64
|
||||
res bool
|
||||
}{
|
||||
{-1, false},
|
||||
{0, true},
|
||||
{1, false},
|
||||
{5, false},
|
||||
{10, true},
|
||||
{15, false},
|
||||
{25, true},
|
||||
{30, true},
|
||||
{60, true},
|
||||
{65, false},
|
||||
{70, true},
|
||||
}
|
||||
|
||||
for _, tc := range tc {
|
||||
require.Equal(t, tc.res, p.NextStep(tc.value), fmt.Sprintf("%.0f%%", tc.value))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue