set tested

This commit is contained in:
lyon 2021-08-31 15:06:54 +08:00
parent 599461f854
commit 35e979dd52
2 changed files with 40 additions and 1 deletions

@ -1 +1 @@
Subproject commit f41adead2e8ecb07de7e11de7beec88e439cf54b
Subproject commit 34fe79a0fa67e429e80325b31191afcb9397e2d3

View File

@ -90,3 +90,42 @@ TEST(content, init)
content_deinit(self);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(content, set)
{
uint8_t contentIn[4] = {0};
contentIn[0] = 1;
contentIn[1] = 2;
contentIn[2] = 3;
contentIn[3] = 4;
uint8_t *self = content_init("", "", NULL, 0);
self = content_setName(self, "name");
self = content_setType(self, "type");
self = content_setContent(self, contentIn, 4);
uint16_t typeOffset = content_typeOffset(self);
uint16_t sizeOffset = content_sizeOffset(self);
uint16_t contentOffset = content_contentOffset(self);
uint16_t totleSize = content_totleSize(self);
char *name = content_getName(self);
char *type = content_getType(self);
uint16_t size = content_getSize(self);
uint8_t *content = content_getContent(self);
ASSERT_EQ(contentOffset, 12);
ASSERT_EQ(typeOffset, 5);
ASSERT_EQ(sizeOffset, 10);
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, 16);
ASSERT_STREQ("name", name);
ASSERT_STREQ("type", type);
content_deinit(self);
EXPECT_EQ(pikaMemNow(), 0);
}