static void treasure_type_by_letter_A_test(void) { struct treasure_type *treasure_type = treasure_type_by_letter('A'); assert(NULL != treasure_type); char *name = treasure_type_alloc_name(treasure_type); assert(str_eq("A", name)); free_or_die(name); char *description = treasure_type_alloc_description(treasure_type, false); char const *expected = " A | 1-6:25% | 1-6:30% | 1-6:35% | 1-10:40% | 1-4:25% | 4-40:60% | 3-30:50% | any 3: 30%\n"; assert(str_eq(expected, description)); free_or_die(description); description = treasure_type_alloc_description(treasure_type, true); expected = " | 1,000's | 1,000's | 1,000's | 1,000's | 100's | | | Maps \n" "Treasure | of | of | of | of | of | | | or \n" " Type | Copper | Silver | Electrum | Gold | Platinum | Gems | Jewelry | Magic \n" "----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------\n" " A | 1-6:25% | 1-6:30% | 1-6:35% | 1-10:40% | 1-4:25% | 4-40:60% | 3-30:50% | any 3: 30%\n"; assert(str_eq(expected, description)); free_or_die(description); }
static void generate_treasure_type_table(FILE *out) { for (char letter = 'A'; letter <= 'Z'; ++letter) { struct treasure_type *treasureType = treasure_type_by_letter(letter); char *description = treasure_type_alloc_description(treasureType, letter == 'A'); fprintf(out, "%s", description); free_or_die(description); } }