コード例 #1
0
 /// <summary>Determines whether the specified object is the same as the current <see cref="T:System.Collections.Specialized.BitVector32.Section" /> object.</summary>
 /// <returns>true if the specified object is the same as the current <see cref="T:System.Collections.Specialized.BitVector32.Section" /> object; otherwise, false.</returns>
 /// <param name="o">The object to compare with the current <see cref="T:System.Collections.Specialized.BitVector32.Section" />.</param>
 public override bool Equals(object o)
 {
     if (!(o is BitVector32.Section))
     {
         return(false);
     }
     BitVector32.Section section = (BitVector32.Section)o;
     return(this.mask == section.mask && this.offset == section.offset);
 }
コード例 #2
0
ファイル: DCB.cs プロジェクト: facchinm/SiRFLive
 public DCB()
 {
     this.DCBlength = (uint) Marshal.SizeOf(this);
     this.Control = new BitVector32(0);
     this.sect1 = BitVector32.CreateSection(15);
     this.DTRsect = BitVector32.CreateSection(3, this.sect1);
     this.sect2 = BitVector32.CreateSection(0x3f, this.DTRsect);
     this.RTSsect = BitVector32.CreateSection(3, this.sect2);
 }
コード例 #3
0
            /// <summary>Returns a string that represents the specified <see cref="T:System.Collections.Specialized.BitVector32.Section" />.</summary>
            /// <returns>A string that represents the specified <see cref="T:System.Collections.Specialized.BitVector32.Section" />.</returns>
            /// <param name="value">The <see cref="T:System.Collections.Specialized.BitVector32.Section" /> to represent.</param>
            public static string ToString(BitVector32.Section value)
            {
                StringBuilder stringBuilder = new StringBuilder();

                stringBuilder.Append("Section{0x");
                stringBuilder.Append(Convert.ToString(value.Mask, 16));
                stringBuilder.Append(", 0x");
                stringBuilder.Append(Convert.ToString(value.Offset, 16));
                stringBuilder.Append("}");
                return(stringBuilder.ToString());
            }
コード例 #4
0
        /// <summary>Creates a new <see cref="T:System.Collections.Specialized.BitVector32.Section" /> following the specified <see cref="T:System.Collections.Specialized.BitVector32.Section" /> in a series of sections that contain small integers.</summary>
        /// <returns>A <see cref="T:System.Collections.Specialized.BitVector32.Section" /> that can hold a number from zero to <paramref name="maxValue" />.</returns>
        /// <param name="maxValue">A 16-bit signed integer that specifies the maximum value for the new <see cref="T:System.Collections.Specialized.BitVector32.Section" />. </param>
        /// <param name="previous">The previous <see cref="T:System.Collections.Specialized.BitVector32.Section" /> in the <see cref="T:System.Collections.Specialized.BitVector32" />. </param>
        /// <exception cref="T:System.ArgumentException">
        ///   <paramref name="maxValue" /> is less than 1. </exception>
        /// <exception cref="T:System.InvalidOperationException">
        ///   <paramref name="previous" /> includes the final bit in the <see cref="T:System.Collections.Specialized.BitVector32" />.-or- <paramref name="maxValue" /> is greater than the highest value that can be represented by the number of bits after <paramref name="previous" />. </exception>
        public static BitVector32.Section CreateSection(short maxValue, BitVector32.Section previous)
        {
            if (maxValue < 1)
            {
                throw new ArgumentException("maxValue");
            }
            int num  = BitVector32.HighestSetBit((int)maxValue);
            int num2 = (1 << num) - 1;
            int num3 = (int)previous.Offset + BitVector32.HighestSetBit((int)previous.Mask);

            if (num3 + num > 32)
            {
                throw new ArgumentException("Sections cannot exceed 32 bits in total");
            }
            return(new BitVector32.Section((short)num2, (short)num3));
        }
コード例 #5
0
ファイル: DCB.cs プロジェクト: intille/mitessoftware
		public DCB()
		{
			//
			// Initialize the length of the structure. Marshal.SizeOf returns
			// the size of the unmanaged object (basically the object that
			// gets marshalled).
			//
			this.DCBlength = (uint)Marshal.SizeOf(this);

			// initialize BitVector32
			Control=new BitVector32(0);

			// of the following 4 sections only 2 are needed
			sect1=BitVector32.CreateSection(0x0f);
			DTRsect=BitVector32.CreateSection(3,sect1); // this is where the DTR setting is stored
			sect2=BitVector32.CreateSection(0x3f,DTRsect);
			RTSsect=BitVector32.CreateSection(3,sect2);	// this is where the RTS setting is stored
		}
コード例 #6
0
        public static Section CreateSection(short maxValue, BitVector32.Section previous)
        {
            if (maxValue < 1)
            {
                throw new ArgumentException("maxValue");
            }

            int bit    = HighestSetBit(maxValue) + 1;
            int mask   = (1 << bit) - 1;
            int offset = previous.Offset + NumberOfSetBits(previous.Mask);

            if (offset > 32)
            {
                throw new ArgumentException("Sections cannot exceed 32 bits in total");
            }

            return(new Section((short)mask, (short)offset));
        }
コード例 #7
0
        public int this [BitVector32.Section section] {
            get {
                return((bits >> section.Offset) & section.Mask);
            }

            set {
                if (value < 0)
                {
                    throw new ArgumentException("Section can't hold negative values");
                }
                if (value > section.Mask)
                {
                    throw new ArgumentException("Value too large to fit in section");
                }
                bits &= ~(section.Mask << section.Offset);
                bits |= (value << section.Offset);
            }
        }
コード例 #8
0
 /// <summary>Gets or sets the value stored in the specified <see cref="T:System.Collections.Specialized.BitVector32.Section" />.</summary>
 /// <returns>The value stored in the specified <see cref="T:System.Collections.Specialized.BitVector32.Section" />.</returns>
 /// <param name="section">A <see cref="T:System.Collections.Specialized.BitVector32.Section" /> that contains the value to get or set. </param>
 public int this[BitVector32.Section section]
 {
     get
     {
         return(this.bits >> (int)section.Offset & (int)section.Mask);
     }
     set
     {
         if (value < 0)
         {
             throw new ArgumentException("Section can't hold negative values");
         }
         if (value > (int)section.Mask)
         {
             throw new ArgumentException("Value too large to fit in section");
         }
         this.bits &= ~((int)section.Mask << (int)section.Offset);
         this.bits |= value << (int)section.Offset;
     }
 }
コード例 #9
0
            static DCB()
            {
                // Create Boolean Mask
                int previousMask;
                fBinary = BitVector32.CreateMask();
                fParity = BitVector32.CreateMask(fBinary);
                fOutxCtsFlow = BitVector32.CreateMask(fParity);
                fOutxDsrFlow = BitVector32.CreateMask(fOutxCtsFlow);
                previousMask = BitVector32.CreateMask(fOutxDsrFlow);
                previousMask = BitVector32.CreateMask(previousMask);
                fDsrSensitivity = BitVector32.CreateMask(previousMask);
                fTXContinueOnXoff = BitVector32.CreateMask(fDsrSensitivity);
                fOutX = BitVector32.CreateMask(fTXContinueOnXoff);
                fInX = BitVector32.CreateMask(fOutX);
                fErrorChar = BitVector32.CreateMask(fInX);
                fNull = BitVector32.CreateMask(fErrorChar);
                previousMask = BitVector32.CreateMask(fNull);
                previousMask = BitVector32.CreateMask(previousMask);
                fAbortOnError = BitVector32.CreateMask(previousMask);

                // Create section Mask
                BitVector32.Section previousSection;
                previousSection = BitVector32.CreateSection(1);
                previousSection = BitVector32.CreateSection(1, previousSection);
                previousSection = BitVector32.CreateSection(1, previousSection);
                previousSection = BitVector32.CreateSection(1, previousSection);
                fDtrControl = BitVector32.CreateSection(2, previousSection);
                previousSection = BitVector32.CreateSection(1, fDtrControl);
                previousSection = BitVector32.CreateSection(1, previousSection);
                previousSection = BitVector32.CreateSection(1, previousSection);
                previousSection = BitVector32.CreateSection(1, previousSection);
                previousSection = BitVector32.CreateSection(1, previousSection);
                previousSection = BitVector32.CreateSection(1, previousSection);
                fRtsControl = BitVector32.CreateSection(3, previousSection);
                previousSection = BitVector32.CreateSection(1, fRtsControl);
            }
コード例 #10
0
 public StateProvider()
 {
     _sellPointSection = BitVector32.CreateSection(short.MaxValue);
     _priceSection = BitVector32.CreateSection(short.MaxValue, _sellPointSection);
 }
コード例 #11
0
        public void Test01()
        {
            BitVector32 bv32;
            int data = 0;
            // create sections to test
            BitVector32.Section[] sect = new BitVector32.Section[6];
            sect[0] = BitVector32.CreateSection(1);        // 1x0 section  - 1st bit
            sect[1] = BitVector32.CreateSection(1, sect[0]);        // 1x1 section - 2nd bit
            sect[2] = BitVector32.CreateSection(7);        // 7x0 section  - first 3 bits
            sect[3] = BitVector32.CreateSection(Int16.MaxValue);        // Int16.MaxValuex0 section
            sect[4] = BitVector32.CreateSection(Int16.MaxValue, sect[3]);        // Int16.MaxValuex15 section
            sect[5] = BitVector32.CreateSection(1, sect[4]);
            sect[5] = BitVector32.CreateSection(1, sect[5]);        // sign bit section    - last sign bit

            // array of expected sections values for all 1's in vector
            int[] values =
            {
                1,                  //   0
                1,                  //   1
                7,                  //   2
                Int16.MaxValue,     //   3
                Int16.MaxValue,     //   4
                1                   //   5 - value of sign bit may differ based on Data sign
            };

            // [] BitVector is constructed as expected and sections return expected values
            //-----------------------------------------------------------------

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

            // loop through sections
            // all values should return 0
            for (int i = 0; i < sect.Length; i++)
            {
                if (bv32[sect[i]] != 0)
                {
                    Assert.False(true, string.Format("Error, returned {1} instead of {2}", i, bv32[sect[i]], 0));
                }
            }

            //
            //   (-1)
            //
            data = -1;
            bv32 = new BitVector32(data);
            if (bv32.Data != data)
            {
                Assert.False(true, string.Format("Error, Data = {0} ", bv32.Data));
            }

            // loop through sections
            // all values should correspond to 'values'-array elements
            for (int i = 0; i < sect.Length; i++)
            {
                if (bv32[sect[i]] != values[i])
                {
                    string temp = "Err" + i;
                    if (i == sect.Length - 1)
                        temp += "section for last bit";
                    Assert.False(true, string.Format("{0} returned {1} instead of {2}", temp, bv32[sect[i]], values[i]));
                }
            }

            //
            //  Int32.MaxValue
            //
            data = Int32.MaxValue;
            bv32 = new BitVector32(data);
            if (bv32.Data != data)
            {
                Assert.False(true, string.Format("Error, Data = {0} ", bv32.Data));
            }

            values[values.Length - 1] = 0;
            // loop through sections
            // all values should correspond to 'values'-array elements
            for (int i = 0; i < sect.Length; i++)
            {
                if (bv32[sect[i]] != values[i])
                {
                    string temp = "Err" + i;
                    Assert.False(true, string.Format("{0} returned {1} instead of {2}", temp, bv32[sect[i]], values[i]));
                }
            }

            //
            //    Int32.MinValue
            //
            data = Int32.MinValue;
            bv32 = new BitVector32(data);
            if (bv32.Data != data)
            {
                Assert.False(true, string.Format("Error, Data = {0} ", bv32.Data));
            }

            ClearArray(values);
            values[values.Length - 1] = 1;
            // loop through sections
            // all values should correspond to 'values'-array elements
            for (int i = 0; i < sect.Length; i++)
            {
                if (bv32[sect[i]] != values[i])
                {
                    string temp = "Err" + i;
                    if (i == sect.Length - 1)
                        temp += "section for last bit";
                    Assert.False(true, string.Format("{0} returned {1} instead of {2}", temp, bv32[sect[i]], values[i]));
                }
            }

            //
            //    1
            //
            data = 1;
            bv32 = new BitVector32(data);
            if (bv32.Data != data)
            {
                Assert.False(true, string.Format("Error, Data = {0} ", bv32.Data));
            }

            ClearArray(values);
            values[0] = 1;
            values[2] = 1;
            values[3] = 1;
            // loop through sections
            // all values should correspond to 'values'-array elements
            for (int i = 0; i < sect.Length; i++)
            {
                if (bv32[sect[i]] != values[i])
                {
                    string temp = "Err" + i;
                    Assert.False(true, string.Format("{0} returned {1} instead of {2}", temp, bv32[sect[i]], values[i]));
                }
            }
        }
コード例 #12
0
 /// <summary>Determines whether the specified <see cref="T:System.Collections.Specialized.BitVector32.Section" /> object is the same as the current <see cref="T:System.Collections.Specialized.BitVector32.Section" /> object.</summary>
 /// <returns>true if the <paramref name="obj" /> parameter is the same as the current <see cref="T:System.Collections.Specialized.BitVector32.Section" /> object; otherwise false.</returns>
 /// <param name="obj">The <see cref="T:System.Collections.Specialized.BitVector32.Section" /> object to compare with the current <see cref="T:System.Collections.Specialized.BitVector32.Section" /> object.</param>
 public bool Equals(BitVector32.Section obj)
 {
     return(this.mask == obj.mask && this.offset == obj.offset);
 }
コード例 #13
0
 public bool Equals(BitVector32.Section obj)
 {
     return((obj.mask == this.mask) && (obj.offset == this.offset));
 }
コード例 #14
0
        public void Test01()
        {
            BitVector32 bv32;
            int data = 0;
            // create sections to test
            BitVector32.Section[] sect = new BitVector32.Section[6];
            sect[0] = BitVector32.CreateSection(1);        // 1x0 section  - 1st bit
            sect[1] = BitVector32.CreateSection(1, sect[0]);        // 1x1 section - 2nd bit
            sect[2] = BitVector32.CreateSection(7);        // 7x0 section  - first 3 bits
            sect[3] = BitVector32.CreateSection(Int16.MaxValue);        // Int16.MaxValue x 0 section
            sect[4] = BitVector32.CreateSection(Int16.MaxValue, sect[3]);        // Int16.MaxValue x 15 section
            sect[5] = BitVector32.CreateSection(1, sect[4]);
            sect[5] = BitVector32.CreateSection(1, sect[5]);        // sign bit section    - last sign bit

            // [] BitVector is constructed as expected and sections return expected values
            //-----------------------------------------------------------------

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

            // loop through sections
            // set all to max
            for (int i = 0; i < sect.Length; i++)
            {
                bv32[sect[i]] = (int)sect[i].Mask;
                if (bv32[sect[i]] != (int)sect[i].Mask)
                {
                    string temp = "Err" + i;
                    if (i == sect.Length - 1)
                        temp += "section for last bit";
                    Assert.False(true, string.Format("{0} returned {1} instead of {2}", temp, bv32[sect[i]], (int)sect[i].Mask));
                }
            }

            // loop through sections
            // set all to 0
            for (int i = 0; i < sect.Length; i++)
            {
                bv32[sect[i]] = 0;
                if (bv32[sect[i]] != 0)
                {
                    Assert.False(true, string.Format("Error, returned {1} instead of {2}", i, bv32[sect[i]], 0));
                }
            }

            // loop through sections
            // set all to 1
            for (int i = 0; i < sect.Length; i++)
            {
                bv32[sect[i]] = 1;
                if (bv32[sect[i]] != 1)
                {
                    string temp = "Err" + i;
                    if (i == sect.Length - 1)
                        temp += "section for last bit";
                    Assert.False(true, string.Format("{0} returned {1} instead of {2}", temp, bv32[sect[i]], 1));
                }
            }

            // loop through sections
            // set to (max/2) where possible
            for (int i = 0; i < sect.Length; i++)
            {
                if (((int)sect[i].Mask) > 3)
                {
                    data = ((int)sect[i].Mask) / 2;
                    bv32[sect[i]] = data;
                    if (bv32[sect[i]] != data)
                    {
                        string temp = "Err" + i;
                        Assert.False(true, string.Format("{0} returned {1} instead of {2}", temp, bv32[sect[i]], data));
                    }
                }
            }
            // loop through sections
            // set all to out-of-range: (-1)
            //
            // There will be no exception
            // in debug builds assertion is thrown (uncatchable)
            // will skip out-of-range cases in debug build
            //
#if !DEBUG
            for (int i = 0; i < sect.Length; i++)
            {

                bv32[sect[i]] = -1;
                if (bv32[sect[i]] != sect[i].Mask)
                {
                    string temp = "Err" + i;
                    Assert.False(true, temp + ": didn't set section to " + sect[i].Mask);
                }
            }

            // loop through sections
            // set all to out-of-range: Max + 1
            for (int i = 0; i < sect.Length; i++)
            {
                int exp = (int)(sect[i].Mask) + 1;
                bv32[sect[i]] = exp;
                exp = sect[i].Mask & exp;
                if (bv32[sect[i]] != exp)
                {
                    string temp = "Err" + i;
                    Assert.False(true, temp + ": didn't set section to " + exp);
                }
            }
#endif
        }
コード例 #15
0
 public virtual bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     String strLoc = "Loc_000oo";
     BitVector32 bv32;         
     int data = 0;
     BitVector32.Section [] sect = new BitVector32.Section [6];
     sect[0] = BitVector32.CreateSection(1);        
     sect[1] = BitVector32.CreateSection(1, sect[0]);        
     sect[2] = BitVector32.CreateSection(7);        
     sect[3] = BitVector32.CreateSection(Int16.MaxValue);        
     sect[4] = BitVector32.CreateSection(Int16.MaxValue, sect[3]);        
     sect[5] = BitVector32.CreateSection(1, sect[4]);        
     sect[5] = BitVector32.CreateSection(1, sect[5]);        
     int [] values = 
     {             
         1,                  
         1,                  
         7,                  
         Int16.MaxValue,     
         Int16.MaxValue,     
         1                   
     };
     try
     {
         Console.WriteLine("1. default ctor");
         strLoc = "Loc_001oo"; 
         bv32 = new BitVector32();
         Console.WriteLine(bv32.ToString());
         iCountTestcases++;
         if (bv32.Data != 0) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0001, Data = {0} after default ctor", bv32.Data);
         }
         for (int i = 0; i < sect.Length; i++) 
         {
             iCountTestcases++;
             if (bv32[sect[i]] != 0 ) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_0001_{0}, returned {1} instead of {2}", i, bv32[sect[i]], 0);
             }
         }
         data = -1;
         Console.WriteLine("2. BitVector32({0})", data);
         strLoc = "Loc_002oo"; 
         bv32 = new BitVector32(data);
         Console.WriteLine(bv32.ToString());
         iCountTestcases++;
         if (bv32.Data != data) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0002, Data = {0} ", bv32.Data);
         }
         for (int i = 0; i < sect.Length; i++) 
         {
             iCountTestcases++;
             if (bv32[sect[i]] != values[i] ) 
             {
                 iCountErrors++;
                 string temp = "Err_0002_" + i;
                 if (i == sect.Length - 1)
                     temp += " - Error - section for last bit";
                 Console.WriteLine("{0} returned {1} instead of {2}", temp, bv32[sect[i]], values[i]);
             }
         }
         data = Int32.MaxValue;
         Console.WriteLine("3. BitVector32({0}) - Int32.MaxValue", data);
         strLoc = "Loc_003oo"; 
         bv32 = new BitVector32(data);
         Console.WriteLine(bv32.ToString());
         iCountTestcases++;
         if (bv32.Data != data) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0003, Data = {0} ", bv32.Data);
         }
         values[values.Length - 1] = 0;
         for (int i = 0; i < sect.Length; i++) 
         {
             iCountTestcases++;
             if (bv32[sect[i]] != values[i] ) 
             {
                 iCountErrors++;
                 string temp = "Err_0003_" + i;
                 Console.WriteLine("{0} returned {1} instead of {2}", temp, bv32[sect[i]], values[i]);
             }
         }
         data = Int32.MinValue;
         Console.WriteLine("4. BitVector32({0}) - Int32.MinValue", data);
         strLoc = "Loc_004oo"; 
         bv32 = new BitVector32(data);
         Console.WriteLine(bv32.ToString());
         iCountTestcases++;
         if (bv32.Data != data) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0004, Data = {0} ", bv32.Data);
         }
         ClearArray(values);
         values[values.Length - 1] = 1;
         for (int i = 0; i < sect.Length; i++) 
         {
             iCountTestcases++;
             if (bv32[sect[i]] != values[i] ) 
             {
                 iCountErrors++;
                 string temp = "Err_0004_" + i;
                 if (i == sect.Length - 1)
                     temp += " - Error - section for last bit";
                 Console.WriteLine("{0} returned {1} instead of {2}", temp, bv32[sect[i]], values[i]);
             }
         }
         data = 1;
         Console.WriteLine("5. BitVector32({0})", data);
         strLoc = "Loc_005oo"; 
         bv32 = new BitVector32(data);
         Console.WriteLine(bv32.ToString());
         iCountTestcases++;
         if (bv32.Data != data) 
         {
             iCountErrors++;
             Console.WriteLine("Err_0005, Data = {0} ", bv32.Data);
         }
         ClearArray(values);
         values[0] = 1;
         values[2] = 1;
         values[3] = 1;
         for (int i = 0; i < sect.Length; i++) 
         {
             iCountTestcases++;
             if (bv32[sect[i]] != values[i] ) 
             {
                 iCountErrors++;
                 string temp = "Err_0005_" + i;
                 Console.WriteLine("{0} returned {1} instead of {2}", temp, bv32[sect[i]], values[i]);
             }
         }
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine("");
         Console.WriteLine( "Pass.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
         return true;
     }
     else
     {
         Console.WriteLine("");
         Console.WriteLine("Fail!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
コード例 #16
0
    public virtual bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver: " + s_strDtTmVer);
        int iCountErrors = 0;
        int iCountTestcases = 0;
        String strLoc = "Loc_000oo";
        BitVector32 bv32;         
        int data = 0;
        BitVector32.Section [] sect = new BitVector32.Section [6];
        sect[0] = BitVector32.CreateSection(1);        
        sect[1] = BitVector32.CreateSection(1, sect[0]);        
        sect[2] = BitVector32.CreateSection(7);        
        sect[3] = BitVector32.CreateSection(Int16.MaxValue);        
        sect[4] = BitVector32.CreateSection(Int16.MaxValue, sect[3]);        
        sect[5] = BitVector32.CreateSection(1, sect[4]);        
        sect[5] = BitVector32.CreateSection(1, sect[5]);        
        try
        {
            Console.WriteLine("- default ctor");
            strLoc = "Loc_001oo"; 
            bv32 = new BitVector32();
            Console.WriteLine(bv32.ToString());
            iCountTestcases++;
            if (bv32.Data != 0) 
            {
                iCountErrors++;
                Console.WriteLine("Err_0001, Data = {0} after default ctor", bv32.Data);
            }
            Console.WriteLine("1. set all sections to max value");
            for (int i = 0; i < sect.Length; i++) 
            {
                iCountTestcases++;
                bv32[sect[i]] = (int)sect[i].Mask;
                if (bv32[sect[i]] != (int)sect[i].Mask ) 
                {
                    iCountErrors++;
                    string temp = "Err_0001_" + i;
                    if (i == sect.Length - 1)
                        temp += " - Error - section for last bit";
                    Console.WriteLine("{0} returned {1} instead of {2}", temp, bv32[sect[i]], (int)sect[i].Mask);
                }
            }
            Console.WriteLine("2. set all sections to 0");
            for (int i = 0; i < sect.Length; i++) 
            {
                iCountTestcases++;
                bv32[sect[i]] = 0;
                if (bv32[sect[i]] != 0 ) 
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0002_{0}, returned {1} instead of {2}", i, bv32[sect[i]], 0);
                }
            }
            Console.WriteLine("3. set all sections to 1");
            for (int i = 0; i < sect.Length; i++) 
            {
                iCountTestcases++;
                bv32[sect[i]] = 1;
                if (bv32[sect[i]] != 1 ) 
                {
                    iCountErrors++;
                    string temp = "Err_0003_" + i;
                    if (i == sect.Length - 1)
                        temp += " - Error - section for last bit";
                    Console.WriteLine("{0} returned {1} instead of {2}", temp, bv32[sect[i]], 1);
                }
            }
            Console.WriteLine("4. set to (max/2) where valid");
            for (int i = 0; i < sect.Length; i++) 
            {
                iCountTestcases++;
                if (((int)sect[i].Mask) > 3) 
                {
                    data = ((int)sect[i].Mask) / 2;
                    bv32[sect[i]] = data;
                    if (bv32[sect[i]] != data ) 
                    {
                        iCountErrors++;
                        string temp = "Err_0004_" + i;
                        Console.WriteLine("{0} returned {1} instead of {2}", temp, bv32[sect[i]], data);
                    }
                }
            }
# if retail
            Console.WriteLine("5. set all to -1");
            for (int i = 0; i < sect.Length; i++) {
    		    iCountTestcases++;
                try {
                    bv32[sect[i]] = -1;
                    if (bv32[sect[i]] != sect[i].Mask ) {
        				iCountErrors++;
                        string temp = "Err_0005a_" + i;
        				Console.WriteLine(temp + ": didn't set section to " + sect[i].Mask);
                    }
                }
                catch (Exception e) {
    				iCountErrors++;
                    string temp = "Err_0005b_" + i;
    				Console.WriteLine(temp + ": unexpected exception - according to spec should not throw");
    				Console.WriteLine(e.ToString());
                }
            }
            Console.WriteLine("6. set all to (max + 1)");
            for (int i = 0; i < sect.Length; i++) {
    		    iCountTestcases++;
                try {
                    int exp = (int)(sect[i].Mask) + 1;
                    bv32[sect[i]] = exp;
                    exp = sect[i].Mask & exp;
                    if (bv32[sect[i]] != exp ) {
        				iCountErrors++;
                        string temp = "Err_0006a_" + i;
        				Console.WriteLine(temp + ": didn't set section to " + exp);
                    }
                }
                catch (Exception e) {
    				iCountErrors++;
                    string temp = "Err_0006b_" + i;
    				Console.WriteLine(temp + ": unexpected exception - according to spec should not throw");
    				Console.WriteLine(e.ToString());
                }
            }
#endif        
        } 
        catch (Exception exc_general ) 
        {
            ++iCountErrors;
            Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
        }
        if ( iCountErrors == 0 )
        {
            Console.WriteLine("");
            Console.WriteLine( "Pass.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
            return true;
        }
        else
        {
            Console.WriteLine("");
            Console.WriteLine("Fail!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
            return false;
        }
    }
コード例 #17
0
ファイル: KeyboardHook.cs プロジェクト: digger1985/MyCode
 public KeyboardMessageFlags(int lParam)
 {
     this.flags = new BitVector32(lParam);
     repeatCount = BitVector32.CreateSection(short.MaxValue);
     scanCode = BitVector32.CreateSection(byte.MaxValue, repeatCount);
     extendedKey = BitVector32.CreateSection(1, scanCode);
     reserved = BitVector32.CreateSection(8, extendedKey);
     contextCode = BitVector32.CreateSection(1, reserved);
     previousKeyState = BitVector32.CreateSection(1, contextCode);
     transitionState = BitVector32.CreateSection(1, previousKeyState);
 }
コード例 #18
0
 public static string ToString(BitVector32.Section value)
 {
     return("Section{0x" + Convert.ToString(value.Mask, 0x10) + ", 0x" + Convert.ToString(value.Offset, 0x10) + "}");
 }