Browse Source

Ensure that the old translator is not used after calling espeak_Terminate.

master
Reece H. Dunn 8 years ago
parent
commit
63e2826753
2 changed files with 13 additions and 0 deletions
  1. 1
    0
      src/libespeak-ng/speech.c
  2. 12
    0
      tests/api.c

+ 1
- 0
src/libespeak-ng/speech.c View File

@@ -899,6 +899,7 @@ ESPEAK_NG_API espeak_ng_STATUS espeak_ng_Terminate(void)
outbuf = NULL;
FreePhData();
FreeVoiceList();
translator = NULL;

return ENS_OK;
}

+ 12
- 0
tests/api.c View File

@@ -37,9 +37,11 @@ test_espeak_terminate_without_initialize()
printf("testing espeak_Terminate without espeak_Initialize\n");

assert(event_list == NULL);
assert(translator == NULL);

assert(espeak_Terminate() == EE_OK);
assert(event_list == NULL);
assert(translator == NULL);
}

void
@@ -48,12 +50,15 @@ test_espeak_initialize()
printf("testing espeak_Initialize\n");

assert(event_list == NULL);
assert(translator == NULL);

assert(espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 0, NULL, 0) == 22050);
assert(event_list != NULL);
assert(translator == NULL);

assert(espeak_Terminate() == EE_OK);
assert(event_list == NULL);
assert(translator == NULL);
}

void
@@ -62,16 +67,22 @@ test_espeak_synth()
printf("testing espeak_Synth\n");

assert(event_list == NULL);
assert(translator == NULL);

assert(espeak_Initialize(AUDIO_OUTPUT_RETRIEVAL, 0, NULL, 0) == 22050);
assert(event_list != NULL);
assert(translator == NULL);

const char *test = "One two three.";
assert(espeak_Synth(test, strlen(test)+1, 0, POS_CHARACTER, 0, espeakCHARS_AUTO, NULL, NULL) == EE_OK);
assert(translator != NULL);

assert(espeak_Synchronize() == EE_OK);
assert(translator != NULL);

assert(espeak_Terminate() == EE_OK);
assert(event_list == NULL);
assert(translator == NULL);
}

int
@@ -81,6 +92,7 @@ main(int argc, char **argv)
test_espeak_initialize();

test_espeak_synth();
test_espeak_synth(); // Check that this does not crash when run a second time.

return EXIT_SUCCESS;
}

Loading…
Cancel
Save