Ejemplo n.º 1
0
 public void SetTag(string key, ValueT val)
 {
     SetTag(GSymbol.Get(key), val);
 }
Ejemplo n.º 2
0
 public ValueT GetTag(string key)
 {
     return(GetTag(GSymbol.GetIfExists(key)));
 }
Ejemplo n.º 3
0
 public bool HasTag(string key)
 {
     return(HasTag(GSymbol.GetIfExists(key)));
 }
Ejemplo n.º 4
0
        private void TestTheBasics(HashTags <string> a, bool startsEmpty)
        {
            // This test is run twice, once on a set that starts empty (to
            // test the one-element code paths) and again on a set that has
            // unrelated stuff in it already.
            IEnumerator <KeyValuePair <Symbol, string> > e;

            // Sanity checks
            Assert.IsNull(a.GetTag((string)null));
            Assert.IsFalse(a.RemoveTag("Nonexistant"));
            Assert.IsFalse(a.HasTag("Nonexistant"));

            a.SetTag("One", "Two");
            Assert.AreEqual(a.GetTag("One"), "Two");

            // Test the enumerator
            e = a.TagEnumerator();
            Assert.IsTrue(e.MoveNext());
            if (startsEmpty)
            {
                Assert.AreEqual(GSymbol.Get("One"), e.Current.Key);
                Assert.AreEqual("Two", e.Current.Value);
                Assert.IsFalse(e.MoveNext());
            }

            // Remove what we added
            Assert.IsNull(a.GetTag((string)null));
            Assert.IsFalse(a.RemoveTag(""));
            Assert.IsTrue(a.RemoveTag("One"));
            Assert.IsNull(a.GetTag("One"));

            if (startsEmpty)
            {
                e = a.TagEnumerator();
                Assert.IsFalse(e.MoveNext());
            }

            // Do almost the same thing again: add an attr, then remove it
            a.SetTag("One", "Two");
            Assert.AreEqual("Two", a.GetTag("One"));
            Assert.IsTrue(a.HasTag("One"));
            Assert.IsTrue(a.RemoveTag("One"));
            Assert.IsNull(a.GetTag("One"));

            // A different attribute
            a.SetTag("Two", "Three");
            Assert.AreEqual("Three", a.GetTag("Two"));
            a.SetTag("Two", "Four");
            a.SetTag("Two", "Two");
            Assert.AreEqual("Two", a.GetTag("Two"));

            // Another attribute should not disturb the first
            a.SetTag("Three", "Four");
            Assert.AreEqual("Two", a.GetTag("Two"));
            Assert.IsFalse(a.HasTag("One"));
            Assert.IsTrue(a.HasTag("Two"));
            Assert.IsTrue(a.HasTag("Three"));

            // Test the enumerator
            e = a.TagEnumerator();
            Assert.IsTrue(e.MoveNext());
            Assert.IsTrue(e.MoveNext());
            if (startsEmpty)
            {
                Assert.IsFalse(e.MoveNext());
            }

            // Clean up by removing all that we added
            Assert.IsTrue(a.RemoveTag("Two"));
            Assert.IsTrue(a.RemoveTag("Three"));
        }
Ejemplo n.º 5
0
 public bool RemoveTag(string key)
 {
     return(RemoveTag(GSymbol.GetIfExists(key)));
 }