mirror of
https://github.com/MengMengCode/VoCat.git
synced 2026-08-13 03:13:43 +08:00
25 lines
512 B
Go
25 lines
512 B
Go
package device
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"vocat/internal/modem"
|
|
)
|
|
|
|
func TestParseRegistrationStatus(t *testing.T) {
|
|
tests := []struct {
|
|
line string
|
|
want int
|
|
}{
|
|
{line: "+CEREG: 0,5", want: 5},
|
|
{line: "+CGREG: 2,1,\"FFFE\",\"06698D06\",7", want: 1},
|
|
{line: "+CREG: 2", want: 2},
|
|
}
|
|
for _, test := range tests {
|
|
got, ok := parseRegistrationStatus(modem.Response{Lines: []string{test.line}})
|
|
if !ok || got != test.want {
|
|
t.Fatalf("parseRegistrationStatus(%q) = %d, %v", test.line, got, ok)
|
|
}
|
|
}
|
|
}
|