static void Test_Remove()
        {
            RleArray <char> chars = new RleArray <char>();

            {
                // In a node
                Set(chars, "aa");
                chars.RemoveAt(0);
                TestUtl.AssertEquals(1, chars.Count);
                TestUtl.AssertEquals("[1|a]", chars._Nodes.ToString());
                chars.RemoveAt(0);
                TestUtl.AssertEquals(0, chars.Count);
                TestUtl.AssertEquals("", chars._Nodes.ToString());
                try{ chars.RemoveAt(0); throw new Exception(); }
                catch (Exception ex) { TestUtl.AssertExceptionType <ArgumentOutOfRangeException>(ex); }

                // Removing a node
                Set(chars, "aaabc");
                chars.RemoveAt(3);
                TestUtl.AssertEquals(4, chars.Count);
                TestUtl.AssertEquals("[3|a] [1|c]", chars._Nodes.ToString());

                // Combining nodes
                Set(chars, "aabaa");
                chars.RemoveAt(2);
                TestUtl.AssertEquals(4, chars.Count);
                TestUtl.AssertEquals("[4|a]", chars._Nodes.ToString());
            }
        }
Exemple #2
0
        public void Remove()
        {
            RleArray <char> chars = new RleArray <char>();

            {
                // In a node
                Set(chars, "aa");
                chars.RemoveAt(0);
                Assert.AreEqual(1, chars.Count);
                Assert.AreEqual("[1|a]", chars._Nodes.ToString());
                chars.RemoveAt(0);
                Assert.AreEqual(0, chars.Count);
                Assert.AreEqual("", chars._Nodes.ToString());
                MyAssert.Throws <ArgumentOutOfRangeException>(delegate {
                    chars.RemoveAt(0);
                });

                // Removing a node
                Set(chars, "aaabc");
                chars.RemoveAt(3);
                Assert.AreEqual(4, chars.Count);
                Assert.AreEqual("[3|a] [1|c]", chars._Nodes.ToString());

                // Combining nodes
                Set(chars, "aabaa");
                chars.RemoveAt(2);
                Assert.AreEqual(4, chars.Count);
                Assert.AreEqual("[4|a]", chars._Nodes.ToString());
            }
        }