コード例 #1
0
        public virtual void testSScanfDouble()
        {
            ArrayList o  = SScanf.sscanf("4", "%f");
            double    d2 = (double)o[0];

            Assert.AreEqual(4, (int)d2);
        }
コード例 #2
0
        public virtual void testSScanfMulti()
        {
            ArrayList o  = SScanf.sscanf("abc 4", "%s %i");
            string    s2 = (string)o[0];
            int       i2 = (int)o[1];

            Assert.AreEqual("abc", s2);
            Assert.AreEqual(4, i2);
            o  = SScanf.sscanf("abc 4", "a%s %i");
            s2 = (string)o[0];
            i2 = (int)o[1];
            Assert.AreEqual("bc", s2);
            Assert.AreEqual(4, i2);
        }
コード例 #3
0
        public virtual void testSScanfInt()
        {
            ArrayList o  = SScanf.sscanf("4", "%i");
            int       i2 = (int)o[0];

            Assert.AreEqual(4, i2);
            o  = SScanf.sscanf("abc4", "abc%i");
            i2 = (int)o[0];
            Assert.AreEqual(4, i2);
            o  = SScanf.sscanf("abc6%", "abc%i%%");
            i2 = (int)o[0];
            Assert.AreEqual(6, i2);
            o  = SScanf.sscanf("abccv", "abc%xv");
            i2 = (int)o[0];
            Assert.AreEqual(12, i2);
            o  = SScanf.sscanf("abc55", "abc%o");
            i2 = (int)o[0];
            Assert.AreEqual(45, i2); //055 = 45d. No octal in c#.
        }
コード例 #4
0
        public virtual void testSScanfString()
        {
            ArrayList o  = SScanf.sscanf("4", "%s");
            string    s2 = (string)o[0];

            Assert.AreEqual("4", s2);
            o  = SScanf.sscanf("abc4", "abc%s");
            s2 = (string)o[0];
            Assert.AreEqual("4", s2);
            o  = SScanf.sscanf("abc4", "abc%s");
            s2 = (string)o[0];
            Assert.AreEqual("4", s2);
            o  = SScanf.sscanf("abc6%", "abc%1s%%");
            s2 = (string)o[0];
            Assert.AreEqual("6", s2);
            o  = SScanf.sscanf("abc7%", "abc%2c");
            s2 = (string)o[0];
            Assert.AreEqual("7%", s2);
        }