MCPcopy Create free account
hub / github.com/defold/defold / TEST_F

Function TEST_F

engine/script/src/test/test_script_hash.cpp:28–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26};
27
28TEST_F(ScriptHashTest, TestHash)
29{
30 int top = lua_gettop(L);
31
32 char hash_hex[64];
33 const char* s = "test_value";
34 dmhash_t hash = dmHashString64(s);
35 dmSnPrintf(hash_hex, sizeof(hash_hex), "%016llx", (unsigned long long)hash);
36 dmScript::PushHash(L, hash);
37 ASSERT_EQ(hash, dmScript::CheckHash(L, -1));
38 lua_pop(L, 1);
39
40 ASSERT_EQ(top, lua_gettop(L));
41
42 ASSERT_TRUE(RunFile(L, "test_hash.luac"));
43
44 lua_getglobal(L, "functions");
45 ASSERT_EQ(LUA_TTABLE, lua_type(L, -1));
46 lua_getfield(L, -1, "test_hash");
47 ASSERT_EQ(LUA_TFUNCTION, lua_type(L, -1));
48 dmScript::PushHash(L, hash);
49 lua_pushstring(L, hash_hex);
50 int result = dmScript::PCall(L, 2, LUA_MULTRET);
51 if (result == LUA_ERRRUN)
52 {
53 ASSERT_TRUE(false);
54 }
55 else
56 {
57 ASSERT_EQ(0, result);
58 }
59 lua_pop(L, 1);
60
61 dmScript::PushHash(L, dmHashString64("test"));
62 ASSERT_TRUE(dmScript::IsHash(L, -1));
63 lua_pop(L, 1);
64 ASSERT_FALSE(dmScript::IsHash(L, -1));
65
66 ASSERT_EQ(top, lua_gettop(L));
67}
68
69TEST_F(ScriptHashTest, TestHashUnknown)
70{

Callers

nothing calls this directly

Calls 15

lua_gettopFunction · 0.85
dmSnPrintfFunction · 0.85
PushHashFunction · 0.85
CheckHashFunction · 0.85
lua_typeFunction · 0.85
lua_getfieldFunction · 0.85
lua_pushstringFunction · 0.85
PCallFunction · 0.85
IsHashFunction · 0.85
dmHashEnableReverseHashFunction · 0.85
lua_tobooleanFunction · 0.85
lua_touserdataFunction · 0.85

Tested by

no test coverage detected