1 /******************************************/
4 by Jean Pierre Cimalando, 2018.
6 This program tests parts of RtAudio related
7 to API names, the conversion from name to API
10 /******************************************/
18 std::vector<RtAudio::Api> apis;
19 RtAudio::getCompiledApi( apis );
21 // ensure the known APIs return valid names
22 std::cout << "API names by identifier:\n";
23 for ( size_t i = 0; i < apis.size() ; ++i ) {
24 const std::string &name = RtAudio::getCompiledApiName(apis[i]);
26 std::cerr << "Invalid name for API " << (int)apis[i] << "\n";
29 std::cout << "* " << (int)apis[i] << ": '" << name << "'\n";
32 // ensure unknown APIs return the empty string
34 const std::string &name = RtAudio::getCompiledApiName((RtAudio::Api)-1);
36 std::cerr << "Bad string for invalid API\n";
41 // try getting API identifier by case-insensitive name
42 std::cout << "API identifiers by name:\n";
43 for ( size_t i = 0; i < apis.size() ; ++i ) {
44 std::string name = RtAudio::getCompiledApiName(apis[i]);
45 if ( RtAudio::getCompiledApiByName(name) != apis[i] ) {
46 std::cerr << "Bad identifier for API '" << name << "'\n";
49 std::cout << "* '" << name << "': " << (int)apis[i] << "\n";
50 for ( size_t j = 0; j < name.size(); ++j )
51 name[j] = (j & 1) ? toupper(name[j]) : tolower(name[j]);
52 if ( RtAudio::getCompiledApiByName(name) != apis[i] ) {
53 std::cerr << "Bad identifier for API '" << name << "'\n";
56 std::cout << "* '" << name << "': " << (int)apis[i] << "\n";
59 // try getting an API identifier by unknown name
62 api = RtAudio::getCompiledApiByName("ALSO");
63 if ( api != RtAudio::UNSPECIFIED ) {
64 std::cerr << "Bad identifier for unknown API name\n";
67 api = RtAudio::getCompiledApiByName("");
68 if ( api != RtAudio::UNSPECIFIED ) {
69 std::cerr << "Bad identifier for unknown API name\n";