Пример #1
0
        public void SplitWithImbalancedReturnsException()
        {
            var opts = new CSVParseOpts {
                EnclosureDelimiter = '|', AreFieldsEnclosed = true, TrimOutside = false, TrimInEnclosure = false
            };

            string[] output = MHString.CSVSplit(TESTSTR_BAD1, opts);
        }
Пример #2
0
        public void SplitWithEnclosureNoTrimAndThreeEmptyFields2Succeeds()
        {
            var opts = new CSVParseOpts {
                EnclosureDelimiter = '|', AreFieldsEnclosed = true, TrimOutside = false, TrimInEnclosure = false
            };

            string[] output = MHString.CSVSplit(TESTSTR8, opts);
            Assert.AreEqual(3, output.Length);
            Assert.AreEqual(2, output.GetUpperBound(0));
        }
Пример #3
0
        public void SplitNoEnclosureTrimOutsideAndOneFieldSucceeds()
        {
            var opts = new CSVParseOpts {
                EnclosureDelimiter = '|', AreFieldsEnclosed = false, TrimOutside = true, TrimInEnclosure = false
            };

            string[] output = MHString.CSVSplit(TESTSTR12, opts);
            Assert.AreEqual(1, output.Length);
            Assert.AreEqual(0, output.GetUpperBound(0));
            Assert.AreEqual("Field1", output[0]);
        }
Пример #4
0
        public void SplitNoEnclosureWithTrimWithEmptySucceeds()
        {
            var opts = new CSVParseOpts {
                AreFieldsEnclosed = false, TrimOutside = true
            };

            opts.AreFieldsEnclosed = false;
            string[] output = MHString.CSVSplit(string.Empty, opts);
            Assert.AreEqual(0, output.Length, "Length of array not zero");
            Assert.AreEqual(-1, output.GetUpperBound(0), "Number of array elements not zero");
        }
Пример #5
0
        public void SplitWithEnclosureTrimOutsideAndInsideAndThreeFieldsSucceeds()
        {
            var opts = new CSVParseOpts {
                EnclosureDelimiter = '|', AreFieldsEnclosed = true, TrimOutside = true, TrimInEnclosure = true
            };

            string[] output = MHString.CSVSplit(TESTSTR11, opts);
            Assert.AreEqual(3, output.Length);
            Assert.AreEqual(2, output.GetUpperBound(0));
            Assert.AreEqual("Field1", output[0]);
            Assert.AreEqual("Field2", output[1]);
            Assert.AreEqual("Field3", output[2]);
        }
Пример #6
0
        public void SplitWithDoubleEnclosureWithFullTrimSucceeds()
        {
            var opts = new CSVParseOpts {
                TrimOutside = true, AreFieldsEnclosed = true, EnclosureDelimiter = '|', TrimInEnclosure = true
            };

            string[] output = MHString.CSVSplit(TESTSTR16, opts);
            Assert.AreEqual(2, output.GetUpperBound(0));
            Assert.AreEqual(3, output.Length);
            Assert.AreEqual("my|pipes", output[0]);
            Assert.AreEqual("are", output[1]);
            Assert.AreEqual("strong", output[2]);
        }
Пример #7
0
        public void SplitWithEnclosureNoTrimSucceeds()
        {
            var opts = new CSVParseOpts {
                EnclosureDelimiter = '|', AreFieldsEnclosed = true, TrimOutside = false, TrimInEnclosure = false
            };

            string[] output = MHString.CSVSplit(TESTSTR3, opts);
            Assert.AreEqual(4, output.Length);
            Assert.AreEqual(3, output.GetUpperBound(0));
            Assert.AreEqual(String.Empty, output[0]);
            Assert.AreEqual("2", output[1]);
            Assert.AreEqual("3", output[2]);
            Assert.AreEqual(string.Empty, output[3]);
        }
Пример #8
0
        public void SplitNoEnclosureNoTrimSucceeds()
        {
            var opts = new CSVParseOpts {
                AreFieldsEnclosed = false, TrimOutside = false
            };

            string[] output = MHString.CSVSplit(TESTSTR1, opts);
            Assert.AreEqual(4, output.GetUpperBound(0));
            Assert.AreEqual(5, output.Length);
            Assert.AreEqual("field1", output[0]);
            Assert.AreEqual("3", output[2]);
            Assert.AreEqual(string.Empty, output[3]);
            Assert.AreEqual("5", output[4]);
        }