From a713a96e69e4e514eeb5421af7cecb8f34d5b991 Mon Sep 17 00:00:00 2001 From: Cameron Moore Date: Fri, 16 Apr 2021 18:07:29 -0500 Subject: [PATCH] Add more newline tests for scanner (#515) --- unmarshaler_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/unmarshaler_test.go b/unmarshaler_test.go index 4cda0de..d2b7512 100644 --- a/unmarshaler_test.go +++ b/unmarshaler_test.go @@ -709,6 +709,42 @@ B = "data"`, } }, }, + { + desc: "windows line endings", + input: "A = 1\r\n\r\nB = 2", + gen: func() test { + doc := map[string]interface{}{} + return test{ + target: &doc, + expected: &map[string]interface{}{ + "A": int64(1), + "B": int64(2), + }, + } + }, + }, + { + desc: "dangling CR", + input: "A = 1\r", + gen: func() test { + doc := map[string]interface{}{} + return test{ + target: &doc, + err: true, + } + }, + }, + { + desc: "missing NL after CR", + input: "A = 1\rB = 2", + gen: func() test { + doc := map[string]interface{}{} + return test{ + target: &doc, + err: true, + } + }, + }, } for _, e := range examples {