So, I have no idea how to make a patch. These two use 'svn diff' and
seem to work, but if they don't I am terribly sorry.
Index: Kernel/Tests/CS/Array.cs
===================================================================
--- Kernel/Tests/CS/Array.cs (revision 731)
+++ Kernel/Tests/CS/Array.cs (working copy)
@@ -2,7 +2,7 @@
// (C) 2006-2007 The SharpOS Project Team (http://www.sharpos.org)
//
// Authors:
-// William Lahti <[EMAIL PROTECTED]>
+// William Lahti <[EMAIL PROTECTED]>
//
// Licensed under the terms of the GNU GPL v3,
// with Classpath Linking Exception for Libraries
@@ -12,221 +12,1029 @@
namespace SharpOS.Kernel.Tests.CS {
#if false
- public unsafe class Array {
+ public unsafe class Array {
- /// <summary>
- /// int[] read/write
- /// </summary>
- public static uint CMPIntArray ()
- {
- int [] arr = new int [3];
+ /// <summary>
+ /// int[] read/write
+ /// </summary>
+ public static uint CMPIntArray ()
+ {
+ int [] arr = new int [3];
- arr [0] = 7;
- arr [1] = 9;
- arr [2] = 44;
-
- if (arr [0] != 7)
- return 0;
+ arr [0] = 7;
+ arr [1] = 9;
+ arr [2] = 44;
+
+ if (arr [0] != 7)
+ return 0;
- if (arr [1] != 9)
- return 0;
+ if (arr [1] != 9)
+ return 0;
- if (arr [2] != 44)
- return 0;
+ if (arr [2] != 44)
+ return 0;
- return 1;
- }
-
- /// <summary>
- /// short[] read/write
- /// </summary>
- public static uint CMPShortArray ()
- {
- short [] arr = new short [3];
+ return 1;
+ }
+
+ /// <summary>
+ /// int[][] read/write
+ /// </summary>
+ public static uint CMPIntJaggedArray ()
+ {
+ int [][] arr = new int [3][];
- arr [0] = 7;
- arr [1] = 9;
- arr [2] = 44;
-
- if (arr [0] != 7)
- return 0;
+ arr [0] = new int [5];
+ arr [1] = new int [3];
+ arr [2] = new int [2];
+
+ arr[0][0] = 39;
+ arr[0][1] = 7;
+ arr[0][2] = 1009;
+ arr[0][3] = -22;
+ arr[0][4] = 1;
+
+ arr[1][0] = 88887;
+ arr[1][1] = -987788;
+ arr[1][2] = 0;
+
+ arr[2][0] = 6;
+ arr[2][1] = arr[0][0]*arr[2][0];
+
+ if (arr[0][0] != 39)
+ return 0;
+
+ if (arr[0][1] != 7)
+ return 0;
+
+ if (arr[0][2] != 1009)
+ return 0;
+
+ if (arr[0][3] != -22)
+ return 0;
+
+ if (arr[0][4] != 1)
+ return 0;
+
+
+
+ if (arr[1][0] != 88887)
+ return 0;
+
+ if (arr[1][1] != -987788)
+ return 0;
+
+ if (arr[1][2] != 0)
+ return 0;
+
+
+ if (arr[2][0] != 6)
+ return 0;
+
+ if (arr[2][1] != 39*6)
+ return 0;
+
+ return 1;
+ }
+
+ /// <summary>
+ /// int[,] read/write
+ /// </summary>
+ public static uint CMPIntMultidimentionalArray ()
+ {
+ int [,] arr = new int [3,2];
+
+ arr[0,0] = 39;
+ arr[0,1] = 7;
+
+ arr[1,0] = 88887;
+ arr[1,1] = -987788;
+
+ arr[2,0] = 6;
+ arr[2,1] = arr[0,0]*arr[2,0];
+
+ if (arr[0,0] != 39)
+ return 0;
+
+ if (arr[0,1] != 7)
+ return 0;
+
+
+
+ if (arr[1,0] != 88887)
+ return 0;
+
+ if (arr[1,1] != -987788)
+ return 0;
+
+
+
+ if (arr[2,0] != 6)
+ return 0;
+
+ if (arr[2,1] != 39*6)
+ return 0;
+
+ return 1;
+ }
+
+
+
+ /// <summary>
+ /// short[] read/write
+ /// </summary>
+ public static uint CMPShortArray ()
+ {
+ short [] arr = new short [3];
- if (arr [1] != 9)
- return 0;
+ arr [0] = 7;
+ arr [1] = 9;
+ arr [2] = 44;
+
+ if (arr [0] != 7)
+ return 0;
- if (arr [2] != 44)
- return 0;
+ if (arr [1] != 9)
+ return 0;
- return 1;
- }
-
- /// <summary>
- /// byte[] read/write
- /// </summary>
- public static uint CMPByteArray ()
- {
- byte [] arr = new byte [3];
+ if (arr [2] != 44)
+ return 0;
- arr [0] = 7;
- arr [1] = 9;
- arr [2] = 44;
-
- if (arr [0] != 7)
- return 0;
+ return 1;
+ }
+
+ /// <summary>
+ /// Short[][] read/write
+ /// </summary>
+ public static uint CMPShortJaggedArray ()
+ {
+ short [][] arr = new short [3][];
- if (arr [1] != 9)
- return 0;
+ arr [0] = new short [5];
+ arr [1] = new short [3];
+ arr [2] = new short [2];
+
+ arr[0][0] = 39;
+ arr[0][1] = 7;
+ arr[0][2] = 1009;
+ arr[0][3] = -22;
+ arr[0][4] = 1;
+
+ arr[1][0] = 667;
+ arr[1][1] = -876;
+ arr[1][2] = 0;
+
+ arr[2][0] = 6;
+ arr[2][1] = 39*6;
+
+ if (arr[0][0] != 39)
+ return 0;
+
+ if (arr[0][1] != 7)
+ return 0;
+
+ if (arr[0][2] != 1009)
+ return 0;
+
+ if (arr[0][3] != -22)
+ return 0;
+
+ if (arr[0][4] != 1)
+ return 0;
+
+
+
+ if (arr[1][0] != 667)
+ return 0;
+
+ if (arr[1][1] != -876)
+ return 0;
+
+ if (arr[1][2] != 0)
+ return 0;
+
+
+ if (arr[2][0] != 6)
+ return 0;
+
+ if (arr[2][1] != 39*6)
+ return 0;
+
+ return 1;
+ }
+
+ /// <summary>
+ /// short[,] read/write
+ /// </summary>
+ public static uint CMPShortMultidimentionalArray ()
+ {
+ short [,] arr = new short [3,2];
+
+ arr[0,0] = 39;
+ arr[0,1] = 7;
+
+ arr[1,0] = 667;
+ arr[1,1] = -876;
+
+ arr[2,0] = 6;
+ arr[2,1] = (short)(arr[0,0]*arr[2,0]);
+
+ if (arr[0,0] != 39)
+ return 0;
+
+ if (arr[0,1] != 7)
+ return 0;
+
+
+
+ if (arr[1,0] != 667)
+ return 0;
+
+ if (arr[1,1] != -876)
+ return 0;
+
+
+
+ if (arr[2,0] != 6)
+ return 0;
+
+ if (arr[2,1] != 39*6)
+ return 0;
+
+ return 1;
+ }
+
+ /// <summary>
+ /// byte[] read/write
+ /// </summary>
+ public static uint CMPByteArray ()
+ {
+ byte [] arr = new byte [3];
- if (arr [2] != 44)
- return 0;
+ arr [0] = 7;
+ arr [1] = 9;
+ arr [2] = 44;
+
+ if (arr [0] != 7)
+ return 0;
- return 1;
- }
+ if (arr [1] != 9)
+ return 0;
- /// <summary>
- /// int[] read/write
- /// </summary>
- public static uint CMPLongArray ()
- {
- long [] arr = new long [3];
+ if (arr [2] != 44)
+ return 0;
- arr [0] = 7;
- arr [1] = 9;
- arr [2] = 44;
-
- if (arr [0] != 7)
- return 0;
+ return 1;
+ }
+
+ /// <summary>
+ /// Byte[][] read/write
+ /// </summary>
+ public static uint CMPByteJaggedArray ()
+ {
+ byte [][] arr = new byte [3][];
- if (arr [1] != 9)
- return 0;
+ arr [0] = new byte [5];
+ arr [1] = new byte [3];
+ arr [2] = new byte [2];
+
+ arr[0][0] = 39;
+ arr[0][1] = 7;
+ arr[0][2] = 76;
+ arr[0][3] = 22;
+ arr[0][4] = 1;
+
+ arr[1][0] = 99;
+ arr[1][1] = 87;
+ arr[1][2] = 0;
+
+ arr[2][0] = 6;
+ arr[2][1] = (byte)(arr[0][0]*arr[2][0]);
+
+ if (arr[0][0] != 39)
+ return 0;
+
+ if (arr[0][1] != 7)
+ return 0;
+
+ if (arr[0][2] != 76)
+ return 0;
+
+ if (arr[0][3] != 22)
+ return 0;
+
+ if (arr[0][4] != 1)
+ return 0;
+
+
+
+ if (arr[1][0] != 99)
+ return 0;
+
+ if (arr[1][1] != 87)
+ return 0;
+
+ if (arr[1][2] != 0)
+ return 0;
+
+
+ if (arr[2][0] != 6)
+ return 0;
+
+ if (arr[2][1] != 39*6)
+ return 0;
+
+ return 1;
+ }
+
+
+ /// <summary>
+ /// byte[,] read/write
+ /// </summary>
+ public static uint CMPByteMultidimentionalArray ()
+ {
+ byte [,] arr = new byte [3,2];
+
+ arr[0,0] = 39;
+ arr[0,1] = 7;
+
+ arr[1,0] = 123;
+ arr[1,1] = 24;
+
+ arr[2,0] = 6;
+ arr[2,1] = (byte)(arr[0,0]*arr[2,0]);
+
+ if (arr[0,0] != 39)
+ return 0;
+
+ if (arr[0,1] != 7)
+ return 0;
+
+
+
+ if (arr[1,0] != 123)
+ return 0;
+
+ if (arr[1,1] != 24)
+ return 0;
+
+
+
+ if (arr[2,0] != 6)
+ return 0;
+
+ if (arr[2,1] != 39*6)
+ return 0;
+
+ return 1;
+ }
+ /// <summary>
+ /// Long[] read/write
+ /// </summary>
+ public static uint CMPLongArray ()
+ {
+ long [] arr = new long [3];
- if (arr [2] != 44)
- return 0;
+ arr [0] = 7;
+ arr [1] = 9;
+ arr [2] = 44;
+
+ if (arr [0] != 7)
+ return 0;
- return 1;
- }
- ///////////////////
+ if (arr [1] != 9)
+ return 0;
- /// <summary>
- /// uint[] read/write
- /// </summary>
- public static uint CMPUIntArray ()
- {
- uint [] arr = new uint [3];
+ if (arr [2] != 44)
+ return 0;
- arr [0] = 7;
- arr [1] = 9;
- arr [2] = 44;
-
- if (arr [0] != 7)
- return 0;
+ return 1;
+ }
+
+ /// <summary>
+ /// long[][] read/write
+ /// </summary>
+ public static uint CMPLongJaggedArray ()
+ {
+ long [][] arr = new long [3][];
- if (arr [1] != 9)
- return 0;
+ arr [0] = new long [5];
+ arr [1] = new long [3];
+ arr [2] = new long [2];
+
+ arr[0][0] = 39;
+ arr[0][1] = 7;
+ arr[0][2] = 1009;
+ arr[0][3] = -22;
+ arr[0][4] = 1;
+
+ arr[1][0] = 88887;
+ arr[1][1] = -987788;
+ arr[1][2] = 0;
+
+ arr[2][0] = 6;
+ arr[2][1] = arr[0][0]*arr[2][0];
+
+ if (arr[0][0] != 39)
+ return 0;
+
+ if (arr[0][1] != 7)
+ return 0;
+
+ if (arr[0][2] != 1009)
+ return 0;
+
+ if (arr[0][3] != -22)
+ return 0;
+
+ if (arr[0][4] != 1)
+ return 0;
+
+
+
+ if (arr[1][0] != 88887)
+ return 0;
+
+ if (arr[1][1] != -987788)
+ return 0;
+
+ if (arr[1][2] != 0)
+ return 0;
+
+
+ if (arr[2][0] != 6)
+ return 0;
+
+ if (arr[2][1] != 39*6)
+ return 0;
+
+ return 1;
+ }
+
+ /// <summary>
+ /// long[,] read/write
+ /// </summary>
+ public static uint CMPLongMultidimentionalArray ()
+ {
+ long [,] arr = new long [3,2];
+
+ arr[0,0] = 39;
+ arr[0,1] = 7;
+
+ arr[1,0] = 88887;
+ arr[1,1] = -987788;
+
+ arr[2,0] = 6;
+ arr[2,1] = arr[0,0]*arr[2,0];
+
+ if (arr[0,0] != 39)
+ return 0;
+
+ if (arr[0,1] != 7)
+ return 0;
+
+
+
+ if (arr[1,0] != 88887)
+ return 0;
+
+ if (arr[1,1] != -987788)
+ return 0;
+
+
+
+ if (arr[2,0] != 6)
+ return 0;
+
+ if (arr[2,1] != 39*6)
+ return 0;
+
+ return 1;
+ }
+ ///////////////////
- if (arr [2] != 44)
- return 0;
+ /// <summary>
+ /// uint[] read/write
+ /// </summary>
+ public static uint CMPUIntArray ()
+ {
+ uint [] arr = new uint [3];
- return 1;
- }
-
- /// <summary>
- /// ushort[] read/write
- /// </summary>
- public static uint CMPUShortArray ()
- {
- short [] arr = new short [3];
+ arr [0] = 7;
+ arr [1] = 9;
+ arr [2] = 44;
+
+ if (arr [0] != 7)
+ return 0;
- arr [0] = 7;
- arr [1] = 9;
- arr [2] = 44;
-
- if (arr [0] != 7)
- return 0;
+ if (arr [1] != 9)
+ return 0;
- if (arr [1] != 9)
- return 0;
+ if (arr [2] != 44)
+ return 0;
- if (arr [2] != 44)
- return 0;
+ return 1;
+ }
+
+ /// <summary>
+ /// uint[][] read/write
+ /// </summary>
+ public static uint CMPUIntJaggedArray ()
+ {
+ uint [][] arr = new uint [3][];
- return 1;
- }
-
- /// <summary>
- /// sbyte[] read/write
- /// </summary>
- public static uint CMPSByteArray ()
- {
- sbyte [] arr = new sbyte [3];
+ arr [0] = new uint [5];
+ arr [1] = new uint [3];
+ arr [2] = new uint [2];
+
+ arr[0][0] = 39;
+ arr[0][1] = 7;
+ arr[0][2] = 76;
+ arr[0][3] = 22;
+ arr[0][4] = 4294967294;
+
+ arr[1][0] = 99;
+ arr[1][1] = 87;
+ arr[1][2] = 0;
+
+ arr[2][0] = 6;
+ arr[2][1] = arr[0][0]*arr[2][0];
+
+ if (arr[0][0] != 39)
+ return 0;
+
+ if (arr[0][1] != 7)
+ return 0;
+
+ if (arr[0][2] != 76)
+ return 0;
+
+ if (arr[0][3] != 22)
+ return 0;
+
+ if (arr[0][4] != 4294967294)
+ return 0;
+
+
+
+ if (arr[1][0] != 99)
+ return 0;
+
+ if (arr[1][1] != 87)
+ return 0;
+
+ if (arr[1][2] != 0)
+ return 0;
+
+
+ if (arr[2][0] != 6)
+ return 0;
+
+ if (arr[2][1] != 39*6)
+ return 0;
+
+ return 1;
+ }
+
+ /// <summary>
+ /// uint[,] read/write
+ /// </summary>
+ public static uint CMPUIntMultidimentionalArray ()
+ {
+ uint [,] arr = new uint [3,2];
+
+ arr[0,0] = 39;
+ arr[0,1] = 7;
+
+ arr[1,0] = 123;
+ arr[1,1] = 24;
+
+ arr[2,0] = 6;
+ arr[2,1] = arr[0,0]*arr[2,0];
+
+ if (arr[0,0] != 39)
+ return 0;
+
+ if (arr[0,1] != 7)
+ return 0;
+
+
+
+ if (arr[1,0] != 123)
+ return 0;
+
+ if (arr[1,1] != 24)
+ return 0;
+
+
+
+ if (arr[2,0] != 6)
+ return 0;
+
+ if (arr[2,1] != 39*6)
+ return 0;
+
+ return 1;
+ }
+
+ /// <summary>
+ /// ushort[] read/write
+ /// </summary>
+ public static uint CMPUShortArray ()
+ {
+ ushort [] arr = new ushort [3];
- arr [0] = 7;
- arr [1] = 9;
- arr [2] = 44;
-
- if (arr [0] != 7)
- return 0;
+ arr [0] = 7;
+ arr [1] = 9;
+ arr [2] = 44;
+
+ if (arr [0] != 7)
+ return 0;
- if (arr [1] != 9)
- return 0;
+ if (arr [1] != 9)
+ return 0;
- if (arr [2] != 44)
- return 0;
+ if (arr [2] != 44)
+ return 0;
- return 1;
- }
+ return 1;
+ }
+
+ /// <summary>
+ /// ushort[][] read/write
+ /// </summary>
+ public static uint CMPUShortJaggedArray ()
+ {
+ ushort [][] arr = new ushort [3][];
- /// <summary>
- /// ulong[] read/write
- /// </summary>
- public static uint CMPULongArray ()
- {
- ulong [] arr = new ulong [3];
+ arr [0] = new ushort [5];
+ arr [1] = new ushort [3];
+ arr [2] = new ushort [2];
+
+ arr[0][0] = 39;
+ arr[0][1] = 7;
+ arr[0][2] = 76;
+ arr[0][3] = 22;
+ arr[0][4] = 1;
+
+ arr[1][0] = 99;
+ arr[1][1] = 87;
+ arr[1][2] = 0;
+
+ arr[2][0] = 6;
+ arr[2][1] = (ushort)(arr[0][0]*arr[2][0]);
+
+ if (arr[0][0] != 39)
+ return 0;
+
+ if (arr[0][1] != 7)
+ return 0;
+
+ if (arr[0][2] != 76)
+ return 0;
+
+ if (arr[0][3] != 22)
+ return 0;
+
+ if (arr[0][4] != 1)
+ return 0;
+
+
+
+ if (arr[1][0] != 99)
+ return 0;
+
+ if (arr[1][1] != 87)
+ return 0;
+
+ if (arr[1][2] != 0)
+ return 0;
+
+
+ if (arr[2][0] != 6)
+ return 0;
+
+ if (arr[2][1] != 39*6)
+ return 0;
+
+ return 1;
+ }
+ /// <summary>
+ /// ushort[,] read/write
+ /// </summary>
+ public static uint CMPUShortMultidimentionalArray ()
+ {
+ ushort [,] arr = new ushort [3,2];
+
+ arr[0,0] = 39;
+ arr[0,1] = 7;
+
+ arr[1,0] = 123;
+ arr[1,1] = 24;
+
+ arr[2,0] = 6;
+ arr[2,1] = (ushort)(arr[0,0]*arr[2,0]);
+
+ if (arr[0,0] != 39)
+ return 0;
+
+ if (arr[0,1] != 7)
+ return 0;
+
+
+
+ if (arr[1,0] != 123)
+ return 0;
+
+ if (arr[1,1] != 24)
+ return 0;
+
+
+
+ if (arr[2,0] != 6)
+ return 0;
+
+ if (arr[2,1] != 39*6)
+ return 0;
+
+ return 1;
+ }
+
+ /// <summary>
+ /// sbyte[] read/write
+ /// </summary>
+ public static uint CMPSByteArray ()
+ {
+ sbyte [] arr = new sbyte [3];
- arr [0] = 7;
- arr [1] = 9;
- arr [2] = 44;
-
- if (arr [0] != 7)
- return 0;
+ arr [0] = 7;
+ arr [1] = 9;
+ arr [2] = 44;
+
+ if (arr [0] != 7)
+ return 0;
- if (arr [1] != 9)
- return 0;
+ if (arr [1] != 9)
+ return 0;
- if (arr [2] != 44)
- return 0;
+ if (arr [2] != 44)
+ return 0;
- return 1;
- }
-
- /// <summary>
- /// int[].Length
- /// </summary>
- public static uint CMPIntArrayLength ()
- {
- int [] arrA = new int [10];
- int [] arrB = new int [4];
+ return 1;
+ }
+ /// <summary>
+ /// sbyte[][] read/write
+ /// </summary>
+ public static uint CMPSByteJaggedArray ()
+ {
+ sbyte [][] arr = new sbyte [3][];
- if (arrA.Length != 10)
- return 0;
- if (arrB.Length != 4)
- return 0;
+ arr [0] = new sbyte [5];
+ arr [1] = new sbyte [3];
+ arr [2] = new sbyte [2];
+
+ arr[0][0] = 39;
+ arr[0][1] = 7;
+ arr[0][2] = 76;
+ arr[0][3] = 22;
+ arr[0][4] = 1;
+
+ arr[1][0] = 99;
+ arr[1][1] = 87;
+ arr[1][2] = 0;
+
+ arr[2][0] = 2;
+ arr[2][1] = (sbyte)(arr[0][0]*arr[2][0]);
+
+ if (arr[0][0] != 39)
+ return 0;
+
+ if (arr[0][1] != 7)
+ return 0;
+
+ if (arr[0][2] != 76)
+ return 0;
+
+ if (arr[0][3] != 22)
+ return 0;
+
+ if (arr[0][4] != 1)
+ return 0;
+
+
+
+ if (arr[1][0] != 99)
+ return 0;
+
+ if (arr[1][1] != 87)
+ return 0;
+
+ if (arr[1][2] != 0)
+ return 0;
+
+
+ if (arr[2][0] != 2)
+ return 0;
+
+ if (arr[2][1] != 39*2)
+ return 0;
+
+ return 1;
+ }
+
+
+ /// <summary>
+ /// sbyte[,] read/write
+ /// </summary>
+ public static uint CMPSByteMultidimentionalArray ()
+ {
+ sbyte [,] arr = new sbyte [3,2];
+
+ arr[0,0] = 39;
+ arr[0,1] = 7;
+
+ arr[1,0] = 123;
+ arr[1,1] = 24;
+
+ arr[2,0] = 2;
+ arr[2,1] = (sbyte)(arr[0,0]*arr[2,0]);
+
+ if (arr[0,0] != 39)
+ return 0;
+
+ if (arr[0,1] != 7)
+ return 0;
+
+
+
+ if (arr[1,0] != 123)
+ return 0;
+
+ if (arr[1,1] != 24)
+ return 0;
+
+
+
+ if (arr[2,0] != 2)
+ return 0;
+
+ if (arr[2,1] != 39*2)
+ return 0;
+
+ return 1;
+ }
+ /// <summary>
+ /// ulong[] read/write
+ /// </summary>
+ public static uint CMPULongArray ()
+ {
+ ulong [] arr = new ulong [3];
- return 1;
- }
-
- /// <summary>
- /// int[].Length
- /// </summary>
- public static uint CMPIntArrayZeroLength ()
- {
- int [] arr = new int [0];
+ arr [0] = 7;
+ arr [1] = 9;
+ arr [2] = 44;
+
+ if (arr [0] != 7)
+ return 0;
- if (arr.Length != 0)
- return 0;
+ if (arr [1] != 9)
+ return 0;
- return 1;
- }
- }
+ if (arr [2] != 44)
+ return 0;
+
+ return 1;
+ }
+
+ /// <summary>
+ /// ulong[][] read/write
+ /// </summary>
+ public static uint CMPULongJaggedArray ()
+ {
+ ulong [][] arr = new ulong [3][];
+
+ arr [0] = new ulong [5];
+ arr [1] = new ulong [3];
+ arr [2] = new ulong [2];
+
+ arr[0][0] = 39;
+ arr[0][1] = 7;
+ arr[0][2] = 76;
+ arr[0][3] = 22;
+ arr[0][4] = 4294967294;
+
+ arr[1][0] = 99;
+ arr[1][1] = 87;
+ arr[1][2] = 0;
+
+ arr[2][0] = 6;
+ arr[2][1] = arr[0][0]*arr[2][0];
+
+ if (arr[0][0] != 39)
+ return 0;
+
+ if (arr[0][1] != 7)
+ return 0;
+
+ if (arr[0][2] != 76)
+ return 0;
+
+ if (arr[0][3] != 22)
+ return 0;
+
+ if (arr[0][4] != 4294967294)
+ return 0;
+
+
+
+ if (arr[1][0] != 99)
+ return 0;
+
+ if (arr[1][1] != 87)
+ return 0;
+
+ if (arr[1][2] != 0)
+ return 0;
+
+
+ if (arr[2][0] != 6)
+ return 0;
+
+ if (arr[2][1] != 39*6)
+ return 0;
+
+ return 1;
+ }
+
+ /// <summary>
+ /// ulong[,] read/write
+ /// </summary>
+ public static uint CMPULongMultidimentionalArray ()
+ {
+ ulong [,] arr = new ulong [3,2];
+
+ arr[0,0] = 39;
+ arr[0,1] = 7;
+
+ arr[1,0] = 123;
+ arr[1,1] = 24;
+
+ arr[2,0] = 6;
+ arr[2,1] = arr[0,0]*arr[2,0];
+
+ if (arr[0,0] != 39)
+ return 0;
+
+ if (arr[0,1] != 7)
+ return 0;
+
+
+
+ if (arr[1,0] != 123)
+ return 0;
+
+ if (arr[1,1] != 24)
+ return 0;
+
+
+
+ if (arr[2,0] != 6)
+ return 0;
+
+ if (arr[2,1] != 39*6)
+ return 0;
+
+ return 1;
+ }
+
+ /// <summary>
+ /// int[].Length
+ /// </summary>
+ public static uint CMPIntArrayLength ()
+ {
+ int [] arrA = new int [10];
+ int [] arrB = new int [4];
+
+ if (arrA.Length != 10)
+ return 0;
+ if (arrB.Length != 4)
+ return 0;
+
+ return 1;
+ }
+
+ /// <summary>
+ /// int[].Length
+ /// </summary>
+ public static uint CMPIntArrayZeroLength ()
+ {
+ int [] arr = new int [0];
+
+ if (arr.Length != 0)
+ return 0;
+
+ return 1;
+ }
+ }
#endif
}
Index: Kernel/Core/Foundation/Convert.cs
===================================================================
--- Kernel/Core/Foundation/Convert.cs (revision 731)
+++ Kernel/Core/Foundation/Convert.cs (working copy)
@@ -2,8 +2,8 @@
// (C) 2007 The SharpOS Project Team (http://www.sharpos.org)
//
// Authors:
-// William Lahti <[EMAIL PROTECTED]>
-// Bruce Markham <[EMAIL PROTECTED]>
+// William Lahti <[EMAIL PROTECTED]>
+// Bruce Markham <[EMAIL PROTECTED]>
//
// Licensed under the terms of the GNU GPL v3,
// with Classpath Linking Exception for Libraries
@@ -11,77 +11,223 @@
using System;
using SharpOS.Kernel.Foundation;
+using SharpOS.Kernel.ADC;
namespace SharpOS.Kernel.Foundation {
- public unsafe class Convert {
- public unsafe static int ToByteString (string str, byte* buffer, int bufferLen, int offset)
- {
- if (offset + str.Length + 1 > bufferLen)
- return -1;
+ public unsafe class Convert {
- for (int x = 0; x < str.Length; ++x)
- buffer [offset + x] = (byte) str [x];
+
+ public unsafe static int ToByteString (string str, byte* buffer, int bufferLen, int offset)
+ {
+ if (offset + str.Length + 1 > bufferLen)
+ return -1;
- return 0;
- }
+ for (int x = 0; x < str.Length; ++x)
+ buffer [offset + x] = (byte) str [x];
- public unsafe static CString8* ToString (int value, bool hex)
- {
- byte* buffer = (byte*) ADC.MemoryManager.Allocate (64);
+ return 0;
+ }
- int l = ToString (value, hex, buffer, 64, 0);
- CString8* result = ((CString8*)buffer)->Substring (0, l);
+ public unsafe static CString8* ToString (int value, bool hex)
+ {
+ byte* buffer = (byte*) ADC.MemoryManager.Allocate (64);
- ADC.MemoryManager.Free ((void*) buffer);
- return result;
- }
+ int l = ToString (value, hex, buffer, 64, 0);
+ CString8* result = ((CString8*)buffer)->Substring (0, l);
- public unsafe static int ToString (int value, bool hex, byte* buffer,
- int bufferLen, int offset)
- {
- uint uvalue = (uint) value;
- ushort divisor = hex ? (ushort) 16 : (ushort) 10;
- int length = 0;
- int count = 0;
- uint temp;
- bool negative = false;
+ ADC.MemoryManager.Free ((void*) buffer);
+ return result;
+ }
- if (!hex && value < 0) {
- count++;
+ public unsafe static int ToString (int value, bool hex, byte* buffer,
+ int bufferLen, int offset)
+ {
+ uint uvalue = (uint) value;
+ ushort divisor = hex ? (ushort) 16 : (ushort) 10;
+ int length = 0;
+ int count = 0;
+ uint temp;
+ bool negative = false;
- uvalue = (uint) -value;
- }
+ if (value < 0) {
+ count++;
+ uvalue = (uint) -value;
+ negative = true;
+ }
- temp = uvalue;
+ temp = uvalue;
- do {
- temp /= divisor;
- count++;
- }
- while (temp != 0);
+ do {
+ temp /= divisor;
+ count++;
+ }
+ while (temp != 0);
- Diagnostics.Assert (offset + count < bufferLen, "Convert.ToString: buffer too small.");
+ Diagnostics.Assert (offset + count < bufferLen, "Convert.ToString: buffer too small.");
- length = count;
+ length = count;
- if (negative) {
- buffer [offset++] = (byte) '-';
- count--;
- }
+ if (negative) {
+ buffer [offset++] = (byte) '-';
+ count--;
+ }
- for (int i = 0; i < count; i++) {
- uint remainder = uvalue % divisor;
+ for (int i = 0; i < count; i++) {
+ uint remainder = uvalue % divisor;
- if (remainder < 10)
- buffer [offset + count - 1 - i] = (byte) ('0' + remainder);
+ if (remainder < 10)
+ buffer [offset + count - 1 - i] = (byte) ('0' + remainder);
- else
- buffer [offset + count - 1 - i] = (byte) ('A' + remainder - 10);
+ else
+ buffer [offset + count - 1 - i] = (byte) ('A' + remainder - 10);
- uvalue /= divisor;
- }
+ uvalue /= divisor;
+ }
- return length;
- }
- }
+ return length;
+ }
+
+#if LONG_ENABLED
+ public unsafe static int ToString (long value, bool hex, byte* buffer,
+ int bufferLen, int offset)
+ {
+ ulong uvalue = (ulong) value;
+ ushort divisor = hex ? (ushort) 16 : (ushort) 10;
+ int length = 0;
+ int count = 0;
+ ulong temp;
+ bool negative = false;
+
+ if (value < 0) {
+ count++;
+ uvalue = (ulong) -value;
+ negative = true;
+ }
+
+ temp = uvalue;
+
+ do {
+ temp /= divisor;
+ count++;
+ }
+ while (temp != 0);
+
+ Diagnostics.Assert (offset + count < bufferLen, "Convert.ToString: buffer too small.");
+
+ length = count;
+
+ if (negative) {
+ buffer [offset++] = (byte) '-';
+ count--;
+ }
+
+ for (int i = 0; i < count; i++) {
+ ulong remainder = uvalue % divisor;
+
+ if (remainder < 10)
+ buffer [offset + count - 1 - i] = (byte) ('0' + remainder);
+
+ else
+ buffer [offset + count - 1 - i] = (byte) ('A' + remainder - 10);
+
+ uvalue /= divisor;
+ }
+
+ return length;
+ }
+
+ /// <summary>
+ /// Runs tests on the long to string conversions.
+ /// </summary>
+ public unsafe static void __Test2 ()
+ {
+ long t1 = 105L;
+ long t2 = -1805L;
+ long t3 = 0x6FL;
+ long t4 = -0x96AL;
+ CString8* p1 = (CString8*)Stubs.CString("105"), p2 = (CString8*)Stubs.CString("-1805");
+ CString8* p3 = (CString8*)Stubs.CString("6F"), p4 = (CString8*)Stubs.CString("-96A");
+
+
+ if (!__StringComp(Convert.ToString(t1, false), p1))
+ TextMode.WriteLine("Convert.ToString(long, bool) Failed Test: 105");
+
+ if (!__StringComp(Convert.ToString(t2, false), p2))
+ TextMode.WriteLine("Convert.ToString(long, bool) Failed Test: -1805");
+
+ if (!__StringComp(Convert.ToString(t3, true), p3))
+ TextMode.WriteLine("Convert.ToString(long, bool) Failed Test: 0x6F");
+
+ if (!__StringComp(Convert.ToString(t4, true), p4))
+ TextMode.WriteLine("Convert.ToString(long, bool) Failed Test: -0x96A");
+
+ }
+
+ public unsafe static CString8* ToString (long value, bool hex)
+ {
+ byte* buffer = (byte*) ADC.MemoryManager.Allocate (128);
+
+ int l = ToString (value, hex, buffer, 128, 0);
+ CString8* result = ((CString8*)buffer)->Substring (0, l);
+
+ ADC.MemoryManager.Free ((void*) buffer);
+ return result;
+ }
+#else
+ public unsafe static void __Test2 ()
+ {
+ TextMode.WriteLine("Convert.ToString(long, bool) Warning: Long Is Not Enabled");
+ }
+#endif
+
+ internal unsafe static void __RunTests ()
+ {
+ __Test1 ();
+ __Test2 ();
+
+ }
+
+ /// <summary>
+ /// Runs tests on the int to string conversions.
+ /// </summary>
+ public unsafe static void __Test1 ()
+ {
+ int t1 = 105;
+ int t2 = -1805;
+ int t3 = 0x6F;
+ int t4 = -0x96A;
+ CString8* p1 = (CString8*)Stubs.CString("105");
+ CString8* p2 = (CString8*)Stubs.CString("-1805");
+ CString8* p3 = (CString8*)Stubs.CString("6F")
+ CString8* p4 = (CString8*)Stubs.CString("-96A");
+
+
+ if (!__StringComp(Convert.ToString(t1, false), p1))
+ TextMode.WriteLine("Convert.ToString(int, bool) Failed Test: 105");
+
+ if (!__StringComp(Convert.ToString(t2, false), p2))
+ TextMode.WriteLine("Convert.ToString(int, bool) Failed Test: -1805");
+
+ if (!__StringComp(Convert.ToString(t3, true), p3))
+ TextMode.WriteLine("Convert.ToString(int, bool) Failed Test: 0x6F");
+
+ if (!__StringComp(Convert.ToString(t4, true), p4))
+ TextMode.WriteLine("Convert.ToString(int, bool) Failed Test: -0x96A");
+
+ }
+
+
+ private unsafe static bool __StringComp(CString8* str1, CString8* str2)
+ {
+ byte* s1 = (byte*)str1;
+ byte* s2 = (byte*)str2;
+ while (*s1 == *s2 && *s1 != 0 && *s2 != 0)
+ {
+ ++s1;
+ ++s2;
+ }
+
+ return (*s1 == 0 & *s2 == 0);
+ }
+ }
}
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
SharpOS-Developers mailing list
SharpOS-Developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sharpos-developers