예제 #1
0
파일: TestField.cs 프로젝트: NeoTim/etch
        private void TestMf(string name)
        {
            Field mf = new Field(name);

            Assert.AreEqual(IdName.Hash(name), mf.Id);
            Assert.AreEqual(name, mf.Name);
        }
예제 #2
0
파일: TestXType.cs 프로젝트: NeoTim/etch
        private void TestMt(string name)
        {
            XType mt = new XType(name);

            Assert.AreEqual(IdName.Hash(name), mt.Id);
            Assert.AreEqual(name, mt.Name);
        }
예제 #3
0
        public void Get_3()
        {
            Assert.AreEqual(2, map.Size());
            IdName x = map.Get(3);

            Assert.IsNull(x);
            Assert.AreEqual(2, map.Size());
        }
예제 #4
0
        public void Get_c()
        {
            Assert.AreEqual(2, map.Size());
            IdName c = map.Get("c");

            Check("c", 352988318, c);
            Assert.AreEqual(3, map.Size());
        }
예제 #5
0
        public void Get_d_locked()
        {
            Assert.AreEqual(2, map.Size());
            map.Lock();
            IdName d = map.Get("d");

            Assert.IsNull(d);
            Assert.AreEqual(2, map.Size());
        }
예제 #6
0
        public void Get_3_locked()
        {
            Assert.AreEqual(2, map.Size());
            map.Lock();
            IdName x = map.Get(3);

            Assert.IsNull(x);
            Assert.AreEqual(2, map.Size());
        }
예제 #7
0
 public void Hash()
 {
     Assert.AreEqual(5381, IdName.Hash(""));
     Assert.AreEqual(352988316, IdName.Hash("a"));
     Assert.AreEqual(1511848646, IdName.Hash("ab"));
     Assert.AreEqual(669497117, IdName.Hash("abc"));
     Assert.AreEqual(-1994190713, IdName.Hash("abcd"));
     Assert.AreEqual(-802680418, IdName.Hash("abcde"));
     Assert.AreEqual(1266308680, IdName.Hash("abcdef"));
     Assert.AreEqual(-379372513, IdName.Hash("abcdefg"));
     Assert.AreEqual(-1416967159, IdName.Hash("abcdefgh"));
     Assert.AreEqual(53556896, IdName.Hash("abcdefghi"));
     Assert.AreEqual(-4427318, IdName.Hash("abcdefghij"));
 }
예제 #8
0
        private void Check(String name, int id, IdName idName)
        {
            IdName x = map.Get(id);

            Assert.IsNotNull(x);
            Assert.AreSame(idName, x);
            Assert.AreEqual(id, x.Id);
            Assert.AreEqual(name, x.Name);

            x = map.Get(name);
            Assert.IsNotNull(x);
            Assert.AreSame(idName, x);
            Assert.AreEqual(id, x.Id);
            Assert.AreEqual(name, x.Name);
        }
예제 #9
0
파일: IdName.cs 프로젝트: NeoTim/etch
        /// Override
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }

            if (obj == null)
            {
                return(false);
            }

            if (this.GetType() != obj.GetType())
            {
                return(false);
            }

            IdName other = (IdName)obj;

            return(id.Equals(other.Id) && name.Equals(other.Name));
        }