ソースを参照

Update documentation

Add README for testing.
master
コミット
002f128a05
3個のファイルの変更42行の追加21行の削除
  1. +10
    -9
      CMakeLists.txt
  2. +14
    -0
      README.md
  3. +18
    -12
      test-note-names.c

+ 10
- 9
CMakeLists.txt ファイルの表示

@@ -5,15 +5,16 @@ set(CMAKE_C_STANDARD 11)

include_directories(.)

add_executable(test-note-names
test-note-names.c
midi-utils.c
midi-utils.h)

add_executable(
test-note-names
test-note-names.c
midi-utils.c
midi-utils.h
)

add_custom_command(
TARGET test-note-names POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${CMAKE_HOME_DIRECTORY}/cases.txt"
$<TARGET_FILE_DIR:test-note-names>
TARGET test-note-names POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${CMAKE_HOME_DIRECTORY}/cases.txt"
$<TARGET_FILE_DIR:test-note-names>
)

+ 14
- 0
README.md ファイルの表示

@@ -0,0 +1,14 @@
# `midi-utils`

Small library for MIDI-related functions.

## Testing

```shell
cmake -S . -B cmake-build-debug -G Ninja
cmake --build cmake-build-debug -t test-note-names
```

## License

[MIT](./LICENSE)

+ 18
- 12
test-note-names.c ファイルの表示

@@ -2,6 +2,22 @@
#include <assert.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) {
FILE* f = fopen("cases.txt", "r");
if (!f) {
@@ -11,20 +27,10 @@ int main(void) {
unsigned int read_note_value;
while (!feof(f)) {
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")) {
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);
}
}



読み込み中…
キャンセル
保存