Example #1
0
        public void String()
        {
            var literal       = new GGLiteral("This is a string");
            var actualLiteral = GGParser.Parse(literal.ToString());

            Assert.Equal(literal, actualLiteral);
        }
Example #2
0
        public void Null()
        {
            var literal       = new GGLiteral(null);
            var actualLiteral = GGParser.Parse(literal.ToString());

            Assert.Equal(literal, actualLiteral);
        }
Example #3
0
        public void NumberDouble()
        {
            var literal       = new GGLiteral(42.42);
            var actualLiteral = GGParser.Parse(literal.ToString());

            Assert.Equal(literal, actualLiteral);

            literal       = new GGLiteral(-42.42);
            actualLiteral = GGParser.Parse(literal.ToString());
            Assert.Equal(literal, actualLiteral);
        }
Example #4
0
        public void Hash()
        {
            var values = new Dictionary <string, GGValue> {
                { "int", new GGLiteral(42) },
                { "double", new GGLiteral(3.14159) },
                { "string", new GGLiteral("My string") },
                { "array", new GGArray(new GGLiteral(0), new GGLiteral(1)) },
                { "null", new GGLiteral(null) }
            };
            var gHash         = new GGHash(values);
            var actualLiteral = GGParser.Parse(gHash.ToString());

            Assert.Equal(gHash, actualLiteral);
        }
Example #5
0
        public void Array()
        {
            var array         = new double[] { 1.1, 2.2, 3.3 };
            var gArray        = new GGArray(array.Select(o => new GGLiteral(o)));
            var actualLiteral = GGParser.Parse(gArray.ToString());

            Assert.Equal(gArray, actualLiteral);

            var arrayStrings = new string[] { "a", "b", "c", "d" };

            gArray        = new GGArray(arrayStrings.Select(o => new GGLiteral(o)));
            actualLiteral = GGParser.Parse(gArray.ToString());
            Assert.Equal(gArray, actualLiteral);
        }