Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdbool.h>
- #include <stdlib.h>
- FILE *fptr;
- void print_testcase(int order, char label[], bool status) {
- fprintf(fptr,"{\n");
- fprintf(fptr,"\"order\": %d,\n", order);
- fprintf(fptr,"\"label\": \"%s\",\n", label);
- fprintf(fptr,"\"didPass\": %s\n", status ? "true" : "false");
- fprintf(fptr,"}");
- }
- int main() {
- fptr = fopen("custom_report.json", "w");
- if(fptr == NULL)
- {
- printf("Error!");
- exit(1);
- }
- fprintf(fptr,"[\n");
- print_testcase(1, "Test Case#1", add(4,3)==7);
- fprintf(fptr,",\n");
- print_testcase(2, "Test Case#2", add(4,-3)==1);
- fprintf(fptr,"\n]");
- fclose(fptr);
- return 0;
- }
Add Comment
Please, Sign In to add comment