summaryrefslogtreecommitdiff
path: root/tests/apinames.cpp
diff options
context:
space:
mode:
authorJP Cimalando <jpcima@users.noreply.github.com>2018-08-08 00:36:22 +0200
committerJP Cimalando <jpcima@users.noreply.github.com>2018-08-08 00:43:31 +0200
commit021928773bfbf9b25505677451ee197b1fe006b6 (patch)
treed926b77d97bfc0fe670f527e43b8d5046eadfcb0 /tests/apinames.cpp
parentee6fd4b4609a1c05a3f4ded4c8022b5ba84d7afd (diff)
Use short lower-case names as API identifiers
Diffstat (limited to 'tests/apinames.cpp')
-rw-r--r--tests/apinames.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/tests/apinames.cpp b/tests/apinames.cpp
index b915ad0..db7a258 100644
--- a/tests/apinames.cpp
+++ b/tests/apinames.cpp
@@ -10,8 +10,8 @@
/******************************************/
#include "RtAudio.h"
-#include <cstdlib>
#include <cctype>
+#include <cstdlib>
#include <iostream>
int main() {
@@ -26,7 +26,12 @@ int main() {
std::cerr << "Invalid name for API " << (int)apis[i] << "\n";
exit(1);
}
- std::cout << "* " << (int)apis[i] << ": '" << name << "'\n";
+ const std::string &displayName = RtAudio::getCompiledApiDisplayName(apis[i]);
+ if (displayName.empty()) {
+ std::cerr << "Invalid display name for API " << (int)apis[i] << "\n";
+ exit(1);
+ }
+ std::cout << "* " << (int)apis[i] << " '" << name << "': '" << displayName << "'\n";
}
// ensure unknown APIs return the empty string
@@ -36,9 +41,14 @@ int main() {
std::cerr << "Bad string for invalid API\n";
exit(1);
}
+ const std::string &displayName = RtAudio::getCompiledApiDisplayName((RtAudio::Api)-1);
+ if (!displayName.empty()) {
+ std::cerr << "Bad display string for invalid API\n";
+ exit(1);
+ }
}
- // try getting API identifier by case-insensitive name
+ // try getting API identifier by name
std::cout << "API identifiers by name:\n";
for ( size_t i = 0; i < apis.size() ; ++i ) {
std::string name = RtAudio::getCompiledApiName(apis[i]);
@@ -47,23 +57,19 @@ int main() {
exit( 1 );
}
std::cout << "* '" << name << "': " << (int)apis[i] << "\n";
+
for ( size_t j = 0; j < name.size(); ++j )
name[j] = (j & 1) ? toupper(name[j]) : tolower(name[j]);
- if ( RtAudio::getCompiledApiByName(name) != apis[i] ) {
- std::cerr << "Bad identifier for API '" << name << "'\n";
+ RtAudio::Api api = RtAudio::getCompiledApiByName(name);
+ if ( api != RtAudio::UNSPECIFIED ) {
+ std::cerr << "Identifier " << (int)api << " for invalid API '" << name << "'\n";
exit( 1 );
}
- std::cout << "* '" << name << "': " << (int)apis[i] << "\n";
}
// try getting an API identifier by unknown name
{
RtAudio::Api api;
- api = RtAudio::getCompiledApiByName("ALSO");
- if ( api != RtAudio::UNSPECIFIED ) {
- std::cerr << "Bad identifier for unknown API name\n";
- exit( 1 );
- }
api = RtAudio::getCompiledApiByName("");
if ( api != RtAudio::UNSPECIFIED ) {
std::cerr << "Bad identifier for unknown API name\n";