2023-03-15 01:02:22 -04:00
|
|
|
#include "../src/kjvcount.h"
|
2022-12-27 15:28:04 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <inttypes.h> /* C99 */
|
|
|
|
#include <stdlib.h>
|
2022-12-27 16:55:58 -05:00
|
|
|
#include <assert.h>
|
2023-03-10 23:06:11 -05:00
|
|
|
#include <errno.h>
|
2022-12-27 15:28:04 -05:00
|
|
|
|
|
|
|
int main(void) {
|
2022-12-27 16:48:45 -05:00
|
|
|
int success = EXIT_SUCCESS;
|
2023-03-10 23:06:11 -05:00
|
|
|
errno = 0; /* `errno` is not set correctly to 0 in some debug situations. */
|
2023-03-15 01:02:22 -04:00
|
|
|
struct kjvcount count = kjvcount();
|
|
|
|
struct kjvset_table set = kjv_set();
|
|
|
|
fprintf(stderr, "%zu total words, %s.\n",
|
|
|
|
count.words.total, kjvcount_to_string(&count));
|
|
|
|
if(kjvcount_is_empty(&count)) goto catch;
|
|
|
|
kjv_set_add(&set, &count,
|
|
|
|
(union kjvcite){ .book = Genesis, .chapter = 1, .verse = 1 });
|
|
|
|
kjv_set_add(&set, &count,
|
|
|
|
(union kjvcite){ .book = Genesis, .chapter = 1, .verse = 2 });
|
|
|
|
kjv_set_add(&set, &count,
|
|
|
|
(union kjvcite){ .book = Genesis, .chapter = 1, .verse = 1 });
|
|
|
|
fprintf(stderr, "%zu of which: %s.\n", count.words.set, kjv_set_to_string(&set));
|
|
|
|
assert(count.words.total == 789633);
|
|
|
|
assert(count.words.set == 39);
|
2022-12-27 16:48:45 -05:00
|
|
|
goto finally;
|
|
|
|
catch:
|
|
|
|
success = EXIT_FAILURE, perror("kjv");
|
|
|
|
finally:
|
2023-03-15 01:02:22 -04:00
|
|
|
kjv_set_(&set);
|
|
|
|
kjvcount_(&count);
|
2022-12-27 16:48:45 -05:00
|
|
|
return success;
|
2022-12-27 15:28:04 -05:00
|
|
|
}
|