|
@@ -2,6 +2,22 @@ |
|
|
#include <assert.h> |
|
|
#include <assert.h> |
|
|
#include "midi-utils.h" |
|
|
#include "midi-utils.h" |
|
|
|
|
|
|
|
|
|
|
|
void check_note_value(char* read_note_name, unsigned char read_note_value) { |
|
|
|
|
|
unsigned int actual_note_value = MIDI_GetNoteFromName(read_note_name); |
|
|
|
|
|
printf("MIDI_GetNoteFromName(\"%s\")...", read_note_name); |
|
|
|
|
|
printf("(%d == %d) ", read_note_value, actual_note_value); |
|
|
|
|
|
assert(read_note_value == actual_note_value); |
|
|
|
|
|
printf("OK!\n"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void check_note_name(char* read_note_name, unsigned char read_note_value) { |
|
|
|
|
|
printf("MIDI_GetNoteName(%d)...", read_note_value); |
|
|
|
|
|
char* actual_note_name = MIDI_GetNoteName(read_note_value); |
|
|
|
|
|
printf("(%s == %s) ", read_note_name, actual_note_name); |
|
|
|
|
|
assert(!strcmp(read_note_name, actual_note_name)); |
|
|
|
|
|
printf("OK!\n"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
int main(void) { |
|
|
int main(void) { |
|
|
FILE* f = fopen("cases.txt", "r"); |
|
|
FILE* f = fopen("cases.txt", "r"); |
|
|
if (!f) { |
|
|
if (!f) { |
|
@@ -11,20 +27,10 @@ int main(void) { |
|
|
unsigned int read_note_value; |
|
|
unsigned int read_note_value; |
|
|
while (!feof(f)) { |
|
|
while (!feof(f)) { |
|
|
fscanf(f, "%s %d\n", read_note_name, &read_note_value); |
|
|
fscanf(f, "%s %d\n", read_note_name, &read_note_value); |
|
|
unsigned int actual_note_value = MIDI_GetNoteFromName(read_note_name); |
|
|
|
|
|
printf("MIDI_GetNoteFromName(\"%s\")...", read_note_name); |
|
|
|
|
|
printf("(%d == %d) ", read_note_value, actual_note_value); |
|
|
|
|
|
assert(read_note_value == actual_note_value); |
|
|
|
|
|
printf("OK!\n"); |
|
|
|
|
|
|
|
|
check_note_value(read_note_name, read_note_value); |
|
|
|
|
|
|
|
|
if (read_note_value != 255u || !strcmp(read_note_name, "D#21")) { |
|
|
if (read_note_value != 255u || !strcmp(read_note_name, "D#21")) { |
|
|
printf("MIDI_GetNoteName(%d)...", read_note_value); |
|
|
|
|
|
char* actual_note_name = MIDI_GetNoteName(read_note_value); |
|
|
|
|
|
|
|
|
|
|
|
printf("(%s == %s) ", read_note_name, actual_note_name); |
|
|
|
|
|
assert(!strcmp(read_note_name, actual_note_name)); |
|
|
|
|
|
|
|
|
|
|
|
printf("OK!\n"); |
|
|
|
|
|
|
|
|
check_note_name(read_note_name, read_note_value); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|