interpret/test/test_journal.c

83 lines
1.5 KiB
C

#include "../src/journal.h"
#include <stdio.h>
#include <inttypes.h> /* C99 */
#include <stdlib.h>
#include <assert.h>
int main(void) {
struct journal j = journal();
int success = EXIT_SUCCESS;
if(!journal_is_valid(&j)) goto catch;
printf("Journal: %s.\n", journal_to_string(&j));
{
struct journal_iterator it = journal_begin(&j);
union date32 date;
const char *value;
if(!(journal_next(&it, &date, &value))) goto catch;
printf("%u-%u-%u\n"
"<%s>\n", date.year, date.month, date.day, value);
}
goto finally;
catch:
success = EXIT_FAILURE;
perror("journal");
finally:
journal_(&j);
return success;
}
#if 0
/*
### plot with steps
reset session
$Data <<EOD
1,1,0
1,2,0
1,3,0
1,4,2
1,5,1
1,6,3
1,7,3
1,8,1
1,9,3
1,10,8
1,11,1
1,12,0
1,13,3
EOD
set title "Cumulative count" font ",16"
set xlabel "episode"
set ylabel "cumulative count"
set xtics 1
set key bottom right
set grid
unset border
set datafile separator comma
plot $Data u 2:($3) smooth cumulative with steps lw 2 lc "red" ti "cumulative count"
### end of code
*/
/*#define C_BLACK "\033[0;30m"
#define C_RED "\033[0;31m"
#define C_GREEN "\033[0;32m"*/
#define C_YELLOW "\033[0;33m"
/*#define C_BLUE "\033[0;34m"
#define C_PURPLE "\033[0;35m"
#define C_CYAN "\033[0;36m"
#define C_WHITE "\033[0;37m"
#define CB_BLACK "\033[1;30m"
#define CB_RED "\033[1;31m"
#define CB_GREEN "\033[1;32m"
#define CB_YELLOW "\033[1;33m"
#define CB_BLUE "\033[1;34m"
#define CB_PURPLE "\033[1;35m"
#define CB_CYAN "\033[1;36m"
#define CB_WHITE "\033[1;37m"*/
#define C_RESET "\033[0m"
#endif