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

Function TEST

engine/gameobject/src/gameobject/test/lua/test_res_lua.cpp:19–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17#include "res_lua.h"
18
19TEST(LuaTest, TestPatchBytesUpTo255)
20{
21 uint8_t bytecode32[] = { 0x1b, 0x4c, 0x4a, 0x02, 0x00, 0x11, 0x40, 0x6d, 0x61, 0x69, 0x6e, 0x2f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x32, 0x00, 0x01, 0x03, 0x00, 0x02, 0x00, 0x04, 0x0c, 0x01, 0x02, 0x36, 0x01, 0x00, 0x00, 0x27, 0x02, 0x01, 0x00, 0x42, 0x01, 0x02, 0x01, 0x4b, 0x00, 0x01, 0x00, 0x0a, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x0a, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x01, 0x01, 0x01, 0x02, 0x73, 0x65, 0x6c, 0x66, 0x00, 0x00, 0x05, 0x00, 0x20, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x04, 0x00, 0x04, 0x33, 0x00, 0x00, 0x00, 0x37, 0x00, 0x01, 0x00, 0x4b, 0x00, 0x01, 0x00, 0x09, 0x69, 0x6e, 0x69, 0x74, 0x00, 0x03, 0x01, 0x03, 0x00, 0x00 };
22 uint8_t bytecode64[] = { 0x1b, 0x4c, 0x4a, 0x02, 0x08, 0x11, 0x40, 0x6d, 0x61, 0x69, 0x6e, 0x2f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x32, 0x00, 0x01, 0x04, 0x00, 0x02, 0x00, 0x04, 0x0c, 0x01, 0x02, 0x36, 0x01, 0x00, 0x00, 0x27, 0x03, 0x01, 0x00, 0x42, 0x01, 0x02, 0x01, 0x4b, 0x00, 0x01, 0x00, 0x0a, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x0a, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x01, 0x01, 0x01, 0x02, 0x73, 0x65, 0x6c, 0x66, 0x00, 0x00, 0x05, 0x00, 0x20, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x04, 0x00, 0x04, 0x33, 0x00, 0x00, 0x00, 0x37, 0x00, 0x01, 0x00, 0x4b, 0x00, 0x01, 0x00, 0x09, 0x69, 0x6e, 0x69, 0x74, 0x00, 0x03, 0x01, 0x03, 0x00, 0x00 };
23 uint8_t delta[] = { 0x04, 0x01, 0x00, 0x1a, 0x01, 0x03, 0x27, 0x01, 0x02 };
24
25 dmLuaDDF::LuaSource source;
26 source.m_Bytecode.m_Data = bytecode64;
27 source.m_Bytecode.m_Count = sizeof(bytecode64);
28 source.m_Delta.m_Data = delta;
29 source.m_Delta.m_Count = sizeof(delta);
30
31 dmGameObject::PatchBytes(source.m_Bytecode.m_Data, source.m_Bytecode.m_Count, source.m_Delta.m_Data, source.m_Delta.m_Count);
32
33 for(int i=0; i<source.m_Bytecode.m_Count; i++) {
34 uint8_t a = source.m_Bytecode.m_Data[i];
35 uint8_t b = bytecode32[i];
36 ASSERT_EQ(a, b);
37 }
38}
39
40TEST(LuaTest, TestPatchBytesUpTo65535)
41{

Callers

nothing calls this directly

Calls 1

PatchBytesFunction · 0.85

Tested by

no test coverage detected