當前位置: 首頁>>代碼示例>>C#>>正文


C# BitVector32.Equals方法代碼示例

本文整理匯總了C#中System.Collections.Specialized.BitVector32.Equals方法的典型用法代碼示例。如果您正苦於以下問題:C# BitVector32.Equals方法的具體用法?C# BitVector32.Equals怎麽用?C# BitVector32.Equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Collections.Specialized.BitVector32的用法示例。


在下文中一共展示了BitVector32.Equals方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Test01

        public void Test01()
        {
            BitVector32 bv32;
            BitVector32 bv32_1;       // extra BitVector32 - for comparison
            int data = 0;

            // [] two BitVectors that are the same - expected true
            //-----------------------------------------------------------------

            bv32 = new BitVector32();
            bv32_1 = new BitVector32();
            if (!bv32.Equals(bv32_1))
            {
                Assert.False(true, string.Format("Error, two default structs are not equal"));
            }


            // generate random data value
            data = -55;
            System.Random random = new System.Random(data);
            data = random.Next(System.Int32.MinValue, System.Int32.MaxValue);

            bv32 = new BitVector32(data);
            bv32_1 = new BitVector32(data);
            if (!bv32.Equals(bv32_1))
            {
                Assert.False(true, string.Format("Error, two vectores with random data are not equal"));
            }

            if (bv32.Equals(null))
            {
                Assert.False(true, string.Format("Error, vector and null are equal"));
            }

            bv32 = new BitVector32(data);
            if (data < Int32.MaxValue)
                data++;
            else
                data--;
            bv32_1 = new BitVector32(data);
            if (bv32.Equals(bv32_1))
            {
                Assert.False(true, string.Format("Error, two different vectors are equal"));
            }

            bv32 = new BitVector32(data);
            if (bv32.Equals(data))
            {
                Assert.False(true, string.Format("Error, vector and non-vector-object are equal"));
            }
        }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:51,代碼來源:EqualsObjTests.cs

示例2: Test01

        public void Test01()
        {
            BitVector32 bv32;
            BitVector32 bv32Temp;       // extra BitVector32 - for comparison

            // [] BitVector is constructed as expected
            //-----------------------------------------------------------------

            bv32 = new BitVector32();
            if (bv32.Data != 0)
            {
                Assert.False(true, string.Format("Error, Data = {0} after default ctor", bv32.Data));
            }

            string result = bv32.ToString();
            if (result.IndexOf("BitVector32") == -1)
            {  // "BitVector32" is not a part of ToString()
                Assert.False(true, "Error: ToString() doesn't contain \"BitVector32\"");
            }

            bool item = bv32[1];
            if (item)
            {
                Assert.False(true, string.Format("Error: Item(0) returned {0} instead of {1}", item, false));
            }

            bv32Temp = new BitVector32();
            if (!bv32.Equals(bv32Temp))
            {
                Assert.False(true, string.Format("Error: two default vectors are not equal"));
            }
        }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:32,代碼來源:CtorTests.cs

示例3: Constructors

		public void Constructors ()
		{
			BitVector32 b = new BitVector32 (31);
			Assert.AreEqual (31, b.Data, "Data");
			Assert.IsTrue (b.Equals (b), "Equals(self)");
			Assert.IsTrue (b[31], "31");
			Assert.IsFalse (b[32], "32");
			Assert.AreEqual (b.ToString (), "BitVector32{00000000000000000000000000011111}", b.ToString ());

			BitVector32 b2 = new BitVector32 (b);
			Assert.IsTrue (b.Equals (b2), "Equals(b2)");
			Assert.AreEqual (b.GetHashCode (), b2.GetHashCode (), "GetHashCode==");

			b2[32] = true;
			Assert.IsFalse (b.Equals (b2), "Equals(b32)");
			Assert.IsFalse (b.GetHashCode () == b2.GetHashCode (), "GetHashCode!=");
		}
開發者ID:LevNNN,項目名稱:mono,代碼行數:17,代碼來源:BitVector32Test.cs


注:本文中的System.Collections.Specialized.BitVector32.Equals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。