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; BitVector32 bv32_1; string str = ""; string str_1 = ""; int data = 0; try { Console.WriteLine("1. two default structs"); strLoc = "Loc_001oo"; iCountTestcases++; bv32 = new BitVector32(); bv32_1 = new BitVector32(); str = bv32.ToString(); str_1 = bv32_1.ToString(); if (String.Compare(str, str_1) != 0) { iCountErrors++; Console.WriteLine("Err_0001, ToString() of two default structs: \"{0}\" != \"{1}\"", str, str_1); } Console.WriteLine("2. two random vectors"); DateTime time = DateTime.Now; data = time.DayOfYear + time.Hour + time.Minute + time.Second; System.Random random = new System.Random(data); data = random.Next(System.Int32.MinValue, System.Int32.MaxValue); iCountTestcases++; bv32 = new BitVector32(data); bv32_1 = new BitVector32(data); str = bv32.ToString(); str_1 = bv32_1.ToString(); if (String.Compare(str, str_1) != 0) { iCountErrors++; Console.WriteLine("Err_0002, ToString() of two equal vectors: \"{0}\" != \"{1}\"", str, str_1); } Console.WriteLine("3. two different vectors"); strLoc = "Loc_003oo"; iCountTestcases++; bv32 = new BitVector32(data); if (data < Int32.MaxValue) data++; else data--; bv32_1 = new BitVector32(data); str = bv32.ToString(); str_1 = bv32_1.ToString(); if (String.Compare(str, str_1) == 0) { iCountErrors++; Console.WriteLine("Err_0003, ToString() of two different vectors: \"{0}\" == \"{1}\"", str, str_1); } Console.WriteLine("4. same vector - default struct"); strLoc = "Loc_004oo"; iCountTestcases++; bv32 = new BitVector32(); str = bv32.ToString(); str_1 = bv32.ToString(); if (String.Compare(str, str_1) != 0) { iCountErrors++; Console.WriteLine("Err_0004, ToString() of the same default struct: \"{0}\" != \"{1}\"", str, str_1); } Console.WriteLine("5. same vector"); strLoc = "Loc_005oo"; iCountTestcases++; bv32 = new BitVector32(data); str = bv32.ToString(); str_1 = bv32.ToString(); if (String.Compare(str, str_1) != 0) { iCountErrors++; Console.WriteLine("Err_0005, ToString() of the same vector: \"{0}\" != \"{1}\"", str, str_1); } data = 0; Console.WriteLine("6. two vectors({0})", data); strLoc = "Loc_006oo"; iCountTestcases++; bv32 = new BitVector32(data); bv32_1 = new BitVector32(data); str = bv32.ToString(); str_1 = bv32_1.ToString(); if (String.Compare(str, str_1) != 0) { iCountErrors++; Console.WriteLine("Err_0006, ToString() of two {2}-vectors: \"{0}\" != \"{1}\"", str, str_1, data); } data = 1; Console.WriteLine("7. two vectors({0})", data); strLoc = "Loc_007oo"; iCountTestcases++; bv32 = new BitVector32(data); bv32_1 = new BitVector32(data); str = bv32.ToString(); str_1 = bv32_1.ToString(); if (String.Compare(str, str_1) != 0) { iCountErrors++; Console.WriteLine("Err_0007, ToString() of two {2}-vectors: \"{0}\" != \"{1}\"", str, str_1, data); } data = -1; Console.WriteLine("8. two vectors({0})", data); strLoc = "Loc_008oo"; iCountTestcases++; bv32 = new BitVector32(data); bv32_1 = new BitVector32(data); str = bv32.ToString(); str_1 = bv32_1.ToString(); if (String.Compare(str, str_1) != 0) { iCountErrors++; Console.WriteLine("Err_0008, ToString() of two {2}-vectors: \"{0}\" != \"{1}\"", str, str_1, data); } data = Int32.MaxValue; Console.WriteLine("9. two vectors({0})", data); strLoc = "Loc_009oo"; iCountTestcases++; bv32 = new BitVector32(data); bv32_1 = new BitVector32(data); str = bv32.ToString(); str_1 = bv32_1.ToString(); if (String.Compare(str, str_1) != 0) { iCountErrors++; Console.WriteLine("Err_0009, ToString() of two {2}-vectors: \"{0}\" != \"{1}\"", str, str_1, data); } data = Int32.MinValue; Console.WriteLine("10. two vectors({0})", data); strLoc = "Loc_010oo"; iCountTestcases++; bv32 = new BitVector32(data); bv32_1 = new BitVector32(data); str = bv32.ToString(); str_1 = bv32_1.ToString(); if (String.Compare(str, str_1) != 0) { iCountErrors++; Console.WriteLine("Err_0010, ToString() of two {2}-vectors: \"{0}\" != \"{1}\"", str, str_1, data); } Console.WriteLine("11. contains \"BitVector32\""); strLoc = "Loc_011oo"; iCountTestcases++; time = DateTime.Now; data = time.DayOfYear + time.Hour + time.Minute + time.Second; random = new System.Random(data); data = random.Next(System.Int32.MinValue, System.Int32.MaxValue); bv32 = new BitVector32(data); str = bv32.ToString(); Console.WriteLine("ToString() returns: " + str); if (str.IndexOf("BitVector32") == -1) { iCountErrors++; Console.WriteLine("Err_0011, ToString() doesn't contain \"BitVector32\""); } } catch (Exception exc_general ) { ++iCountErrors; Console.WriteLine (s_strTFAbbrev + " : Error Err_general! strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString()); } if ( iCountErrors == 0 ) { Console.WriteLine( "Pass. "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases); return true; } else { Console.WriteLine("Fail! "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums ); return false; } }
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; } }
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; int [] bits = { 0, 1, 2, 3, 7, 15, 16, Int16.MaxValue, Int32.MaxValue - 1, Int32.MinValue, Int16.MinValue, -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); } bool expected = false; for (int i = 0; i < bits.Length; i++) { iCountTestcases++; bv32[bits[i]] = true; if (i==9 || i == 10 || i == 11) expected = false; else expected = true; if (bv32[bits[i]] != expected) { iCountErrors++; Console.WriteLine("Err_0001_{0}a, bit[{3}]: returned {1} instead of {2}", i, bv32[bits[i]], true, bits[i]); } iCountTestcases++; if (bv32.Data != bits[i]) { iCountErrors++; Console.WriteLine("Err_0001_{0}b, Data returned {1} instead of {2}", i, bv32.Data, bits[i]); } iCountTestcases++; bv32[bits[i]] = false; if (i==0) expected = true; else expected = false; if (bv32[bits[i]] != expected) { iCountErrors++; Console.WriteLine("Err_0001_{0}c, bit[{3}]: returned {1} instead of {2}", i, bv32[bits[i]], expected, bits[i]); } iCountTestcases++; if (bv32.Data != 0) { iCountErrors++; Console.WriteLine("Err_0001_{0}d, Data returned {1} instead of {2}", i, bv32.Data, 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 < bits.Length; i++) { iCountTestcases++; bv32[bits[i]] = false; if (i==0) expected = true; else expected = false; if (bv32[bits[i]] != expected) { iCountErrors++; Console.WriteLine("Err_0002_{0}a, bit[{3}]: returned {1} instead of {2}", i, bv32[bits[i]], expected, bits[i]); } iCountTestcases++; if (bv32.Data != ~bits[i]) { iCountErrors++; Console.WriteLine("Err_0002_{0}b, Data returned {1} instead of {2}", i, bv32.Data, ~bits[i]); } if (i==9 || i == 10 || i == 11) expected = false; else expected = true; iCountTestcases++; bv32[bits[i]] = true; if (bv32[bits[i]] != expected) { iCountErrors++; Console.WriteLine("Err_0002_{0}c, bit[{3}]: returned {1} instead of {2}", i, bv32[bits[i]], true, bits[i]); } iCountTestcases++; if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0002_{0}d, Data returned {1} instead of {2}", i, bv32.Data, data); } } for (int i = 0; i < bits.Length; i++) { int ind = i+3; data = bits[i]; Console.WriteLine((ind).ToString() + ". BitVector32({0})", data); strLoc = "Loc_00" + ind + "oo"; bv32 = new BitVector32(data); Console.WriteLine(" " + bv32.ToString()); iCountTestcases++; if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_000{1}, Data = {0} ", bv32.Data, ind); } iCountTestcases++; bv32[bits[i]] = false; if (i==0) expected = true; else expected = false; if (bv32[bits[i]] != expected) { iCountErrors++; Console.WriteLine("Err_000{4}_{0}a, bit[{3}]: returned {1} instead of {2}", i, bv32[bits[i]], expected, bits[i], ind); } iCountTestcases++; if (bv32.Data != 0) { iCountErrors++; Console.WriteLine("Err_000{4}_{0}b, Data returned {1} instead of {2}", i, bv32.Data, 0, ind); } iCountTestcases++; bv32[bits[i]] = true; if (i==9 || i == 10 || i == 11) expected = false; else expected = true; if (bv32[bits[i]] != expected) { iCountErrors++; Console.WriteLine("Err_000{4}_{0}c, bit[{3}]: returned {1} instead of {2}", i, bv32[bits[i]], true, bits[i], ind); } iCountTestcases++; if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_000{3}_{0}d, Data returned {1} instead of {2}", i, bv32.Data, data, ind); } } } 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; } }
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; try { Console.WriteLine("1. default ctor"); strLoc = "Loc_001oo"; iCountTestcases++; bv32 = new BitVector32(); if (bv32.Data != 0) { iCountErrors++; Console.WriteLine("Err_0001, Data = {0} after default ctor", bv32.Data); } data = 0; Console.WriteLine("2. ctor({0})", data); strLoc = "Loc_002oo"; iCountTestcases++; bv32 = new BitVector32(data); if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0002, Data = {0} after ctor({1})", bv32.Data, data); } data = 1; Console.WriteLine("3. ctor({0})", data); strLoc = "Loc_003oo"; iCountTestcases++; bv32 = new BitVector32(data); if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0003, Data = {0} after ctor({1})", bv32.Data, data); } data = -1; Console.WriteLine("4. ctor({0})", data); strLoc = "Loc_004oo"; iCountTestcases++; bv32 = new BitVector32(data); if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0004, Data = {0} after ctor({1})", bv32.Data, data); } data = 2; Console.WriteLine("5. ctor({0})", data); strLoc = "Loc_005oo"; iCountTestcases++; bv32 = new BitVector32(data); if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0005, Data = {0} after ctor({1})", bv32.Data, data); } data = 10; Console.WriteLine("6. ctor({0})", data); strLoc = "Loc_006oo"; iCountTestcases++; bv32 = new BitVector32(data); if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0006, Data = {0} after ctor({1})", bv32.Data, data); } data = 99; Console.WriteLine("7. ctor({0})", data); strLoc = "Loc_007oo"; iCountTestcases++; bv32 = new BitVector32(data); if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0007, Data = {0} after ctor({1})", bv32.Data, data); } data = -9; Console.WriteLine("8. ctor({0})", data); strLoc = "Loc_008oo"; iCountTestcases++; bv32 = new BitVector32(data); if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0008, Data = {0} after ctor({1})", bv32.Data, data); } data = System.Int32.MinValue; Console.WriteLine("9. ctor({0})", data); strLoc = "Loc_009oo"; iCountTestcases++; bv32 = new BitVector32(data); if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0009, Data = {0} after ctor({1})", bv32.Data, data); } data = System.Int32.MaxValue; Console.WriteLine("10. ctor({0})", data); strLoc = "Loc_010oo"; iCountTestcases++; bv32 = new BitVector32(data); if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0010, Data = {0} after ctor({1})", bv32.Data, data); } data = System.Int32.MinValue / 2; Console.WriteLine("11. ctor({0})", data); strLoc = "Loc_011oo"; iCountTestcases++; bv32 = new BitVector32(data); if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0011, Data = {0} after ctor({1})", bv32.Data, data); } data = System.Int32.MaxValue / 2; Console.WriteLine("12. ctor({0})", data); strLoc = "Loc_012oo"; iCountTestcases++; bv32 = new BitVector32(data); if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0012, Data = {0} after ctor({1})", bv32.Data, data); } DateTime time = DateTime.Now; data = time.DayOfYear + time.Hour + time.Minute + time.Second; System.Random random = new System.Random(data); data = random.Next(System.Int32.MinValue, System.Int32.MaxValue); Console.WriteLine("13. ctor(random data: {0})", data); strLoc = "Loc_013oo"; iCountTestcases++; bv32 = new BitVector32(data); if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0013, Data = {0} after ctor({1})", bv32.Data, data); } data = 7; Console.WriteLine("14. access Data on BitVector32({0})", data); strLoc = "Loc_014oo"; iCountTestcases++; bv32 = new BitVector32(data); Console.WriteLine(" a. check Data"); if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0014a, Data = {0} after ctor({1})", bv32.Data, data); } iCountTestcases++; int mask = BitVector32.CreateMask(); Console.WriteLine(" b. access via Mask " + mask); strLoc = "Loc_014oo"; if ((bv32.Data & mask) != mask) { iCountErrors++; Console.WriteLine("Err_0014b, {0} & {1} != {1}", bv32.Data, mask); } iCountTestcases++; BitVector32.Section sect = BitVector32.CreateSection(1); Console.WriteLine(" c. access via Section {0}", sect.ToString()); Console.WriteLine(" - get section value"); strLoc = "Loc_015oo"; if ((bv32[sect]) != 1) { iCountErrors++; Console.WriteLine("Err_0014c, bv32[{0}] != {1}", sect, 1); } Console.WriteLine(" - set section value and verify Data"); bv32[sect] = 0; if (bv32.Data != 6) { iCountErrors++; Console.WriteLine("Err_0014c, Data: {0} != {1}", bv32.Data, 6); } iCountTestcases++; strLoc = "Loc_016oo"; sect = BitVector32.CreateSection(5); Console.WriteLine(" d. access via Section {0}", sect.ToString()); Console.WriteLine(" - get section value"); if ((bv32[sect]) != bv32.Data) { iCountErrors++; Console.WriteLine("Err_0014d, bv32[{0}] != {1}", sect, bv32.Data); } Console.WriteLine(" - set section value and verify Data"); bv32[sect] = 0; if (bv32.Data != 0) { iCountErrors++; Console.WriteLine("Err_0014e, Data: {0} != {1}", bv32.Data, 0); } data = -1; Console.WriteLine("15. access Data on BitVector32({0})", data); strLoc = "Loc_017oo"; iCountTestcases++; bv32 = new BitVector32(data); Console.WriteLine(" a. check Data"); if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0015a, Data = {0} after ctor({1})", bv32.Data, data); } iCountTestcases++; strLoc = "Loc_018oo"; sect = BitVector32.CreateSection(1); sect = BitVector32.CreateSection(Int16.MaxValue, sect); sect = BitVector32.CreateSection(Int16.MaxValue, sect); sect = BitVector32.CreateSection(1, sect); Console.WriteLine(" b. access via Section: {0} - offset {1} - sign bit", sect.ToString(), (int)sect.Offset); Console.WriteLine(" " + bv32.ToString()); bv32[sect] = 0; if (bv32.Data != Int32.MaxValue) { iCountErrors++; Console.WriteLine("Err_0015b, Data: {0} != {1}", bv32.Data, Int32.MaxValue); } } 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( "Pass. "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases); return true; } else { Console.WriteLine("Fail! "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums ); return false; } }
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; int [] bits = { 0, 1, 2, 3, 7, 15, 16, Int16.MaxValue, Int32.MaxValue - 1, Int32.MinValue, Int16.MinValue, -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); } bool expected = false; for (int i = 0; i < bits.Length; i++) { iCountTestcases++; if (i == 0) expected = true; else expected = false; if (bv32[bits[i]] != expected) { iCountErrors++; Console.WriteLine("Err_0001_{0}, bit[{3}]: returned {1} instead of {2}", i, bv32[bits[i]], expected, bits[i]); } } 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 < bits.Length; i++) { iCountTestcases++; if (i == 9 || i == 10 || i == 11) expected = false; else expected = true; if (bv32[bits[i]] != expected) { iCountErrors++; string temp = "Err_0002_" + i; Console.WriteLine("{0}: bit[{3}]: returned {1} instead of {2}", temp, bv32[bits[i]], expected, bits[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); } for (int i = 0; i < bits.Length; i++) { iCountTestcases++; if (i == (bits.Length-1) || i == (bits.Length-2) || i == (bits.Length-3)) expected = false; else expected = true; if (bv32[bits[i]] != expected) { iCountErrors++; string temp = "Err_0003_" + i; Console.WriteLine("{0}: bit[{3}]: returned {1} instead of {2}", temp, bv32[bits[i]], expected, bits[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); } for (int i = 0; i < bits.Length; i++) { iCountTestcases++; if (i == 0) expected = true; else expected = false; if (bv32[bits[i]] != expected) { iCountErrors++; string temp = "Err_0004_" + i; Console.WriteLine("{0}: bit[{3}]: returned {1} instead of {2}", temp, bv32[bits[i]], expected, bits[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); } for (int i = 0; i < bits.Length; i++) { iCountTestcases++; if (i == 0 || i == 1) expected = true; else expected = false; if (bv32[bits[i]] != expected) { iCountErrors++; string temp = "Err_0005_" + i; Console.WriteLine("{0}: bit[{3}]: returned {1} instead of {2}", temp, bv32[bits[i]], expected, bits[i]); } } data = 2; Console.WriteLine("6. BitVector32({0})", data); strLoc = "Loc_006oo"; bv32 = new BitVector32(data); Console.WriteLine(" " + bv32.ToString()); iCountTestcases++; if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0006, Data = {0} ", bv32.Data); } for (int i = 0; i < bits.Length; i++) { iCountTestcases++; if (i == 0 || i == 2) expected = true; else expected = false; if (bv32[bits[i]] != expected) { iCountErrors++; string temp = "Err_0006_" + i; Console.WriteLine("{0}: bit[{3}]: returned {1} instead of {2}", temp, bv32[bits[i]], expected, bits[i]); } } data = 3; Console.WriteLine("6. BitVector32({0})", data); strLoc = "Loc_006oo"; bv32 = new BitVector32(data); Console.WriteLine(" " + bv32.ToString()); iCountTestcases++; if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0006, Data = {0} ", bv32.Data); } for (int i = 0; i < bits.Length; i++) { iCountTestcases++; if (i < 4) expected = true; else expected = false; if (bv32[bits[i]] != expected) { iCountErrors++; string temp = "Err_0006_" + i; Console.WriteLine("{0}: bit[{3}]: returned {1} instead of {2}", temp, bv32[bits[i]], expected, bits[i]); } } data = 7; Console.WriteLine("7. BitVector32({0})", data); strLoc = "Loc_007oo"; bv32 = new BitVector32(data); Console.WriteLine(" " + bv32.ToString()); iCountTestcases++; if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0007, Data = {0} ", bv32.Data); } for (int i = 0; i < bits.Length; i++) { iCountTestcases++; if (i < 5) expected = true; else expected = false; if (bv32[bits[i]] != expected) { iCountErrors++; string temp = "Err_0007_" + i; Console.WriteLine("{0}: bit[{3}]: returned {1} instead of {2}", temp, bv32[bits[i]], expected, bits[i]); } } data = Int16.MaxValue; Console.WriteLine("8. BitVector32({0}) - Int16.MaxValue", data); strLoc = "Loc_008oo"; bv32 = new BitVector32(data); Console.WriteLine(" " + bv32.ToString()); iCountTestcases++; if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0008, Data = {0} ", bv32.Data); } for (int i = 0; i < bits.Length; i++) { iCountTestcases++; if (i < 8) expected = true; else expected = false; if (bv32[bits[i]] != expected) { iCountErrors++; string temp = "Err_0008_" + i; Console.WriteLine("{0}: bit[{3}]: returned {1} instead of {2}", temp, bv32[bits[i]], expected, bits[i]); } } data = Int16.MinValue; Console.WriteLine("9. BitVector32({0}) - Int16.MomValue", data); strLoc = "Loc_009oo"; bv32 = new BitVector32(data); Console.WriteLine(" " + bv32.ToString()); iCountTestcases++; if (bv32.Data != data) { iCountErrors++; Console.WriteLine("Err_0009, Data = {0} ", bv32.Data); } for (int i = 0; i < bits.Length; i++) { iCountTestcases++; if (i == 0) expected = true; else expected = false; if (bv32[bits[i]] != expected) { iCountErrors++; string temp = "Err_0009_" + i; Console.WriteLine("{0}: bit[{3}]: returned {1} instead of {2}", temp, bv32[bits[i]], expected, bits[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; } }
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; BitVector32 bv32Temp; try { Console.WriteLine("--- default ctor ---"); strLoc = "Loc_001oo"; iCountTestcases++; bv32 = new BitVector32(); Console.WriteLine("1. check Data"); if (bv32.Data != 0) { iCountErrors++; Console.WriteLine("Err_0001, Data = {0} after default ctor", bv32.Data); } iCountTestcases++; Console.WriteLine("2. check returned Type"); string type = bv32.GetType().ToString().Trim(); Console.WriteLine(" GetType(): " + type); if (type.IndexOf("BitVector32") == -1) { iCountErrors++; Console.WriteLine("Err_0002: returned type doesn't contain \"BitVector32\""); } bv32Temp = new BitVector32(3); string type1 = bv32Temp.GetType().ToString().Trim(); if (String.Compare(type, type1) != 0) { iCountErrors++; Console.WriteLine("Err_0003: returned types of two vectors differ"); } iCountTestcases++; Console.WriteLine("3. call ToString()"); string result = bv32.ToString(); Console.WriteLine(" ToString(): " + result); if (result.IndexOf("BitVector32") == -1) { iCountErrors++; Console.WriteLine("Err_0004: ToString() doesn't contain \"BitVector32\""); } iCountTestcases++; Console.WriteLine("4. Item(1)"); bool item = bv32[1]; Console.WriteLine(" Item(1): " + item); if (item) { iCountErrors++; Console.WriteLine("Err_0005: Item(0) returned {0} instead of {1}", item, false); } iCountTestcases++; Console.WriteLine("5. Equals"); bv32Temp = new BitVector32(); if (! bv32.Equals(bv32Temp) ) { iCountErrors++; Console.WriteLine("Err_0006: two default vectors are not equal"); } } catch (Exception exc_general ) { ++iCountErrors; Console.WriteLine (s_strTFAbbrev + " : Error Err_general! strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString()); } if ( iCountErrors == 0 ) { Console.WriteLine( "Pass. "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases); return true; } else { Console.WriteLine("Fail! "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums ); return false; } }
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; } }
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.Section section; BitVector32.Section sectionArgument; Int16 maxValue = 0; BitVector32 bv32; int expected = 0; try { sectionArgument = BitVector32.CreateSection(1); maxValue = Int16.MinValue; Console.WriteLine("1. CreateSection({0}, section) ~ Int16.MinValue", maxValue); strLoc = "Loc_001oo"; iCountTestcases++; try { section = BitVector32.CreateSection(maxValue, sectionArgument); iCountErrors++; Console.WriteLine(" Err_0001a, no exception for CreateSection({0})", maxValue); } catch (ArgumentException e) { Console.WriteLine(" Expected exception for CreateSection({0}):{1}", maxValue, e.Message); } catch (Exception ex) { iCountErrors++; Console.WriteLine(" Err_0001b, unexpected exception for CreateSection({0}): {1}", maxValue, ex.ToString()); } maxValue = -1; Console.WriteLine("2. CreateSection({0}, section)", maxValue); strLoc = "Loc_002oo"; iCountTestcases++; try { section = BitVector32.CreateSection(maxValue, sectionArgument); iCountErrors++; Console.WriteLine(" Err_0002a, no exception for CreateSection({0})", maxValue); } catch (ArgumentException e) { Console.WriteLine(" Expected exception for CreateSection({0}):{1}", maxValue, e.Message); } catch (Exception ex) { iCountErrors++; Console.WriteLine(" Err_0002b, unexpected exception for CreateSection({0}): {1}", maxValue, ex.ToString()); } maxValue = 0; Console.WriteLine("3. CreateSection({0}, section)", maxValue); strLoc = "Loc_003oo"; iCountTestcases++; try { section = BitVector32.CreateSection(maxValue, sectionArgument); iCountErrors++; Console.WriteLine(" Err_0003a, no exception for CreateSection({0})", maxValue); } catch (ArgumentException e) { Console.WriteLine(" Expected exception for CreateSection({0}):{1}", maxValue, e.Message); } catch (Exception ex) { iCountErrors++; Console.WriteLine(" Err_0003b, unexpected exception for CreateSection({0}): {1}", maxValue, ex.ToString()); } maxValue = 1; Console.WriteLine("4. CreateSection({0}, ({1}, {2}))", maxValue, (int)sectionArgument.Mask, (int)sectionArgument.Offset); strLoc = "Loc_004oo"; iCountTestcases++; section = BitVector32.CreateSection(maxValue, sectionArgument); Console.WriteLine(" returned: ({0}, {1})", section.Mask, section.Offset); if (section.Mask != maxValue || section.Offset != 1) { iCountErrors++; Console.WriteLine(" Err_0004, returned ({1}, {2}) instead of expected ({0}, {3})", maxValue, section.Mask, section.Offset, 1); } sectionArgument = BitVector32.CreateSection(2); maxValue = 1; Console.WriteLine("5. CreateSection({0}, ({1}, {2}))", maxValue, (int)sectionArgument.Mask, (int)sectionArgument.Offset); strLoc = "Loc_005oo"; iCountTestcases++; section = BitVector32.CreateSection(maxValue, sectionArgument); Console.WriteLine(" returned: ({0}, {1})", section.Mask, section.Offset); if (section.Mask != maxValue || section.Offset != 2) { iCountErrors++; Console.WriteLine(" Err_0005, returned ({1}, {2}) instead of expected ({0}, {3})", maxValue, section.Mask, section.Offset, 2); } maxValue = 2; Console.WriteLine("6. CreateSection({0}, ({1}, {2}))", maxValue, (int)sectionArgument.Mask, (int)sectionArgument.Offset); strLoc = "Loc_006oo"; iCountTestcases++; section = BitVector32.CreateSection(maxValue, sectionArgument); Console.WriteLine(" returned: ({0}, {1})", section.Mask, section.Offset); if (section.Mask != 3 || section.Offset != 2) { iCountErrors++; Console.WriteLine(" Err_0006, returned ({1}, {2}) instead of expected ({0}, {3})", 3, section.Mask, section.Offset, 2); } sectionArgument = BitVector32.CreateSection(Int16.MaxValue); maxValue = Int16.MaxValue; expected = 15; Console.WriteLine("7. CreateSection({0}, ({1}, {2}))", maxValue, (int)sectionArgument.Mask, (int)sectionArgument.Offset); strLoc = "Loc_007oo"; iCountTestcases++; section = BitVector32.CreateSection(maxValue, sectionArgument); Console.WriteLine(" returned: ({0}, {1})", section.Mask, section.Offset); if (section.Mask != maxValue || section.Offset != expected) { iCountErrors++; Console.WriteLine(" Err_0007, returned ({1}, {2}) instead of expected ({0}, {3})", maxValue, section.Mask, section.Offset, expected); } sectionArgument = section; expected = 30; Console.WriteLine("8. CreateSection({0}, ({1}, {2}))", maxValue, (int)sectionArgument.Mask, (int)sectionArgument.Offset); strLoc = "Loc_008oo"; iCountTestcases++; section = BitVector32.CreateSection(maxValue, sectionArgument); Console.WriteLine(" returned: ({0}, {1})", section.Mask, section.Offset); if (section.Mask != maxValue || section.Offset != expected) { iCountErrors++; Console.WriteLine(" Err_0008, returned ({1}, {2}) instead of expected ({0}, {3})", maxValue, section.Mask, section.Offset, expected); } Console.WriteLine("10. Linked list of sections with maxValue 1"); maxValue = 1; sectionArgument = BitVector32.CreateSection(maxValue); bv32 = new BitVector32(Int32.MaxValue); Console.WriteLine(" will apply sections to " + bv32.ToString()); for (int i = 1; i < 32; i++) { iCountTestcases++; section = BitVector32.CreateSection(maxValue, sectionArgument); if (section.Mask != maxValue || section.Offset != i) { iCountErrors++; Console.WriteLine(" Err_0010a, returned ({0}, {1}) instead of ({2}, {3})", section.Mask, section.Offset, maxValue, i); } sectionArgument = section; iCountTestcases++; expected = 1; if (i == 31) expected = 0; if (bv32[section] != expected) { iCountErrors++; Console.WriteLine(" Err_0010b_{2}, returned {0} instead of {1} ", bv32[section], expected, i); } iCountTestcases++; bv32[section] = 0; if (bv32[section] != 0) { iCountErrors++; Console.WriteLine(" Err_0010c_{2}, returned {0} instead of {1} ", bv32[section], 0, i); } iCountTestcases++; expected = 1; bv32[section] = 1; if (bv32[section] != expected) { iCountErrors++; Console.WriteLine(" Err_0010d_{2}, returned {0} instead of {1} ", bv32[section], expected, i); if (i == 31 && bv32[section] == -1) Console.WriteLine(" Error "); } } Console.WriteLine("12. Linked list of sections with maxValue 3"); maxValue = 3; sectionArgument = BitVector32.CreateSection(maxValue); bv32 = new BitVector32(Int32.MaxValue); Console.WriteLine(" will apply sections to " + bv32.ToString()); for (int i = 2; i < 32; i+=2) { iCountTestcases++; section = BitVector32.CreateSection(maxValue, sectionArgument); if (section.Mask != maxValue || section.Offset != i) { iCountErrors++; Console.WriteLine(" Err_0012a, returned ({0}, {1}) instead of ({2}, {3})", section.Mask, section.Offset, maxValue, i); } sectionArgument = section; iCountTestcases++; expected = 3; if (i == 30) expected = 1; if (bv32[section] != expected) { iCountErrors++; Console.WriteLine(" Err_0012b_{2}, returned {0} instead of {1} ", bv32[section], expected, i); } iCountTestcases++; bv32[section] = 0; if (bv32[section] != 0) { iCountErrors++; Console.WriteLine(" Err_0012c_{2}, returned {0} instead of {1} ", bv32[section], 0, i); } iCountTestcases++; expected = 3; bv32[section] = expected; if (i == 30) Console.WriteLine(" " + bv32.ToString()); if (bv32[section] != expected) { iCountErrors++; Console.WriteLine(" Err_0012d_{2}, returned {0} instead of {1} ", bv32[section], expected, i); if (i == 30 && bv32[section] == (-1)) Console.WriteLine(" Error "); } } maxValue = 3; bv32 = new BitVector32(-1); Console.WriteLine("14. set section with maxValue {0} to out of range value {1}", maxValue, maxValue * 2); strLoc = "Loc_014oo"; sectionArgument = BitVector32.CreateSection(maxValue); section = BitVector32.CreateSection(maxValue, sectionArgument); Console.WriteLine(" " + bv32.ToString()); Console.WriteLine(" init bv32[section] = " + bv32[section]); iCountTestcases++; } catch (Exception exc_general ) { ++iCountErrors; Console.WriteLine (s_strTFAbbrev + " : Error Err_general! strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString()); } if ( iCountErrors == 0 ) { Console.WriteLine( "Pass. "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases); return true; } else { Console.WriteLine("Fail! "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums ); return false; } }
public static void Main() { // Creates and initializes a BitVector32 with the value 123. // This is the BitVector32 that will be compared to different types. BitVector32 myBV = new BitVector32(123); // Creates and initializes a new BitVector32 which will be set up as sections. BitVector32 myBVsect = new BitVector32(0); // Compares myBV and myBVsect. Console.WriteLine("myBV : {0}", myBV.ToString()); Console.WriteLine("myBVsect : {0}", myBVsect.ToString()); if (myBV.Equals(myBVsect)) { Console.WriteLine(" myBV({0}) equals myBVsect({1}).", myBV.Data, myBVsect.Data); } else { Console.WriteLine(" myBV({0}) does not equal myBVsect({1}).", myBV.Data, myBVsect.Data); } Console.WriteLine(); // Assigns values to the sections of myBVsect. BitVector32.Section mySect1 = BitVector32.CreateSection(5); BitVector32.Section mySect2 = BitVector32.CreateSection(1, mySect1); BitVector32.Section mySect3 = BitVector32.CreateSection(20, mySect2); myBVsect[mySect1] = 3; myBVsect[mySect2] = 1; myBVsect[mySect3] = 7; // Compares myBV and myBVsect. Console.WriteLine("myBV : {0}", myBV.ToString()); Console.WriteLine("myBVsect with values : {0}", myBVsect.ToString()); if (myBV.Equals(myBVsect)) { Console.WriteLine(" myBV({0}) equals myBVsect({1}).", myBV.Data, myBVsect.Data); } else { Console.WriteLine(" myBV({0}) does not equal myBVsect({1}).", myBV.Data, myBVsect.Data); } Console.WriteLine(); // Compare myBV with an Int32. Console.WriteLine("Comparing myBV with an Int32: "); Int32 myInt32 = 123; // Using Equals will fail because Int32 is not compatible with BitVector32. if (myBV.Equals(myInt32)) { Console.WriteLine(" Using BitVector32.Equals, myBV({0}) equals myInt32({1}).", myBV.Data, myInt32); } else { Console.WriteLine(" Using BitVector32.Equals, myBV({0}) does not equal myInt32({1}).", myBV.Data, myInt32); } // To compare a BitVector32 with an Int32, use the "==" operator. if (myBV.Data == myInt32) { Console.WriteLine(" Using the \"==\" operator, myBV.Data({0}) equals myInt32({1}).", myBV.Data, myInt32); } else { Console.WriteLine(" Using the \"==\" operator, myBV.Data({0}) does not equal myInt32({1}).", myBV.Data, myInt32); } }
public static void ToStringTest(int data, string expected) { Assert.Equal(expected, new BitVector32(data).ToString()); Assert.Equal(expected, BitVector32.ToString(new BitVector32(data))); }
public static void EscribirBitsDeInteger(int valor) { BitVector32 bv32 = new BitVector32(valor); System.Console.WriteLine(bv32.ToString()); }