comparison UnitTestsSources/Lua.cpp @ 712:9e3f21441903

lua tests
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 13 Feb 2014 16:16:07 +0100
parents 17815b9d4280
children 3d6f9b7d0add
comparison
equal deleted inserted replaced
711:8f62e8d5a384 712:9e3f21441903
1 #include "gtest/gtest.h" 1 #include "gtest/gtest.h"
2 2
3 #include "../Core/Lua/LuaFunctionCall.h" 3 #include "../Core/Lua/LuaFunctionCall.h"
4 4
5 5
6 TEST(Lua, Simple) 6 TEST(Lua, Json)
7 { 7 {
8 Orthanc::LuaContext lua; 8 Orthanc::LuaContext lua;
9 lua.Execute(Orthanc::EmbeddedResources::LUA_TOOLBOX); 9 lua.Execute(Orthanc::EmbeddedResources::LUA_TOOLBOX);
10 lua.Execute("a={}"); 10 lua.Execute("a={}");
11 lua.Execute("a['x'] = 10"); 11 lua.Execute("a['x'] = 10");
68 68
69 ASSERT_TRUE(lua.IsExistingFunction("f")); 69 ASSERT_TRUE(lua.IsExistingFunction("f"));
70 ASSERT_FALSE(lua.IsExistingFunction("a")); 70 ASSERT_FALSE(lua.IsExistingFunction("a"));
71 ASSERT_FALSE(lua.IsExistingFunction("Dummy")); 71 ASSERT_FALSE(lua.IsExistingFunction("Dummy"));
72 } 72 }
73
74
75 TEST(Lua, Simple)
76 {
77 Orthanc::LuaContext lua;
78 lua.Execute(Orthanc::EmbeddedResources::LUA_TOOLBOX);
79
80 {
81 Orthanc::LuaFunctionCall f(lua, "PrintRecursive");
82 f.PushString("hello");
83 f.Execute();
84 }
85
86 {
87 Orthanc::LuaFunctionCall f(lua, "PrintRecursive");
88 f.PushBoolean(true);
89 f.Execute();
90 }
91
92 {
93 Orthanc::LuaFunctionCall f(lua, "PrintRecursive");
94 f.PushInteger(42);
95 f.Execute();
96 }
97
98 {
99 Orthanc::LuaFunctionCall f(lua, "PrintRecursive");
100 f.PushDouble(3.1415);
101 f.Execute();
102 }
103 }