[TestMethod] public void StartsWithLetterTest() { Assert.IsTrue(SystemString.StartsWithLetter("abc")); Assert.IsFalse(SystemString.StartsWithLetter("1abc")); Assert.IsFalse(SystemString.StartsWithLetter("")); Assert.IsFalse(SystemString.StartsWithLetter(null)); }
[TestMethod] public void ToBackwardsTest() { Assert.AreEqual("cba", SystemString.ToBackwards("abc")); Assert.AreEqual(" ", SystemString.ToBackwards(" ")); Assert.AreEqual("", SystemString.ToBackwards("")); Assert.AreEqual("", SystemString.ToBackwards(null)); }
public static int Execute(tCLIFile *pThis, int argc, /*char**/ byte **argp) { throw new System.NotImplementedException(); #if NO tThread * pThread; /*HEAP_PTR*/ byte *args; int i; // Create a string array for the program arguments // Don't include the argument that is the program name. argc--; argp++; args = new string[argc]; Heap.MakeUndeletable(args); for (i = 0; i < argc; i++) { /*HEAP_PTR*/ byte *arg = SystemString.FromCharPtrASCII(argp[i]); SystemArray.StoreElement(args, i, (byte *)&arg); } // Create the main application thread pThread = Thread(); Thread.SetEntryPoint(pThread, pThis->pMetaData, pThis->entryPoint, (byte *)&args, sizeof(void *)); return(Thread.Execute()); #endif }
public void RecursionIsSlowTest() { var d1 = DateTime.Now.Ticks; for (var i = 0; i < 1000000; i++) { SystemString.ToBackwards("abc"); } var d2 = DateTime.Now.Ticks; for (var i = 0; i < 1000000; i++) { ToBackwardsUsingRecursion("abc"); } var d3 = DateTime.Now.Ticks; var r1 = d2 - d1; var r2 = d3 - d2; Assert.IsTrue(r1 < r2); }
[TestMethod] public void FasterToBackwardsAlgorithmTest() { var d1 = DateTime.Now.Ticks; for (var i = 0; i < 1000000; i++) { SystemString.ToBackwards("abc"); } var d2 = DateTime.Now.Ticks; for (var i = 0; i < 1000000; i++) { toBackwardsUsingRecursion("abc"); } var d3 = DateTime.Now.Ticks; var r1 = d2 - d1; var r2 = d3 - d2; Assert.IsTrue(r1 < r2); }
/// <summary> /// Get a system string that is localized to the user's currently-set Windows language. /// </summary> /// <param name="eSystemStringId">Id of the system string to use.</param> internal static string GetSystemString(SystemString eSystemStringId) { return(Marshal.PtrToStringAuto(MB_GetString((int)eSystemStringId))); }
static void Main(string[] args) { ///////////////////////////////////////////////////////////////////////// ////////////////// TEST THE sYSTEM "string" CLASS////////// //////////////////////////////////////////////////////////// SystemString myString = new SystemString("This is the SYSTEM \"string\"."); Console.WriteLine(myString); Console.ReadLine(); myString.Insert("Add More to this is it"); Console.WriteLine(myString); Console.ReadLine(); myString.Remove(39, 8); //AT POSITION 39 REMOVE 4 CHARATERS Console.WriteLine(myString); Console.ReadLine(); //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /////////////////// TEST THE CUSTOM LINKEDLISTSTRING /////// //////////////////////////////////////////////////////////// CustomLinkedListString myLinkedString = new CustomLinkedListString("This is char Custom string linked listed."); Console.WriteLine(myLinkedString.ToString()); //////// TEST THE "INSERT" METHOD /////////////// myLinkedString.Insert(" Just added some more."); Console.WriteLine(myLinkedString.ToString()); Console.ReadLine(); myLinkedString.Remove(39, 8); //AT POSITION 39 REMOVE 4 CHARATERS Console.WriteLine(myLinkedString); Console.ReadLine(); //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////// TEST THE SYSTEM "LinkedList" /////////// //////////////////////////////////////////////////////////// SystemLinkedListString MySysLinkedLIst = new SystemLinkedListString(" This is a char System \"LinkedList\"."); Console.WriteLine(MySysLinkedLIst.ToString()); MySysLinkedLIst.Insert(" Adding to the linked list"); Console.WriteLine(MySysLinkedLIst.ToString()); MySysLinkedLIst.Remove(4, 3); Console.WriteLine(MySysLinkedLIst.ToString()); Console.ReadLine(); //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////// TEST THE SYSTEM "ARRAY List" /////////// //////////////////////////////////////////////////////////// SystemArrayString MySysArrayList = new SystemArrayString("This is an array list."); Console.WriteLine(MySysArrayList.ToString()); MySysArrayList.Insert(" Adding to the Array"); Console.WriteLine(MySysArrayList.ToString()); MySysArrayList.Remove(12, 3); Console.WriteLine(MySysArrayList.ToString()); Console.ReadLine(); //////////////////////////////////////////////////////////////////////// //System.Collections.SortedList SysColSL = new System.Collections.SortedList(); //System.Collections.SortedList<ICustomString> SysSLICustomS = new System.Collections.SortedList<ICustomString>(); }