csv reworked, and header support added, no memory leaks found, still needs more testing
This commit is contained in:
parent
3f97b6d497
commit
39e7403b82
2 changed files with 82 additions and 53 deletions
|
|
@ -44,3 +44,38 @@ ARC_TEST(Parser_ParserCSV_BasicTest){
|
|||
|
||||
ARC_Parser_Destroy(parser);
|
||||
}
|
||||
|
||||
ARC_TEST(Parser_ParserCSV_BasicHeaderTest){
|
||||
ARC_Parser *parser;
|
||||
ARC_ParserCSV_CreateAsParser(&parser, ARC_True, TEST_ParserCSV_CastTypeFn, TEST_ParserCSV_DestroyTypeFn);
|
||||
|
||||
const char *tempCString =
|
||||
"a,b,c,d\n"
|
||||
"4,3,2,1\n"
|
||||
"7,3,2,1\n"
|
||||
"4,2,4,1\n"
|
||||
"7,7,7,7\n";
|
||||
|
||||
ARC_String *tempString;
|
||||
ARC_String_CreateWithStrlen(&tempString, (char *)tempCString);
|
||||
|
||||
//this destroys string, so no need for cleanup
|
||||
ARC_Parser_Parse(parser, &tempString);
|
||||
ARC_CHECK(arc_errno == 0);
|
||||
|
||||
ARC_ParserCSVData *data = (ARC_ParserCSVData *)ARC_Parser_GetData(parser);
|
||||
|
||||
for(uint32_t x = 0; x < data->width; x++){
|
||||
printf("%s ", data->headers[x]->data);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
for(uint32_t y = 0; y < data->height; y++){
|
||||
for(uint32_t x = 0; x < data->width; x++){
|
||||
printf("%d ", *(int32_t *)(data->data[y][x]));
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
ARC_Parser_Destroy(parser);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue