MCPcopy
hub / github.com/nats-io/nats.go / TestParserOK

Function TestParserOK

nats_test.go:583–607  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

581}
582
583func TestParserOK(t *testing.T) {
584 c := &Conn{}
585 c.ps = &parseState{}
586
587 if c.ps.state != OP_START {
588 t.Fatalf("Expected OP_START vs %d\n", c.ps.state)
589 }
590 errProto := []byte("+OKay\r\n")
591 err := c.parse(errProto[:1])
592 if err != nil || c.ps.state != OP_PLUS {
593 t.Fatalf("Unexpected: %d : %v\n", c.ps.state, err)
594 }
595 err = c.parse(errProto[1:2])
596 if err != nil || c.ps.state != OP_PLUS_O {
597 t.Fatalf("Unexpected: %d : %v\n", c.ps.state, err)
598 }
599 err = c.parse(errProto[2:3])
600 if err != nil || c.ps.state != OP_PLUS_OK {
601 t.Fatalf("Unexpected: %d : %v\n", c.ps.state, err)
602 }
603 err = c.parse(errProto[3:])
604 if err != nil || c.ps.state != OP_START {
605 t.Fatalf("Unexpected: %d : %v\n", c.ps.state, err)
606 }
607}
608
609func TestParserShouldFail(t *testing.T) {
610 c := &Conn{}

Callers

nothing calls this directly

Calls 2

parseMethod · 0.95
FatalfMethod · 0.80

Tested by

no test coverage detected