refactoring
This commit is contained in:
parent
97e8c978ce
commit
1b4bbb8772
|
@ -21,6 +21,22 @@ end \
|
|||
|
||||
#define PRINT_ARRAY "hexstr = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, \"A\", \"B\", \"C\", \"D\", \"E\", \"F\" } \
|
||||
\
|
||||
function toHexString(num) \
|
||||
if num == 0 then \
|
||||
return '0' \
|
||||
end \
|
||||
\
|
||||
local result = \"\" \
|
||||
while num > 0 do \
|
||||
local n = num % 16 \
|
||||
result = hexstr[n + 1] ..result \
|
||||
num = math.floor(num / 16) \
|
||||
end \
|
||||
return result \
|
||||
end \
|
||||
\
|
||||
\
|
||||
\
|
||||
"
|
||||
|
||||
// LSB (Least Significant Byte comes first) "Intel"
|
||||
|
|
|
@ -23,19 +23,6 @@ TEST(LuaVag, Checksum) {
|
|||
TEST(LuaVag, packMotor1) {
|
||||
const char* realdata = PRINT_ARRAY ARRAY_EQUALS SET_TWO_BYTES R"(
|
||||
|
||||
function toHexString(num)
|
||||
if num == 0 then
|
||||
return '0'
|
||||
end
|
||||
|
||||
local result = ""
|
||||
while num > 0 do
|
||||
local n = num % 16
|
||||
result = hexstr[n + 1] ..result
|
||||
num = math.floor(num / 16)
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
function arrayToString(arr)
|
||||
local str = ""
|
||||
|
|
Loading…
Reference in New Issue