Exemplo n.º 1
0
        public void Distinct1()
        {
            var set = new CharSeq("".ToCharArray());

            Assert.Equal("", set.ToString());

            set = new CharSeq("1".ToCharArray());
            Assert.Equal("1", set.ToString());

            set = new CharSeq("11".ToCharArray());
            Assert.Equal("1", set.ToString());

            set = new CharSeq("142321423456789".ToCharArray());
            Assert.Equal("123456789", set.ToString());

            set = new CharSeq("0000000000000000000000000".ToCharArray());
            Assert.Equal("0", set.ToString());

            set = new CharSeq("0111111111111111111111111112".ToCharArray());
            Assert.Equal("012", set.ToString());

            set = new CharSeq("111111111111111112".ToCharArray());
            Assert.Equal("12", set.ToString());

            set = new CharSeq("1222222222222222222".ToCharArray());
            Assert.Equal("12", set.ToString());

            set = new CharSeq("000000987654321111111111".ToCharArray());
            Assert.Equal("0123456789", set.ToString());
        }
Exemplo n.º 2
0
        public void Expand2()
        {
            var value = CharSeq.Expand("a-z");

            Assert.Equal(26, value.Length);
            Assert.Equal("abcdefghijklmnopqrstuvwxyz", value);

            value = CharSeq.Expand("a-z\\-");
            Assert.Equal(27, value.Length);
            Assert.Equal("abcdefghijklmnopqrstuvwxyz-", value);

            value = CharSeq.Expand("a-z\\\\xx");
            Assert.Equal(29, value.Length);
            Assert.Equal("abcdefghijklmnopqrstuvwxyz\\xx", value);

            value = CharSeq.Expand("A-Z");
            Assert.Equal(26, value.Length);
            Assert.Equal("ABCDEFGHIJKLMNOPQRSTUVWXYZ", value);

            value = CharSeq.Expand("0-9");
            Assert.Equal(10, value.Length);
            Assert.Equal("0123456789", value);

            value = CharSeq.Expand("0-9yxcvba-z");
            Assert.Equal(41, value.Length);
            Assert.Equal("0123456789yxcvbabcdefghijklmnopqrstuvwxyz", value);

            value = CharSeq.Expand("0-9a-zA-Z");
            Assert.Equal(10 + 26 + 26, value.Length);
            Assert.Equal("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", value);
        }
Exemplo n.º 3
0
        public void Distinct()
        {
            var cs1 = new CharSeq("abcdeaafg");
            var cs2 = new CharSeq("gfedcbabb");

            Assert.Equal(cs2, cs1);
        }
Exemplo n.º 4
0
        public void Distinct2()
        {
            var set = new CharSeq("");

            Assert.Equal("", set.ToString());

            set = new CharSeq("1");
            Assert.Equal("1", set.ToString());

            set = new CharSeq("11");
            Assert.Equal("1", set.ToString());

            set = new CharSeq("1223345667899");
            Assert.Equal("123456789", set.ToString());

            set = new CharSeq("0000000000000000000000000");
            Assert.Equal("0", set.ToString());

            set = new CharSeq("0111111111111111111111111112");
            Assert.Equal("012", set.ToString());

            set = new CharSeq("111111111111111112");
            Assert.Equal("12", set.ToString());

            set = new CharSeq("1222222222222222222");
            Assert.Equal("12", set.ToString());

            set = new CharSeq("000000987654321111111111");
            Assert.Equal("0123456789", set.ToString());
        }
Exemplo n.º 5
0
        public void SubSequence()
        {
            var set = new CharSeq(CharSeq.Expand("a-z"));
            var sub = set.SubSequence(3, 10);

            Assert.Equal(7, sub.Length);
            Assert.Equal("defghij", sub.ToString());
        }
Exemplo n.º 6
0
        public void Contains()
        {
            var set = new CharSeq(CharSeq.Expand("a-z"));

            Assert.Contains('t', set);
            Assert.Contains('a', set);
            Assert.Contains('z', set);
            Assert.DoesNotContain('T', set);
            Assert.DoesNotContain('1', set);
            Assert.DoesNotContain('2', set);
        }
Exemplo n.º 7
0
        public void Expand1()
        {
            var value = CharSeq.Expand('a', 'z');

            Assert.Equal(26, value.Length);
            Assert.Equal("abcdefghijklmnopqrstuvwxyz", value);

            value = CharSeq.Expand('A', 'Z');
            Assert.Equal(26, value.Length);
            Assert.Equal("ABCDEFGHIJKLMNOPQRSTUVWXYZ", value);

            value = CharSeq.Expand('0', '9');
            Assert.Equal(10, value.Length);
            Assert.Equal("0123456789", value);
        }
Exemplo n.º 8
0
        public void Iterate()
        {
            var set    = new CharSeq(CharSeq.Expand("a-z"));
            var values = CharSeq.Expand("a-z");

            using (var it = set.GetEnumerator())
            {
                foreach (var t in values)
                {
                    Assert.True(it.MoveNext());

                    Assert.Equal(t, it.Current);
                }
                Assert.False(it.MoveNext());
            }
        }
Exemplo n.º 9
0
 public void Expand4()
 {
     Assert.Throws <ArgumentException>(() => CharSeq.Expand("-az"));
 }
Exemplo n.º 10
0
 public void Expand3()
 {
     Assert.Throws <ArgumentException>(() => CharSeq.Expand("a-z-"));
 }