Beispiel #1
0
        public void CompareTest()
        {
            var a = new byte[]
            {
                0xcd, 0x7c, 0xf6, 0x7b, 0xe3, 0x9c, 0x79, 0x4a
            };

            var b = new byte[]
            {
                0x77, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d,
            };

            var c = new byte[]
            {
                0xcd, 0x7c, 0xf6, 0x7b, 0xe3, 0x9c, 0x79, 0x4a
            };

            var d = new byte[]
            {
                0xcd, 0x7c, 0xf6, 0x7b, 0xe3, 0x9c
            };

            Assert.AreEqual(false, Utilities.Compare(a, b));
            Assert.AreEqual(true, Utilities.Compare(a, c));
            Assert.AreEqual(false, Utilities.Compare(a, d));
            Assert.AreEqual(false, Utilities.Compare(d, b));
        }
Beispiel #2
0
        public void PlainStructs()
        {
            var unit       = JsonModelBuilder.FromCppFile("PlainStructs.hpp");
            var references = new JObject[]
            {
                new JObject
                {
                    ["Name"]   = "A",
                    ["Fields"] = new JArray
                    {
                        new JObject
                        {
                            ["Name"]   = "a",
                            ["Type"]   = "int",
                            ["Access"] = "Public",
                            ["Const"]  = false,
                        }
                    }
                },
                new JObject
                {
                    ["Name"]   = "B",
                    ["Fields"] = new JArray
                    {
                        new JObject
                        {
                            ["Name"]   = "b",
                            ["Type"]   = "int",
                            ["Access"] = "Public",
                            ["Const"]  = false,
                        }
                    },
                    ["Bases"] = new JArray
                    {
                        new JObject
                        {
                            ["Type"]   = "struct A",
                            ["Access"] = "Public",
                        }
                    }
                },
                new JObject
                {
                    ["Name"]   = "C",
                    ["Fields"] = new JArray
                    {
                        new JObject
                        {
                            ["Name"]   = "c",
                            ["Type"]   = "int",
                            ["Access"] = "Public",
                            ["Const"]  = false,
                        },
                        new JObject
                        {
                            ["Name"]   = "m",
                            ["Type"]   = "struct B",
                            ["Access"] = "Public",
                            ["Const"]  = false,
                        }
                    },
                },
                new JObject
                {
                    ["Name"]   = "D",
                    ["Fields"] = new JArray
                    {
                        new JObject
                        {
                            ["Name"]   = "d",
                            ["Type"]   = "int",
                            ["Access"] = "Public",
                            ["Const"]  = false,
                        },
                        new JObject
                        {
                            ["Name"]   = "x",
                            ["Type"]   = "int",
                            ["Access"] = "Private",
                            ["Const"]  = false,
                        },
                    },
                    ["Bases"] = new JArray
                    {
                        new JObject
                        {
                            ["Type"]   = "struct C",
                            ["Access"] = "Public",
                        }
                    },
                }
            };

            Utilities.Compare(references, unit["Structs"]);
            Console.WriteLine("PlainStructs for JSON model passed.");
        }
Beispiel #3
0
        public void ClassWithStuff()
        {
            var unit       = JsonModelBuilder.FromCppFile("ClassWithStuff.hpp");
            var references = new JObject[]
            {
                new JObject
                {
                    ["Name"]   = "MyClass",
                    ["Fields"] = new JArray
                    {
                        new JObject
                        {
                            ["Name"]   = "field",
                            ["Type"]   = "int",
                            ["Access"] = "Public",
                            ["Const"]  = false,
                        },
                        new JObject
                        {
                            ["Name"]   = "constant",
                            ["Type"]   = "const int",
                            ["Access"] = "Public",
                            ["Const"]  = true,
                        },
                        new JObject
                        {
                            ["Name"]   = "secret_field",
                            ["Type"]   = "int",
                            ["Access"] = "Private",
                            ["Const"]  = false,
                        },
                    },
                    ["Variables"] = new JArray
                    {
                        new JObject
                        {
                            ["Name"]  = "static_field",
                            ["Type"]  = "const int",
                            ["Const"] = true,
                        }
                    },
                    ["Methods"] = new JArray
                    {
                        new JObject
                        {
                            ["Name"]        = "method",
                            ["ReturnType"]  = "void",
                            ["Const"]       = true,
                            ["Virtual"]     = true,
                            ["PureVirtual"] = true,
                            ["Static"]      = false,
                            ["Access"]      = "Public",
                            ["Parameters"]  = new JArray(),
                        },
                        new JObject
                        {
                            ["Name"]        = "static_method",
                            ["ReturnType"]  = "int",
                            ["Const"]       = false,
                            ["Virtual"]     = false,
                            ["PureVirtual"] = false,
                            ["Static"]      = true,
                            ["Access"]      = "Public",
                            ["Parameters"]  = new JArray
                            {
                                new JObject
                                {
                                    ["Name"] = "abc",
                                    ["Type"] = "int",
                                }
                            },
                        }
                    }
                },
            };

            Utilities.Compare(references, unit["Classes"]);

            var references2 = new JObject[]
            {
                new JObject
                {
                    ["Name"]  = "MyClassDerived",
                    ["Bases"] = new JArray
                    {
                        new JObject
                        {
                            ["Type"]   = "class MyClass",
                            ["Access"] = "Private"
                        }
                    },
                    ["TypeParameters"] = new JArray
                    {
                        new JObject
                        {
                            ["Name"] = "T"
                        }
                    },
                    ["Constructors"] = new JArray
                    {
                        new JObject
                        {
                            ["Access"]     = "Public",
                            ["Name"]       = "MyClassDerived<T>",
                            ["Parameters"] = new JArray
                            {
                                new JObject
                                {
                                    ["Name"] = "a",
                                    ["Type"] = "int"
                                }
                            }
                        }
                    }
                }
            };

            Utilities.Compare(references2, unit["ClassTemplates"]);
            Console.WriteLine("ClassWithStuff for JSON model passed.");
        }