MCPcopy Create free account
hub / github.com/crownengine/crown / test_lua_resource

Function test_lua_resource

src/core/unit_tests.cpp:2164–2312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2162}
2163
2164static void test_lua_resource()
2165{
2166#if CROWN_CAN_COMPILE
2167 memory_globals::init();
2168 {
2169 const char *lua = "";
2170
2171 HashSet<StringView> req(default_allocator());
2172 lua_resource_internal::find_requirements(req, lua);
2173
2174 ENSURE(hash_set::size(req) == 0);
2175 }
2176 {
2177 const char *lua = "require 'foo'";
2178
2179 HashSet<StringView> req(default_allocator());
2180 lua_resource_internal::find_requirements(req, lua);
2181
2182 ENSURE(hash_set::size(req) == 1);
2183 ENSURE(hash_set::has(req, StringView("foo")));
2184 }
2185 {
2186 const char *lua = "require \"foo\"";
2187
2188 HashSet<StringView> req(default_allocator());
2189 lua_resource_internal::find_requirements(req, lua);
2190
2191 ENSURE(hash_set::size(req) == 1);
2192 ENSURE(hash_set::has(req, StringView("foo")));
2193 }
2194 {
2195 const char *lua = "require (\"foo\")";
2196
2197 HashSet<StringView> req(default_allocator());
2198 lua_resource_internal::find_requirements(req, lua);
2199
2200 ENSURE(hash_set::size(req) == 1);
2201 ENSURE(hash_set::has(req, StringView("foo")));
2202 }
2203 {
2204 const char *lua = "require";
2205
2206 HashSet<StringView> req(default_allocator());
2207 lua_resource_internal::find_requirements(req, lua);
2208
2209 ENSURE(hash_set::size(req) == 0);
2210 }
2211 {
2212 const char *lua = "require '";
2213
2214 HashSet<StringView> req(default_allocator());
2215 lua_resource_internal::find_requirements(req, lua);
2216
2217 ENSURE(hash_set::size(req) == 0);
2218 }
2219 {
2220 const char *lua = "require ('";
2221

Callers

nothing calls this directly

Calls 6

find_requirementsFunction · 0.85
initFunction · 0.70
shutdownFunction · 0.70
sizeFunction · 0.50
hasFunction · 0.50
StringViewClass · 0.50

Tested by

no test coverage detected