Beispiel #1
0
        public void ReadColumnsSetTest()
        {
            const char separator = CharsSplitReader.Comma;
            var        expecteds = new string[] { "A", "B", "C", "D", "", };
            var        text      = string.Join(separator.ToString(), expecteds);
            var        raw       = Encoding.UTF8.GetBytes(text);
            var        columns   = new int[expecteds.Length];

            for (var column = columns.Length - 1; column >= 0; --column)
            {
                columns[column] = column;
            }
            var actuals = new CharsColumn[expecteds.Length];
            var appends = new Action <char[], int, int> [expecteds.Length];

            for (var i = actuals.Length - 1; i >= 0; --i)
            {
                var actual = new CharsColumn();
                actuals[i] = actual;
                appends[i] = actual.AppendLength;
            }
            using (var readerStream = new MemoryStream(raw))
                using (var reader = new CharsSplitReader(readerStream))
                {
                    Assert.IsTrue(reader.ReadColumnsLength(separator, appends), "!ReadColumns");
                    for (var i = expecteds.Length - 1; i >= 0; --i)
                    {
                        Assert.AreEqual(expecteds[i], actuals[i].ToString(), i.ToString());
                    }
                }
        }
Beispiel #2
0
        public void Append(CharsColumn append)
        {
            appended = true;
            var appendCount = append.count;
            var required    = count + appendCount;

            if (required > capacity)
            {
                Enlarge();
            }
            Array.Copy(append.values, 0, values, count, appendCount);
            count += appendCount;
        }
Beispiel #3
0
        public void ReadColumnTest()
        {
            const char separator = CharsSplitReader.Comma;
            var        expecteds = new string[] { "A", "B", "C", "D", "", };
            var        text      = string.Join(separator.ToString(), expecteds);
            var        raw       = Encoding.UTF8.GetBytes(text);

            for (var i = expecteds.Length - 1; i >= 0; --i)
            {
                var actual = new CharsColumn();
                using (var readerStream = new MemoryStream(raw))
                    using (var reader = new CharsSplitReader(readerStream))
                    {
                        Assert.IsTrue(reader.ReadColumnsLength(separator, i, actual.AppendLength), "!ReadColumn");
                        Assert.AreEqual(expecteds[i], actual.ToString(), i.ToString());
                    }
            }
        }
Beispiel #4
0
 public bool Equals(CharsColumn other)
 {
     if (object.ReferenceEquals(other, null))
     {
         return(false);
     }
     if (other.count != this.count)
     {
         return(false);
     }
     for (var offset = count - 1; offset >= 0; --offset)
     {
         if (other.values[offset] != this.values[offset])
         {
             return(false);
         }
     }
     return(true);
 }
Beispiel #5
0
 public static bool TryParseObjectUInt64(CharsColumn parse, out object value)
 {
     return(parse.TryParseObjectUInt64(out value));
 }
Beispiel #6
0
 public static bool TryParseObjectTimeSpan(CharsColumn parse, out object value)
 {
     return(parse.TryParseObjectTimeSpan(out value));
 }
Beispiel #7
0
 public static bool TryParseObjectSingle(CharsColumn parse, out object value)
 {
     return(parse.TryParseObjectSingle(out value));
 }
Beispiel #8
0
 public static bool TryParseObjectDecimal(CharsColumn parse, out object value)
 {
     return(parse.TryParseObjectDecimal(out value));
 }