comparison UnitTestsSources/LuaTests.cpp @ 4031:e3b3af80732d

ServerResources, and moving EmbeddedResourceHttpHandler from Core to OrthancServer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 09 Jun 2020 21:31:13 +0200
parents 27628b0f6ada
children 058b5ade8acd
comparison
equal deleted inserted replaced
4030:100fbe970762 4031:e3b3af80732d
40 40
41 #include "../Core/OrthancException.h" 41 #include "../Core/OrthancException.h"
42 #include "../Core/Toolbox.h" 42 #include "../Core/Toolbox.h"
43 #include "../Core/Lua/LuaFunctionCall.h" 43 #include "../Core/Lua/LuaFunctionCall.h"
44 44
45 #include <ServerResources.h>
46
45 #include <boost/lexical_cast.hpp> 47 #include <boost/lexical_cast.hpp>
46 48
47 #if !defined(UNIT_TESTS_WITH_HTTP_CONNEXIONS) 49 #if !defined(UNIT_TESTS_WITH_HTTP_CONNEXIONS)
48 #error "Please set UNIT_TESTS_WITH_HTTP_CONNEXIONS to 0 or 1" 50 #error "Please set UNIT_TESTS_WITH_HTTP_CONNEXIONS to 0 or 1"
49 #endif 51 #endif
52 TEST(Lua, Json) 54 TEST(Lua, Json)
53 { 55 {
54 Orthanc::LuaContext lua; 56 Orthanc::LuaContext lua;
55 57
56 #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK != 1 58 #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK != 1
57 lua.Execute(Orthanc::EmbeddedResources::LUA_TOOLBOX); 59 {
58 #endif 60 std::string command;
59 61 Orthanc::ServerResources::GetFileResource(command, Orthanc::ServerResources::LUA_TOOLBOX);
62 lua.Execute(command);
63 }
64 #endif
65
60 lua.Execute("a={}"); 66 lua.Execute("a={}");
61 lua.Execute("a['x'] = 10"); 67 lua.Execute("a['x'] = 10");
62 lua.Execute("a['y'] = {}"); 68 lua.Execute("a['y'] = {}");
63 lua.Execute("a['y'][1] = 20"); 69 lua.Execute("a['y'][1] = 20");
64 lua.Execute("a['y'][2] = 20"); 70 lua.Execute("a['y'][2] = 20");
129 135
130 #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK != 1 136 #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK != 1
131 TEST(Lua, Simple) 137 TEST(Lua, Simple)
132 { 138 {
133 Orthanc::LuaContext lua; 139 Orthanc::LuaContext lua;
134 lua.Execute(Orthanc::EmbeddedResources::LUA_TOOLBOX); 140
141 {
142 std::string command;
143 Orthanc::ServerResources::GetFileResource(command, Orthanc::ServerResources::LUA_TOOLBOX);
144 lua.Execute(command);
145 }
135 146
136 { 147 {
137 Orthanc::LuaFunctionCall f(lua, "PrintRecursive"); 148 Orthanc::LuaFunctionCall f(lua, "PrintRecursive");
138 f.PushString("hello"); 149 f.PushString("hello");
139 f.Execute(); 150 f.Execute();