コード例 #1
0
        public void KhronosLosContext_TestConstructur()
        {
            KhronosLogContext ctx = null;

            Assert.Throws <ArgumentNullException>(() => ctx = new KhronosLogContext(null));
            Assert.DoesNotThrow(() => ctx = new KhronosLogContext(typeof(TestApi)));

            Assert.AreEqual("NONE", ctx.GetEnumName(0));
            Assert.AreEqual("ONE", ctx.GetEnumName(1));
            Assert.AreEqual("TWO", ctx.GetEnumName(2));
            Assert.IsNull(ctx.GetEnumName(-1));
            Assert.IsNull(ctx.GetEnumName(-2));
        }
コード例 #2
0
        public void KhronosLosContext_TestToString()
        {
            KhronosLogContext ctx = new KhronosLogContext(typeof(TestApi));

            Assert.Throws <ArgumentNullException>(() => ctx.ToString(null, null, null));

            Assert.AreEqual("glCommand()", ctx.ToString("glCommand", null, null));
            Assert.AreEqual("glCommand() = -1", ctx.ToString("glCommand", -1, null));
            Assert.AreEqual("glCommand(15)", ctx.ToString("glCommand", null, new object[] { 15 }));
            Assert.AreEqual("glCommand(\"value\")", ctx.ToString("glCommand", null, new object[] { "value" }));
            Assert.AreEqual("glCommand(0x00000000)", ctx.ToString("glCommand", null, new object[] { IntPtr.Zero }));
            Assert.AreEqual("glCommand({15,16,17})", ctx.ToString("glCommand", null, new object[] { new int[] { 15, 16, 17 } }));
        }
コード例 #3
0
ファイル: KhronosLogContext.cs プロジェクト: koson/OpenGL.Net
        public void KhronosLosContext_ToString()
        {
            KhronosLogMap m = new KhronosLogMap {
                Commands = new[] {
                    new KhronosLogMap.Command {
                        Name   = "glCommand2",
                        Params = new[] {
                            new KhronosLogMap.CommandParam {
                                Name = "arg0", Flags = KhronosLogCommandParameterFlags.Enum
                            },
                            new KhronosLogMap.CommandParam {
                                Name = "arg1", Flags = KhronosLogCommandParameterFlags.None
                            },
                            new KhronosLogMap.CommandParam {
                                Name = "arg2",                                                         /* Flags defaults to None */
                            }
                        }
                    }
                }
            };
            KhronosLogContext ctx = new KhronosLogContext(typeof(TestApi), m);

            Assert.Throws <ArgumentNullException>(() => ctx.ToString(null, null, null));

            Assert.AreEqual("glCommand()", ctx.ToString("glCommand", null, null));
            Assert.AreEqual("glCommand() = -1", ctx.ToString("glCommand", -1, null));
            Assert.AreEqual("glCommand(15)", ctx.ToString("glCommand", null, new object[] { 15 }));
            Assert.AreEqual("glCommand(\"value\")", ctx.ToString("glCommand", null, new object[] { "value" }));
            Assert.AreEqual("glCommand(0x00000000)", ctx.ToString("glCommand", null, new object[] { IntPtr.Zero }));
            Assert.AreEqual("glCommand({15,16,17})", ctx.ToString("glCommand", null, new object[] { new[] { 15, 16, 17 } }));
            Assert.AreEqual("glCommand({15,16,17}, 18, 19)", ctx.ToString("glCommand", null, new object[] { new[] { 15, 16, 17 }, 18, 19 }));
            Assert.AreEqual("glCommand({a,b,c}, 18, 19)", ctx.ToString("glCommand", null, new object[] { new[] { "a", "b", "c" }, 18, 19 }));
            Assert.AreEqual("glCommand(null)", ctx.ToString("glCommand", null, new object[] { null }));

            Assert.AreEqual("glCommand2(NONE, 0, 0)", ctx.ToString("glCommand2", null, new object[] { 0, 0, 0 }));
            Assert.AreEqual("glCommand2({ONE,TWO}, 1, 2)", ctx.ToString("glCommand2", null, new object[] { new[] { 1, 2 }, 1, 2 }));
        }