public void TestGetValueN() { { bool errorThrown = false; try { char[] c = new Char[2]; c.GetValue((int [])null); } catch (ArgumentNullException) { errorThrown = true; } Assert("#I61a", errorThrown); } { bool errorThrown = false; try { char[] c = new Char[2]; int[] coords = {1, 1}; c.GetValue(coords); } catch (ArgumentException) { errorThrown = true; } Assert("#I62", errorThrown); } { bool errorThrown = false; try { char[,] c = new Char[2,2]; int[] coords = {-1, 1}; c.GetValue(coords); } catch (IndexOutOfRangeException) { errorThrown = true; } Assert("#I63", errorThrown); } { bool errorThrown = false; try { char[,] c = new Char[2,2]; int[] coords = {4, 1}; c.GetValue(coords); } catch (IndexOutOfRangeException) { errorThrown = true; } Assert("#I64", errorThrown); } char[,] c1 = new Char[4,6]; for (int i = 0; i < 24; i++) { int first = i / 6; int second = i % 6; c1[first,second] = (char)(((int)'a')+i); } for (int i = 0; i < c1.GetLength(0); i++) { for (int j = 0; j < c1.GetLength(1); j++) { int[] coords = {i, j}; AssertEquals("#I65(" + i + "," + j + ")", c1[i,j], c1.GetValue(coords)); } } }
public void TestGetValueLongArray() { char[] c = new Char[2]; c.GetValue((long [])null); }
public void TestGetValue2() { { bool errorThrown = false; try { char[] c = new Char[2]; c.GetValue(1,1); } catch (ArgumentException) { errorThrown = true; } Assert("#I21", errorThrown); } { bool errorThrown = false; try { char[,] c = new Char[2,2]; c.GetValue(-1, 1); } catch (IndexOutOfRangeException) { errorThrown = true; } Assert("#I22", errorThrown); } { bool errorThrown = false; try { char[,] c = new Char[2,2]; c.GetValue(4,1); } catch (IndexOutOfRangeException) { errorThrown = true; } Assert("#I23", errorThrown); } char[,] c1 = new Char[4,6]; for (int i = 0; i < 24; i++) { int first = i / 6; int second = i % 6; c1[first,second] = (char)(((int)'a')+i); } for (int i = 0; i < c1.GetLength(0); i++) { for (int j = 0; j < c1.GetLength(1); j++) { AssertEquals("#I24(" + i + "," + j + ")", c1[i,j], c1.GetValue(i, j)); } } }
public void TestGetValue3() { { bool errorThrown = false; try { char[] c = new Char[2]; c.GetValue(1,1,1); } catch (ArgumentException) { errorThrown = true; } Assert("#I41", errorThrown); } { bool errorThrown = false; try { char[,,] c = new Char[2,2,2]; c.GetValue(-1, 1, 1); } catch (IndexOutOfRangeException) { errorThrown = true; } Assert("#I42", errorThrown); } { bool errorThrown = false; try { char[,,] c = new Char[2,2,2]; c.GetValue(4,1,1); } catch (IndexOutOfRangeException) { errorThrown = true; } Assert("#I43", errorThrown); } char[,,] c1 = new Char[4,2,3]; for (int i = 0; i < 24; i++) { int first = i / 6; int remains = i % 6; int second = remains / 3; int third = remains % 3; c1[first,second, third] = (char)(((int)'a')+i); } for (int i = 0; i < c1.GetLength(0); i++) { for (int j = 0; j < c1.GetLength(1); j++) { for (int k = 0; k < c1.GetLength(2); k++) { AssertEquals("#I44(" + i + "," + j + ")", c1[i,j,k], c1.GetValue(i,j,k)); } } } }
public void TestGetValue1() { { bool errorThrown = false; try { char[,] c = new Char[2,2]; c.GetValue(1); } catch (ArgumentException) { errorThrown = true; } Assert("#I01", errorThrown); } { bool errorThrown = false; try { char[] c = {'a', 'b', 'c'}; c.GetValue(-1); } catch (IndexOutOfRangeException) { errorThrown = true; } Assert("#I02", errorThrown); } { bool errorThrown = false; try { char[] c = {'a', 'b', 'c'}; c.GetValue(4); } catch (IndexOutOfRangeException) { errorThrown = true; } Assert("#I03", errorThrown); } char[] c1 = {'a', 'b', 'c', 'd'}; for (int i = 0; i < c1.Length; i++) { AssertEquals("#I04(" + i + ")", c1[i], c1.GetValue(i)); } }