Ejemplo n.º 1
0
        public void WordPatternTest(string pattern, string s, bool expected)
        {
            // arrange

            // actual
            var actual = StringTest.WordPattern(pattern, s);

            // assert
            Assert.AreEqual(actual, expected);
        }
Ejemplo n.º 2
0
        //[TestCase ("abab", true)]
        //[TestCase ("aba", false)]
        //[TestCase ("abcabcabc", true)]
        //[TestCase ("ababba", false)]
        public void RepeatedSubstringPatternTest(string s, bool expected)
        {
            // arrange

            // actual
            var actual = StringTest.RepeatedSubstringPattern(s);

            // assert
            Assert.AreEqual(actual, expected);
        }
Ejemplo n.º 3
0
        public void IsIsomorphicTest(string s, string t, bool expected)
        {
            // arrange

            // actual
            var actual = StringTest.IsIsomorphic(s, t);

            // assert
            Assert.AreEqual(actual, expected);
        }
Ejemplo n.º 4
0
        public void ValidParenthesesTest()
        {
            // arrange
            var s        = "{]}";
            var expected = false;
            // actual
            var actual = StringTest.IsValid(s);

            // assert
            Assert.AreEqual(actual, expected);
        }
Ejemplo n.º 5
0
        public void LengthOfLastWordTest()
        {
            // arrange
            var s        = "Hello World";
            var expected = 0;
            // actual
            var actual = StringTest.LengthOfLastWord(s);

            // assert
            Assert.AreEqual(actual, expected);
        }
Ejemplo n.º 6
0
        public void TitleToNumberTest()
        {
            // arrange
            var columnTitle = "AB"; // 26^1 + 1*26^0
            //"ABC" // 26^2 + 2*26^1 + 3*26^2
            var expected = 27;
            // actual
            var actual = StringTest.TitleToNumber(columnTitle);

            // assert
            Assert.AreEqual(actual, expected);
        }
Ejemplo n.º 7
0
        public void IsSubsequenceTest()
        {
            // arrange
            var s        = "abc";
            var t        = "ahbgdc";
            var expected = true;
            // actual
            var actual = StringTest.IsSubsequence(s, t);

            // assert
            Assert.AreEqual(actual, expected);
        }
Ejemplo n.º 8
0
        public void MultiplyTest()
        {
            // arrange
            var num1     = "123";
            var num2     = "456";
            var expected = "56088";
            // actual
            string actual = StringTest.Multiply(num1, num2);

            // assert
            Assert.AreEqual(actual, expected);
        }
Ejemplo n.º 9
0
        public void DiStringMatchTest()
        {
            // arrange
            var s        = "IDID";
            var expected = new int[] { 0, 4, 1, 3, 2 };

            // actual
            var actual = StringTest.DiStringMatch(s);

            // assert
            Assert.AreEqual(actual, expected);
        }
Ejemplo n.º 10
0
            public void Should_Not_Populate_When_Max_Depth_Exceeded()
            {
                // Arrange
                autoBuilderConfiguration.MaxDepth = -1;

                // Act
                var objectToPopulate = new StringTest();

                propertyPopulationService.PopulateProperties(objectToPopulate, 0);

                // Assert
                objectToPopulate.Test.ShouldBeNull();
            }
Ejemplo n.º 11
0
        public void UncommonFromSentencesTest()
        {
            // arrange
            // var s1 = "this apple is sweet";
            // var s2 = "this apple is sour";
            // var expected = new string[] { "sweet","sour" };
            var s1       = "apple apple";
            var s2       = "banana";
            var expected = new string[] { "banana" };
            // actual
            var actual = StringTest.UncommonFromSentences(s1, s2);

            // assert
            Assert.AreEqual(actual, expected);
        }
Ejemplo n.º 12
0
    public void OnSaveMapClick()
    {
        if (!LibPlacenote.Instance.Initialized())
        {
            Debug.Log("SDK not yet initialized");
            ToastManager.ShowToast("SDK not yet initialized", 2f);
            return;
        }

        bool         useLocation  = Input.location.status == LocationServiceStatus.Running;
        LocationInfo locationInfo = Input.location.lastData;

        mLabelText.text = "Saving...";
        LibPlacenote.Instance.SaveMap(
            (mapId) => {
            LibPlacenote.Instance.StopSession();
            mLabelText.text = "Saved Map ID: " + mapId;
            mInitButtonPanel.SetActive(true);
            mMappingButtonPanel.SetActive(false);


            JObject metadata = new JObject();

            JObject shapeList     = Shapes2JSON();
            metadata["shapeList"] = shapeList;

            StringTest testData     = new StringTest();
            testData.stringtests    = new string[2];
            testData.stringtests[0] = "test1";
            testData.stringtests[1] = "test2";
            metadata["test"]        = JObject.FromObject(testData);


            JObject onionList     = Onions2JSON();
            metadata["onionList"] = onionList;

            if (useLocation)
            {
                metadata["location"]              = new JObject();
                metadata["location"]["latitude"]  = locationInfo.latitude;
                metadata["location"]["longitude"] = locationInfo.longitude;
                metadata["location"]["altitude"]  = locationInfo.altitude;
            }
            LibPlacenote.Instance.SetMetadata(mapId, metadata);
        },
            (completed, faulted, percentage) => {}
            );
    }
Ejemplo n.º 13
0
            public void Should_Call_Correct_Populate_Service_When_Passed_A_String()
            {
                // Arrange
                const string resultString = "TestReturn";

                populateStringService.Setup(x => x.Populate(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <PropertyInfo>())).Returns(resultString);

                // Act
                var objectToPopulate = new StringTest();

                propertyPopulationService.PopulateProperties(objectToPopulate, 0);

                // Assert
                populateStringService.VerifyAll();
                objectToPopulate.Test.ShouldEqual(resultString);
            }
Ejemplo n.º 14
0
        public void ConvertToTitleTest()
        {
            // arrange
            // var n = 1;
            // var expected = "A";
            var n        = 27;
            var expected = "AA";
            // var n = 701;
            // var expected = "AAA";

            // actual
            string actual = StringTest.ConvertToTitle(n);

            // assert
            Assert.AreEqual(actual, expected);
        }
Ejemplo n.º 15
0
        protected override void Run()
        {
            try
            {
                mDebugger.Send("Run");

                CSharp.WhileLoopTests.Execute();
                ObjectTests.Execute();
                StringTest.Execute();
                ByteTest.Execute();
                SByteTest.Execute();
                Int16Test.Execute();
                UInt16Test.Execute();
                Int32Test.Execute();
                UInt32Test.Execute();
                Int64Test.Execute();
                UInt64Test.Execute();
                CharTest.Execute();
                BooleanTest.Execute();
                SingleTest.Execute();
                DoubleTest.Execute();
                BitConverterTest.Execute();
                UnsafeCodeTest.Execute();

#if false
                DecimalTest.Execute();
                System.Collections.Generic.ListTest.Execute();
                System.Collections.Generic.QueueTest.Execute();
                System.DelegatesTest.Execute();
                System.UInt64Test.Execute();
#endif
                TestController.Completed();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception occurred");
                Console.WriteLine(e.Message);
                mDebugger.Send("Exception occurred: " + e.Message);
                TestController.Failed();
            }
        }
Ejemplo n.º 16
0
        public void TestSplitContent(StringTest test)
        {
            Func<string[], FSStringList> of_array = (array) => ListModule.of_array<string>(array);

            Func<FSStringList, string[]> to_string_array = (string_list) =>
            {
                var tl = string_list;
                var res = new StringList();
                while (ListModule.length<string>(tl) > 0)
                {
                    res.Add(ListModule.hd<string>(tl));
                    tl = ListModule.tl<string>(tl);
                }

                return res.ToArray();
            };

            Assert.AreEqual(to_string_array(of_array(test.expected)), to_string_array(OutputHandling.split_token_contents(test.provided)));
        }
Ejemplo n.º 17
0
        public void TestSmartSplit(StringTest test)
        {
            Regex r = new Regex(@"(""(?:[^""\\]*(?:\\.[^""\\]*)*)""|'(?:[^'\\]*(?:\\.[^'\\]*)*)'|[^\s]+)", RegexOptions.Compiled);
            MatchCollection m = r.Matches(@"'\'funky\' style'");

            Func<string[], FSStringList> of_array = (array) => ListModule.of_array<string>(array);

            Func<FSStringList, string[]> to_string_array = (string_list) =>
            {
                var tl = string_list;
                var res = new StringList();
                while (ListModule.length<string>(tl) > 0)
                {
                    res.Add(ListModule.hd<string>(tl));
                    tl = ListModule.tl<string>(tl);
                }

                return res.ToArray();
            };

            Assert.AreEqual(to_string_array(of_array(test.expected)), to_string_array(OutputHandling.smart_split(test.provided)));
        }
            public void Should_Not_Populate_When_Max_Depth_Exceeded()
            {
                // Arrange
                autoBuilderConfiguration.MaxDepth = -1;

                // Act
                var objectToPopulate = new StringTest();
                propertyPopulationService.PopulateProperties(objectToPopulate, 0);

                // Assert
                objectToPopulate.Test.ShouldBeNull();
            }
            public void Should_Call_Correct_Populate_Service_When_Passed_A_String()
            {
                // Arrange
                const string resultString = "TestReturn";
                populateStringService.Setup(x => x.Populate(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<PropertyInfo>())).Returns(resultString);

                // Act
                var objectToPopulate = new StringTest();
                propertyPopulationService.PopulateProperties(objectToPopulate, 0);

                // Assert
                populateStringService.VerifyAll();
                objectToPopulate.Test.ShouldEqual(resultString);
            }