mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
set size of arg to uint32_t to aline to 4
This commit is contained in:
parent
e184adc59d
commit
d0eabb0b94
2
port/linux/.vscode/launch.json
vendored
2
port/linux/.vscode/launch.json
vendored
@ -18,6 +18,8 @@
|
||||
"program": "${workspaceFolder}/build/test/pikascript_test",
|
||||
// "program": "${workspaceFolder}/../build/src/boot/demo06-pikamain/pikascript_demo06-pikamain",
|
||||
"args": [
|
||||
// "--gtest_filter=arg_test*",
|
||||
"--gtest_filter=content*",
|
||||
// "--gtest_filter=pikaMain.print_in_def",
|
||||
// "--gtest_filter=pikaMain.list_for_loop"
|
||||
// "--gtest_filter=pikaMain.err_scop"
|
||||
|
@ -22,15 +22,15 @@ TEST(content, init) {
|
||||
uint16_t size = content_getSize(self);
|
||||
uint8_t* content = content_getContent(self);
|
||||
|
||||
ASSERT_EQ(contentOffset, 14);
|
||||
ASSERT_EQ(typeOffset, 18);
|
||||
ASSERT_EQ(contentOffset, 16);
|
||||
ASSERT_EQ(typeOffset, 20);
|
||||
ASSERT_EQ(sizeOffset, 8);
|
||||
ASSERT_EQ(size, 4);
|
||||
ASSERT_EQ(content[0], 1);
|
||||
ASSERT_EQ(content[1], 2);
|
||||
ASSERT_EQ(content[2], 3);
|
||||
ASSERT_EQ(content[3], 4);
|
||||
ASSERT_EQ(totleSize, 22);
|
||||
ASSERT_EQ(totleSize, 24);
|
||||
|
||||
ASSERT_EQ(hash_time33((char*)"name"), nameHash);
|
||||
ASSERT_EQ(TYPE_NONE, type);
|
||||
@ -60,15 +60,15 @@ TEST(content, set) {
|
||||
uint16_t size = content_getSize(self);
|
||||
uint8_t* content = content_getContent(self);
|
||||
|
||||
ASSERT_EQ(contentOffset, 14);
|
||||
ASSERT_EQ(typeOffset, 18);
|
||||
ASSERT_EQ(contentOffset, 16);
|
||||
ASSERT_EQ(typeOffset, 20);
|
||||
ASSERT_EQ(sizeOffset, 8);
|
||||
ASSERT_EQ(size, 4);
|
||||
ASSERT_EQ(content[0], 1);
|
||||
ASSERT_EQ(content[1], 2);
|
||||
ASSERT_EQ(content[2], 3);
|
||||
ASSERT_EQ(content[3], 4);
|
||||
ASSERT_EQ(totleSize, 22);
|
||||
ASSERT_EQ(totleSize, 24);
|
||||
|
||||
ASSERT_EQ(hash_time33((char*)"name"), nameHash);
|
||||
ASSERT_EQ(TYPE_NONE, type);
|
||||
|
@ -76,10 +76,10 @@ Hash hash_time33(char* str) {
|
||||
uint8_t* content_init_hash(Hash nameHash,
|
||||
ArgType type,
|
||||
uint8_t* content,
|
||||
uint16_t size,
|
||||
uint32_t size,
|
||||
uint8_t* next) {
|
||||
const uint8_t nextLength = sizeof(uint8_t*);
|
||||
const uint8_t sizeLength = sizeof(uint16_t);
|
||||
const uint8_t sizeLength = sizeof(uint32_t);
|
||||
uint16_t nameSize = sizeof(Hash); // use hash
|
||||
uint16_t typeSize = sizeof(ArgType); // use enum
|
||||
uint8_t* self = (uint8_t*)pikaMalloc(nextLength + sizeLength + nameSize +
|
||||
@ -121,7 +121,7 @@ uint8_t* content_init(char* name,
|
||||
}
|
||||
|
||||
uint16_t content_totleSize(uint8_t* self) {
|
||||
const uint8_t size_size = sizeof(uint16_t);
|
||||
const uint8_t size_size = sizeof(uint32_t);
|
||||
const uint8_t size_next = sizeof(uint8_t*);
|
||||
const uint8_t size_type = sizeof(ArgType);
|
||||
const uint8_t size_hash = sizeof(Hash);
|
||||
@ -137,7 +137,7 @@ void arg_freeContent(Arg* self) {
|
||||
|
||||
uint8_t content_nameOffset(uint8_t* self) {
|
||||
const uint8_t nextLength = sizeof(uint8_t*);
|
||||
const uint8_t sizeLength = sizeof(uint16_t);
|
||||
const uint8_t sizeLength = sizeof(uint32_t);
|
||||
return nextLength + sizeLength;
|
||||
}
|
||||
|
||||
@ -239,7 +239,7 @@ ArgType content_getType(uint8_t* self) {
|
||||
|
||||
uint16_t content_contentOffset(uint8_t* self) {
|
||||
const uint8_t nextLength = sizeof(uint8_t*);
|
||||
const uint8_t sizeLength = sizeof(uint16_t);
|
||||
const uint8_t sizeLength = sizeof(uint32_t);
|
||||
return nextLength + sizeLength + sizeof(Hash);
|
||||
}
|
||||
|
||||
@ -360,7 +360,7 @@ char* arg_getStr(Arg* self) {
|
||||
|
||||
uint16_t content_typeOffset(uint8_t* self) {
|
||||
const uint8_t nextLength = sizeof(uint8_t*);
|
||||
const uint8_t sizeLength = 2;
|
||||
const uint8_t sizeLength = sizeof(uint32_t);
|
||||
uint16_t size = content_getSize(self);
|
||||
uint16_t nameSize = sizeof(Hash);
|
||||
return nextLength + sizeLength + nameSize + size;
|
||||
|
Loading…
x
Reference in New Issue
Block a user