MCPcopy Create free account
hub / github.com/segmentio/encoding / TestDecodeLines

Function TestDecodeLines

json/json_test.go:761–911  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

759}
760
761func TestDecodeLines(t *testing.T) {
762 tests := []struct {
763 desc string
764 reader io.Reader
765 expectCount int
766 }{
767 // simple
768
769 {
770 desc: "bare object",
771 reader: strings.NewReader("{\"Good\":true}"),
772 expectCount: 1,
773 },
774 {
775 desc: "multiple objects on one line",
776 reader: strings.NewReader("{\"Good\":true}{\"Good\":true}\n"),
777 expectCount: 2,
778 },
779 {
780 desc: "object spanning multiple lines",
781 reader: strings.NewReader("{\n\"Good\":true\n}\n"),
782 expectCount: 1,
783 },
784
785 // whitespace handling
786
787 {
788 desc: "trailing newline",
789 reader: strings.NewReader("{\"Good\":true}\n{\"Good\":true}\n"),
790 expectCount: 2,
791 },
792 {
793 desc: "multiple trailing newlines",
794 reader: strings.NewReader("{\"Good\":true}\n{\"Good\":true}\n\n"),
795 expectCount: 2,
796 },
797 {
798 desc: "blank lines",
799 reader: strings.NewReader("{\"Good\":true}\n\n{\"Good\":true}"),
800 expectCount: 2,
801 },
802 {
803 desc: "no trailing newline",
804 reader: strings.NewReader("{\"Good\":true}\n{\"Good\":true}"),
805 expectCount: 2,
806 },
807 {
808 desc: "leading whitespace",
809 reader: strings.NewReader(" {\"Good\":true}\n\t{\"Good\":true}"),
810 expectCount: 2,
811 },
812
813 // multiple reads
814
815 {
816 desc: "one object, multiple reads",
817 reader: io.MultiReader(
818 strings.NewReader("{"),

Callers

nothing calls this directly

Calls 4

DecodeMethod · 0.95
NewDecoderFunction · 0.70
NewReaderMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…