diff options
author | Nayeem Rahman <muhammed.9939@gmail.com> | 2020-03-15 12:03:25 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-15 13:03:25 +0100 |
commit | 6471d4cfabf27c0f5e7b340568aa88712d270541 (patch) | |
tree | 29ca29b6baeb4715a0b7eeb24aeaf8b0ed112e97 /std/encoding/csv_test.ts | |
parent | 2f4be6e9441c7d5b0afd0d37dccd48d3057bcd3f (diff) |
refactor(std): Uncomment disabled tests, use skip option (#4378)
Diffstat (limited to 'std/encoding/csv_test.ts')
-rw-r--r-- | std/encoding/csv_test.ts | 259 |
1 files changed, 138 insertions, 121 deletions
diff --git a/std/encoding/csv_test.ts b/std/encoding/csv_test.ts index efea353e1..2862d57e3 100644 --- a/std/encoding/csv_test.ts +++ b/std/encoding/csv_test.ts @@ -29,21 +29,22 @@ const testCases = [ Input: "a,b\rc,d\r\n", Output: [["a", "b\rc", "d"]] }, - // { - // Name: "RFC4180test", - // Input: `#field1,field2,field3 - // "aaa","bbb","ccc" - // "a,a","bbb","ccc" - // zzz,yyy,xxx`, - // UseFieldsPerRecord: true, - // FieldsPerRecord: 0, - // Output: [ - // ["#field1", "field2", "field3"], - // ["aaa", "bbb", "ccc"], - // ["a,a", `bbb`, "ccc"], - // ["zzz", "yyy", "xxx"] - // ] - // }, + { + Name: "RFC4180test", + Input: `#field1,field2,field3 +"aaa","bbb","ccc" +"a,a","bbb","ccc" +zzz,yyy,xxx`, + UseFieldsPerRecord: true, + FieldsPerRecord: 0, + Output: [ + ["#field1", "field2", "field3"], + ["aaa", "bbb", "ccc"], + ["a,a", `bbb`, "ccc"], + ["zzz", "yyy", "xxx"] + ], + skip: true + }, { Name: "NoEOLTest", Input: "a,b,c", @@ -55,14 +56,15 @@ const testCases = [ Output: [["a", "b", "c"]], Comma: ";" }, - // { - // Name: "MultiLine", - // Input: `"two - // line","one line","three - // line - // field"`, - // Output: [["two\nline"], ["one line"], ["three\nline\nfield"]] - // }, + { + Name: "MultiLine", + Input: `"two +line","one line","three +line +field"`, + Output: [["two\nline"], ["one line"], ["three\nline\nfield"]], + skip: true + }, { Name: "BlankLine", Input: "a,b,c\n\nd,e,f\n\n", @@ -256,54 +258,62 @@ x,,, ], ReuseRecord: true }, - // { - // Name: "StartLine1", // Issue 19019 - // Input: 'a,"b\nc"d,e', - // Error: true - // // Error: &ParseError{StartLine: 1, Line: 2, Column: 1, Err: ErrQuote}, - // }, - // { - // Name: "StartLine2", - // Input: 'a,b\n"d\n\n,e', - // Error: true - // // Error: &ParseError{StartLine: 2, Line: 5, Column: 0, Err: ErrQuote}, - // }, - // { - // Name: "CRLFInQuotedField", // Issue 21201 - // Input: 'A,"Hello\r\nHi",B\r\n', - // Output: [["A", "Hello\nHi", "B"]] - // }, + { + Name: "StartLine1", // Issue 19019 + Input: 'a,"b\nc"d,e', + Error: true, + // Error: &ParseError{StartLine: 1, Line: 2, Column: 1, Err: ErrQuote}, + skip: true + }, + { + Name: "StartLine2", + Input: 'a,b\n"d\n\n,e', + Error: true, + // Error: &ParseError{StartLine: 2, Line: 5, Column: 0, Err: ErrQuote}, + skip: true + }, + { + Name: "CRLFInQuotedField", // Issue 21201 + Input: 'A,"Hello\r\nHi",B\r\n', + Output: [["A", "Hello\nHi", "B"]], + skip: true + }, { Name: "BinaryBlobField", // Issue 19410 Input: "x09\x41\xb4\x1c,aktau", Output: [["x09A\xb4\x1c", "aktau"]] }, - // { - // Name: "TrailingCR", - // Input: "field1,field2\r", - // Output: [["field1", "field2"]] - // }, - // { - // Name: "QuotedTrailingCR", - // Input: '"field"\r', - // Output: [['"field"']] - // }, - // { - // Name: "QuotedTrailingCRCR", - // Input: '"field"\r\r', - // Error: true, - // // Error: &ParseError{StartLine: 1, Line: 1, Column: 6, Err: ErrQuote}, - // }, - // { - // Name: "FieldCR", - // Input: "field\rfield\r", - // Output: [["field\rfield"]] - // }, - // { - // Name: "FieldCRCR", - // Input: "field\r\rfield\r\r", - // Output: [["field\r\rfield\r"]] - // }, + { + Name: "TrailingCR", + Input: "field1,field2\r", + Output: [["field1", "field2"]], + skip: true + }, + { + Name: "QuotedTrailingCR", + Input: '"field"\r', + Output: [['"field"']], + skip: true + }, + { + Name: "QuotedTrailingCRCR", + Input: '"field"\r\r', + Error: true, + // Error: &ParseError{StartLine: 1, Line: 1, Column: 6, Err: ErrQuote}, + skip: true + }, + { + Name: "FieldCR", + Input: "field\rfield\r", + Output: [["field\rfield"]], + skip: true + }, + { + Name: "FieldCRCR", + Input: "field\r\rfield\r\r", + Output: [["field\r\rfield\r"]], + skip: true + }, { Name: "FieldCRCRLF", Input: "field\r\r\nfield\r\r\n", @@ -314,20 +324,22 @@ x,,, Input: "field\r\r\n\rfield\r\r\n\r", Output: [["field\r"], ["\rfield\r"]] }, - // { - // Name: "FieldCRCRLFCRCR", - // Input: "field\r\r\n\r\rfield\r\r\n\r\r", - // Output: [["field\r"], ["\r\rfield\r"], ["\r"]] - // }, - // { - // Name: "MultiFieldCRCRLFCRCR", - // Input: "field1,field2\r\r\n\r\rfield1,field2\r\r\n\r\r,", - // Output: [ - // ["field1", "field2\r"], - // ["\r\rfield1", "field2\r"], - // ["\r\r", ""] - // ] - // }, + { + Name: "FieldCRCRLFCRCR", + Input: "field\r\r\n\r\rfield\r\r\n\r\r", + Output: [["field\r"], ["\r\rfield\r"], ["\r"]], + skip: true + }, + { + Name: "MultiFieldCRCRLFCRCR", + Input: "field1,field2\r\r\n\r\rfield1,field2\r\r\n\r\r,", + Output: [ + ["field1", "field2\r"], + ["\r\rfield1", "field2\r"], + ["\r\r", ""] + ], + skip: true + }, { Name: "NonASCIICommaAndComment", Input: "a£b,c£ \td,e\n€ comment\n", @@ -358,30 +370,30 @@ x,,, Output: [["λ"], ["λ"], ["λ"]], Comment: "θ" }, - // { - // Name: "QuotedFieldMultipleLF", - // Input: '"\n\n\n\n"', - // Output: [["\n\n\n\n"]] - // }, - // { - // Name: "MultipleCRLF", - // Input: "\r\n\r\n\r\n\r\n" - // }, + { + Name: "QuotedFieldMultipleLF", + Input: '"\n\n\n\n"', + Output: [["\n\n\n\n"]], + skip: true + }, + { + Name: "MultipleCRLF", + Input: "\r\n\r\n\r\n\r\n", + skip: true + }, /** * The implementation may read each line in several chunks if * it doesn't fit entirely. * in the read buffer, so we should test the code to handle that condition. */ - // { - // Name: "HugeLines", - // Input: - // strings.Repeat("#ignore\n", 10000) + - // strings.Repeat("@", 5000) + - // "," + - // strings.Repeat("*", 5000), - // Output: [[strings.Repeat("@", 5000), strings.Repeat("*", 5000)]], - // Comment: "#" - // }, + { + Name: "HugeLines", + Input: + "#ignore\n".repeat(10000) + "@".repeat(5000) + "," + "*".repeat(5000), + Output: [["@".repeat(5000), "*".repeat(5000)]], + Comment: "#", + skip: true + }, { Name: "QuoteWithTrailingCRLF", Input: '"foo"bar"\r\n', @@ -394,28 +406,32 @@ x,,, Output: [[`foo"bar`]], LazyQuotes: true }, - // { - // Name: "DoubleQuoteWithTrailingCRLF", - // Input: '"foo""bar"\r\n', - // Output: [[`foo"bar`]] - // }, - // { - // Name: "EvenQuotes", - // Input: `""""""""`, - // Output: [[`"""`]] - // }, - // { - // Name: "OddQuotes", - // Input: `"""""""`, - // Error: true - // // Error:" &ParseError{StartLine: 1, Line: 1, Column: 7, Err: ErrQuote}", - // }, - // { - // Name: "LazyOddQuotes", - // Input: `"""""""`, - // Output: [[`"""`]], - // LazyQuotes: true - // }, + { + Name: "DoubleQuoteWithTrailingCRLF", + Input: '"foo""bar"\r\n', + Output: [[`foo"bar`]], + skip: true + }, + { + Name: "EvenQuotes", + Input: `""""""""`, + Output: [[`"""`]], + skip: true + }, + { + Name: "OddQuotes", + Input: `"""""""`, + Error: true, + // Error:" &ParseError{StartLine: 1, Line: 1, Column: 7, Err: ErrQuote}", + skip: true + }, + { + Name: "LazyOddQuotes", + Input: `"""""""`, + Output: [[`"""`]], + LazyQuotes: true, + skip: true + }, { Name: "BadComma1", Comma: "\n", @@ -450,6 +466,7 @@ x,,, ]; for (const t of testCases) { Deno.test({ + skip: !!t.skip, name: `[CSV] ${t.Name}`, async fn(): Promise<void> { let comma = ","; |