Example #1
0
        public virtual void test_standard_expressionPrefixNumbers()
        {
            StringBuilder buf = new StringBuilder();

            CsvOutput.standard(buf, "\n").writeLine(Arrays.asList("+8", "-7", "+8-7", "-7+8", "NaN", "-Infinity"));
            assertEquals(buf.ToString(), "+8,-7,+8-7,-7+8,NaN,-Infinity\n");
        }
Example #2
0
        public virtual void test_standard_writeLines_tab_separated()
        {
            StringBuilder buf = new StringBuilder();

            CsvOutput.standard(buf, "\n", LINE_ITEM_SEP_TAB).writeLine(Arrays.asList("a", "1,000"));
            assertEquals(buf.ToString(), "a\t\"1,000\"\n");
        }
Example #3
0
        public virtual void test_standard_expressionPrefix()
        {
            StringBuilder buf = new StringBuilder();

            CsvOutput.standard(buf, "\n").writeLine(Arrays.asList("=cmd", "+cmd", "-cmd", "@cmd", ""));
            assertEquals(buf.ToString(), "\"=cmd\",+cmd,-cmd,\"@cmd\",\n");
        }
Example #4
0
        //-------------------------------------------------------------------------
        public virtual void test_writeCell()
        {
            StringBuilder buf = new StringBuilder();

            CsvOutput.standard(buf, "\n").writeCell("a").writeCell("x").writeNewLine().writeCell("b", true).writeCell("y", true).writeNewLine();
            assertEquals(buf.ToString(), "a,x\n\"b\",\"y\"\n");
        }
Example #5
0
        public virtual void test_standard_writeLine_selectiveQuote()
        {
            StringBuilder buf = new StringBuilder();

            CsvOutput.standard(buf, "\n", LINE_ITEM_SEP_COMMA).writeLine(Arrays.asList("a", "1,000"));
            assertEquals(buf.ToString(), "a,\"1,000\"\n");
        }
Example #6
0
        public virtual void test_safe_expressionPrefixNumbers()
        {
            StringBuilder buf = new StringBuilder();

            CsvOutput.safe(buf, "\n", LINE_ITEM_SEP_COMMA).writeLine(Arrays.asList("+8", "-7", "+8-7", "-7+8", "NaN", "-Infinity"));
            assertEquals(buf.ToString(), "+8,-7,=\"+8-7\",=\"-7+8\",NaN,=\"-Infinity\"\n");
        }
Example #7
0
        public virtual void test_safe_expressionPrefix()
        {
            StringBuilder buf = new StringBuilder();

            CsvOutput.safe(buf, "\n").writeLine(Arrays.asList("=cmd", "+cmd", "-cmd", "@cmd"));
            assertEquals(buf.ToString(), "=\"=cmd\",=\"+cmd\",=\"-cmd\",=\"@cmd\"\n");
        }
Example #8
0
        public virtual void test_standard_writeLines_systemNewLine()
        {
            IList <IList <string> > rows = Arrays.asList(Arrays.asList("a", "x"), Arrays.asList("b", "y"));
            StringBuilder           buf  = new StringBuilder();

            CsvOutput.standard(buf).writeLines(rows, false);
            assertEquals(buf.ToString(), "a,x" + LINE_SEP + "b,y" + LINE_SEP);
        }
Example #9
0
        public virtual void test_standard_writeLines_selectiveQuote_trimmable()
        {
            IList <IList <string> > rows = Arrays.asList(Arrays.asList("a", " x"), Arrays.asList("b ", "y"));
            StringBuilder           buf  = new StringBuilder();

            CsvOutput.standard(buf, "\n", LINE_ITEM_SEP_COMMA).writeLines(rows, false);
            assertEquals(buf.ToString(), "a,\" x\"\n\"b \",y\n");
        }
Example #10
0
        //-------------------------------------------------------------------------
        public virtual void test_standard_writeLines_alwaysQuote()
        {
            IList <IList <string> > rows = Arrays.asList(Arrays.asList("a", "x"), Arrays.asList("b", "y"));
            StringBuilder           buf  = new StringBuilder();

            CsvOutput.standard(buf, "\n").writeLines(rows, true);
            assertEquals(buf.ToString(), "\"a\",\"x\"\n\"b\",\"y\"\n");
        }
Example #11
0
        public virtual void test_mixed()
        {
            IList <string> row = Arrays.asList("x", "y");
            StringBuilder  buf = new StringBuilder();

            CsvOutput.standard(buf, "\n").writeCell("a").writeCell("b").writeLine(row);
            assertEquals(buf.ToString(), "a,b,x,y\n");
        }
Example #12
0
        //-------------------------------------------------------------------------
        public virtual void test_exception()
        {
            Appendable throwingAppendable = new AppendableAnonymousInnerClass(this);

            CsvOutput output = CsvOutput.standard(throwingAppendable, "\n");

            assertThrows(typeof(UncheckedIOException), () => output.writeCell("a"));
            assertThrows(typeof(UncheckedIOException), () => output.writeNewLine());
        }