Esempio n. 1
0
        public void TestStringEncoderEmptyString()
        {
            const int n       = 10;
            var       encoder = new StringEncoder();

            for (int i = 0; i < n; i++)
            {
                encoder.Write(string.Empty);
            }

            var data = encoder.ToArray();

            using var stream = new MemoryStream(data);
            var decoder = new StringDecoder(stream);

            for (int i = 0; i < n; i++)
            {
                Assert.AreEqual(string.Empty, decoder.Read());
            }
        }
Esempio n. 2
0
        public void TestStringEncoder()
        {
            const int n       = 100;
            var       words   = new List <string>(n);
            var       encoder = new StringEncoder();

            for (int i = 0; i < n; i++)
            {
                var v = Guid.NewGuid().ToString();
                words.Add(v);
                encoder.Write(v);
            }

            var data = encoder.ToArray();

            using var stream = new MemoryStream(data);
            var decoder = new StringDecoder(stream);

            for (int i = 0; i < words.Count; i++)
            {
                Assert.AreEqual(words[i], decoder.Read());
            }
        }
Esempio n. 3
0
 public void WriteString(string s)
 {
     _stringEncoder.Write(s);
 }