Esempio n. 1
0
        public void TestStaticOrs()
        {
            Assert.Throws <ArgumentNullException>(() => { Generex.Ors((Generex <int>)null); });
            Assert.Throws <ArgumentNullException>(() => { Generex.Ors((Generex <int>[])null); });
            Assert.Throws <ArgumentNullException>(() => { Generex.Ors((IEnumerable <Generex <int> >)null); });
            Assert.Throws <ArgumentNullException>(() => { Generex.Ors((Generex <int, int>)null); });
            Assert.Throws <ArgumentNullException>(() => { Generex.Ors((Generex <int, int>[])null); });
            Assert.Throws <ArgumentNullException>(() => { Generex.Ors((IEnumerable <Generex <int, int> >)null); });
            AssertMatches(Generex.Ors(_g, _gn), _input, True, False, False, False, True, new object[] { 0, 1 }, null, new object[] { 0, 1 }, 1, 1);
            AssertMatches(Generex.Ors((IEnumerable <Generex <int> >) new[] { _g, _gn }), _input, True, False, False, False, True, new object[] { 0, 1 }, null, new object[] { 0, 1 }, 1, 1);
            AssertMatches(Generex.Ors(_gr, _gnr), _input, True, False, False, False, True, new object[] { 0, 1, 1 }, null, new object[] { 0, 1, 1 }, 1, 1);
            AssertMatches(Generex.Ors((IEnumerable <Generex <int, int> >) new[] { _gr, _gnr }), _input, True, False, False, False, True, new object[] { 0, 1, 1 }, null, new object[] { 0, 1, 1 }, 1, 1);

            Assert.Throws <ArgumentNullException>(() => { Generex.Ors((Stringerex)null); });
            Assert.Throws <ArgumentNullException>(() => { Generex.Ors((Stringerex[])null); });
            Assert.Throws <ArgumentNullException>(() => { Generex.Ors((IEnumerable <Stringerex>)null); });
            Assert.Throws <ArgumentNullException>(() => { Generex.Ors((Stringerex <int>)null); });
            Assert.Throws <ArgumentNullException>(() => { Generex.Ors((Stringerex <int>[])null); });
            Assert.Throws <ArgumentNullException>(() => { Generex.Ors((IEnumerable <Stringerex <int> >)null); });
            AssertMatches(Generex.Ors(_s, _sn), "MLP", True, False, False, False, True, new object[] { 0, 1 }, null, new object[] { 0, 1 }, 1, 1);
            AssertMatches(Generex.Ors((IEnumerable <Stringerex>) new[] { _s, _sn }), "MLP", True, False, False, False, True, new object[] { 0, 1 }, null, new object[] { 0, 1 }, 1, 1);
            AssertMatches(Generex.Ors(_sr, _snr), "MLP", True, False, False, False, True, new object[] { 0, 1, 1 }, null, new object[] { 0, 1, 1 }, 1, 1);
            AssertMatches(Generex.Ors((IEnumerable <Stringerex <int> >) new[] { _sr, _snr }), "MLP", True, False, False, False, True, new object[] { 0, 1, 1 }, null, new object[] { 0, 1, 1 }, 1, 1);

            Assert.Throws <ArgumentNullException>(() => { Stringerex.Ors((Stringerex)null); });
            Assert.Throws <ArgumentNullException>(() => { Stringerex.Ors((Stringerex[])null); });
            Assert.Throws <ArgumentNullException>(() => { Stringerex.Ors((IEnumerable <Stringerex>)null); });
            Assert.Throws <ArgumentNullException>(() => { Stringerex <int> .Ors((Stringerex <int>)null); });
            Assert.Throws <ArgumentNullException>(() => { Stringerex <int> .Ors((Stringerex <int>[])null); });
            Assert.Throws <ArgumentNullException>(() => { Stringerex <int> .Ors((IEnumerable <Stringerex <int> >)null); });
            AssertMatches(Stringerex.Ors(_s, _sn), "MLP", True, False, False, False, True, new object[] { 0, 1 }, null, new object[] { 0, 1 }, 1, 1);
            AssertMatches(Stringerex.Ors((IEnumerable <Stringerex>) new[] { _s, _sn }), "MLP", True, False, False, False, True, new object[] { 0, 1 }, null, new object[] { 0, 1 }, 1, 1);
            AssertMatches(Stringerex <int> .Ors(_sr, _snr), "MLP", True, False, False, False, True, new object[] { 0, 1, 1 }, null, new object[] { 0, 1, 1 }, 1, 1);
            AssertMatches(Stringerex <int> .Ors((IEnumerable <Stringerex <int> >) new[] { _sr, _snr }), "MLP", True, False, False, False, True, new object[] { 0, 1, 1 }, null, new object[] { 0, 1, 1 }, 1, 1);
        }
Esempio n. 2
0
        public ConsoleColoredString Validate()
        {
            var point        = new Stringerex("(").Then(Stringerexes.Number).Then(",").ThenRaw(Stringerexes.Number, (x, y) => new PointF((float)x, (float)y)).Then(")");
            var listOfPoints = point.RepeatWithSeparatorGreedy(",");
            var result       = listOfPoints.RawMatchExact(Polygon);

            if (result == null)
            {
                return("The specified polygon does not conform to the expected syntax.");
            }
            PolygonParsed = result.ToArray();
            return(null);
        }
Esempio n. 3
0
        public void TestRawMatchNullable()
        {
            // RawMatchNullable, RawMatchReverseNullable
            var g = Generex.New(47).Process(m => 1);

            Assert.AreEqual(1, g.RawMatchNullable(_input));
            Assert.AreEqual(null, g.RawMatchNullable(_input, 1));
            Assert.AreEqual(1, g.RawMatchReverseNullable(_input));
            Assert.AreEqual(1, g.RawMatchReverseNullable(_input, 1));
            Assert.AreEqual(null, g.RawMatchReverseNullable(_input, 0));
            var s = new Stringerex('M').Process(m => 1);

            Assert.AreEqual(1, s.RawMatchNullable("MLP"));
            Assert.AreEqual(null, s.RawMatchNullable("MLP", 1));
            Assert.AreEqual(1, s.RawMatchReverseNullable("MLP"));
            Assert.AreEqual(1, s.RawMatchReverseNullable("MLP", 1));
            Assert.AreEqual(null, s.RawMatchReverseNullable("MLP", 0));
        }
Esempio n. 4
0
 public void TestRawMatchNullable()
 {
     // RawMatchNullable, RawMatchReverseNullable
     var g = Generex.New(47).Process(m => 1);
     Assert.AreEqual(1, g.RawMatchNullable(_input));
     Assert.AreEqual(null, g.RawMatchNullable(_input, 1));
     Assert.AreEqual(1, g.RawMatchReverseNullable(_input));
     Assert.AreEqual(1, g.RawMatchReverseNullable(_input, 1));
     Assert.AreEqual(null, g.RawMatchReverseNullable(_input, 0));
     var s = new Stringerex('M').Process(m => 1);
     Assert.AreEqual(1, s.RawMatchNullable("MLP"));
     Assert.AreEqual(null, s.RawMatchNullable("MLP", 1));
     Assert.AreEqual(1, s.RawMatchReverseNullable("MLP"));
     Assert.AreEqual(1, s.RawMatchReverseNullable("MLP", 1));
     Assert.AreEqual(null, s.RawMatchReverseNullable("MLP", 0));
 }