コード例 #1
0
        public static SuffixArray Create <T>(T[] str)
        {
            var sa  = StringLib.SuffixArray(str);
            var lcp = StringLib.LCPArray(str, sa);

            return(new SuffixArray(sa, lcp));
        }
コード例 #2
0
        public void T04_ExpandTo_NegativeTargetLength_ThrowsException()
        {
            string inputText    = "Anyway";
            int    targetLength = -1;

            Assert.Throws <ArgumentOutOfRangeException>(() => StringLib.ExpandTo(inputText, targetLength));
        }
コード例 #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button   button         = FindViewById <Button>(Resource.Id.myButton);
            EditText amountEditText = FindViewById <EditText>(Resource.Id.editTextAmount);
            TextView resultTextView = FindViewById <TextView>(Resource.Id.textViewResult);

            button.Click += delegate {
                var input = amountEditText.Text;
                try {
                    var conversion = CurrencyConverter.ConvertDollarsToPunds(input);
                    resultTextView.Text = StringLib.DollarToPunds(input, conversion);
                } catch (FormatException fe) {
                    // Show error message
                    Toast.MakeText(this, StringLib.CONVERSION_ERROR_MESSAGE, ToastLength.Short).Show();
                    Console.WriteLine(fe);
                }
            };
        }
コード例 #4
0
        public void Titlecase12_DigitsEmbeddedUcLetter_CorrectOutput()
        {
            string inputText    = "6X7";
            string actualOutput = StringLib.Titlecase(inputText);

            Assert.AreEqual("6x7", actualOutput);
        }
        public void NumberOf_NullSource_ThrowsException()
        {
            string sSource            = null;
            char   characterToTestFor = 'X';

            Assert.Throws(typeof(ArgumentNullException), () => StringLib.NumberOf(sSource, characterToTestFor));
        }
コード例 #6
0
        public void IsTheSameFilesystemPath_NullPathRef_Exception()
        {
            string pathReference = null;
            string pathToTest    = "Path";

            Assert.Throws(typeof(ArgumentNullException), () => StringLib.IsTheSameFilesystemPath(pathReference, pathToTest, false));
        }
コード例 #7
0
        public void ContainsDigits_NullArg_ThrowsException()
        {
            string digitFound;
            int    indexOfDigit;

            Assert.Throws(typeof(ArgumentNullException), () => StringLib.ContainsDigit(null, out digitFound, out indexOfDigit));
        }
コード例 #8
0
        public void Titlecase10_2Digits_SameOutput()
        {
            string inputText    = "23";
            string actualOutput = StringLib.Titlecase(inputText);

            Assert.AreEqual("23", actualOutput);
        }
コード例 #9
0
        public void Titlecase08_LcLetterUcLetter_CorrectOutput()
        {
            string inputText    = "eF";
            string actualOutput = StringLib.Titlecase(inputText);

            Assert.AreEqual("Ef", actualOutput);
        }
コード例 #10
0
        public void WithoutAtStart_NullThisArg()
        {
            string s = null;
            string textToRemoveAtStart = "something to remove";

            Assert.Throws(typeof(ArgumentNullException), () => StringLib.WithoutAtStart(s, textToRemoveAtStart));
        }
コード例 #11
0
        public void Titlecase06_TwoUppercaseLetters_CorrectOutput()
        {
            string inputText    = "BC";
            string actualOutput = StringLib.Titlecase(inputText);

            Assert.AreEqual("Bc", actualOutput);
        }
コード例 #12
0
        public void Titlecase07_UcLcLettersInput_CorrectOutput()
        {
            string inputText    = "Cd";
            string actualOutput = StringLib.Titlecase(inputText);

            Assert.AreEqual("Cd", actualOutput);
        }
コード例 #13
0
        public void Titlecase04_OneLowercaseLetterInput_YieldsUppercaseLetterOutput()
        {
            string inputText    = "b";
            string actualOutput = StringLib.Titlecase(inputText);

            Assert.AreEqual("B", actualOutput);
        }
コード例 #14
0
        public void Titlecase05_TwoLowercaseLetters_CorrectOutput()
        {
            string inputText    = "xy";
            string actualOutput = StringLib.Titlecase(inputText);

            Assert.AreEqual("Xy", actualOutput);
        }
コード例 #15
0
        public void Titlecase02_NullInput_YieldsEmptyOutput()
        {
            string inputText    = null;
            string actualOutput = StringLib.Titlecase(inputText);

            Assert.AreEqual("", actualOutput);
        }
コード例 #16
0
        public void Titlecase03_OneUppercaseLetterInput_YieldsSameAsOutput()
        {
            string inputText    = "A";
            string actualOutput = StringLib.Titlecase(inputText);

            Assert.AreEqual("A", actualOutput);
        }
コード例 #17
0
        public void Titlecase09_1Digit_SameOutput()
        {
            string inputText    = "1";
            string actualOutput = StringLib.Titlecase(inputText);

            Assert.AreEqual("1", actualOutput);
        }
コード例 #18
0
        public void Titlecase11_LcLetter2Digits_CorrectOutput()
        {
            string inputText    = "a45";
            string actualOutput = StringLib.Titlecase(inputText);

            Assert.AreEqual("A45", actualOutput);
        }
コード例 #19
0
        public void IsTheSameFilesystemPath_2LevelsNoDr_Path2_CorrrectResult()
        {
            string pathReference = @"Path1\Path2";
            string pathToTest    = @"Path2";
            bool   result        = StringLib.IsTheSameFilesystemPath(pathReference, pathToTest, false);

            Assert.IsFalse(result);
        }
コード例 #20
0
        public void IsTheSameFilesystemPath_Path1Slash_Path1_CorrrectResult()
        {
            string pathReference = @"C:\Path1\";
            string pathToTest    = @"Path1";
            bool   result        = StringLib.IsTheSameFilesystemPath(pathReference, pathToTest, false);

            Assert.IsTrue(result);
        }
        public void NumberOf_XCommaY_Comma_Return1()
        {
            string sSource            = "X, Y";
            char   characterToTestFor = ',';
            int    n = StringLib.NumberOf(sSource, characterToTestFor);

            Assert.AreEqual(1, n);
        }
        public void TopOfFilesystemPath_DriveAndSlash_CorrectResult()
        {
            string remainder;
            string result = StringLib.TopOfFilesystemPath(@"C:\", out remainder);

            Assert.AreEqual(@"C:\", result);
            Assert.IsNull(remainder);
        }
        public void TopOfFilesystemPath_SingleSpace_CorrectResult()
        {
            string remainder;
            string result = StringLib.TopOfFilesystemPath(" ", out remainder);

            Assert.IsNull(result);
            Assert.IsNull(remainder);
        }
        public void TopOfFilesystemPath_EmptyString_CorrectResult()
        {
            string remainder;
            string result = StringLib.TopOfFilesystemPath(String.Empty, out remainder);

            Assert.IsNull(result);
            Assert.IsNull(remainder);
        }
        public void TopOfFilesystemPath_SlashFolder_CorrectResult()
        {
            string remainder;
            string result = StringLib.TopOfFilesystemPath(@"\Folder1", out remainder);

            Assert.AreEqual(@"Folder1", result);
            Assert.IsNull(remainder);
        }
        public void TopOfFilesystemPath_Null_CorrectResult()
        {
            string remainder;
            string result = StringLib.TopOfFilesystemPath(null, out remainder);

            Assert.IsNull(result);
            Assert.IsNull(remainder);
        }
コード例 #27
0
        public void Matches_TwoNullArguments()
        {
            string source       = null;
            string pattern      = null;
            bool   actualOutput = StringLib.Matches(source, pattern);

            Assert.AreEqual(true, actualOutput);
        }
コード例 #28
0
        public void IsTheSameFilesystemPath_BothEqual_CorrrectResult()
        {
            string pathReference = @"C:\Path1";
            string pathToTest    = @"C:\Path1";
            bool   result        = StringLib.IsTheSameFilesystemPath(pathReference, pathToTest, true);

            Assert.IsTrue(result);
        }
        public void TopOfFilesystemPath_2Folders_CorrectResult()
        {
            string remainder;
            string result = StringLib.TopOfFilesystemPath(@"Folder1\Folder2", out remainder);

            Assert.AreEqual("Folder1", result);
            Assert.AreEqual("Folder2", remainder);
        }
コード例 #30
0
        public void IsTheSameFilesystemPath_Capitalized_Uppercase_CorrrectResult()
        {
            string pathReference = @"OnePath";
            string pathToTest    = "ONEPATH";
            bool   result        = StringLib.IsTheSameFilesystemPath(pathReference, pathToTest, false);

            Assert.IsTrue(result);
        }