To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / Tester.h @ 42:f1e8e14e9c96
History | View | Annotate | Download (3.06 KB)
| 1 | 0:f89128a316e7 | cannam | /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
|---|---|---|---|
| 2 | |||
| 3 | /*
|
||
| 4 | Vamp Plugin Tester
|
||
| 5 | Chris Cannam, cannam@all-day-breakfast.com
|
||
| 6 | Centre for Digital Music, Queen Mary, University of London.
|
||
| 7 | 42:f1e8e14e9c96 | Chris | Copyright 2009-2014 QMUL.
|
| 8 | 0:f89128a316e7 | cannam | |
| 9 | This program loads a Vamp plugin and tests its susceptibility to a
|
||
| 10 | number of common pitfalls, including handling of extremes of input
|
||
| 11 | data. If you can think of any additional useful tests that are
|
||
| 12 | easily added, please send them to me.
|
||
| 13 | |||
| 14 | Permission is hereby granted, free of charge, to any person
|
||
| 15 | obtaining a copy of this software and associated documentation
|
||
| 16 | files (the "Software"), to deal in the Software without
|
||
| 17 | restriction, including without limitation the rights to use, copy,
|
||
| 18 | modify, merge, publish, distribute, sublicense, and/or sell copies
|
||
| 19 | of the Software, and to permit persons to whom the Software is
|
||
| 20 | furnished to do so, subject to the following conditions:
|
||
| 21 | |||
| 22 | The above copyright notice and this permission notice shall be
|
||
| 23 | included in all copies or substantial portions of the Software.
|
||
| 24 | |||
| 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||
| 26 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||
| 27 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||
| 28 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
|
||
| 29 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||
| 30 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||
| 31 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||
| 32 | |||
| 33 | Except as contained in this notice, the names of the Centre for
|
||
| 34 | Digital Music; Queen Mary, University of London; and Chris Cannam
|
||
| 35 | shall not be used in advertising or otherwise to promote the sale,
|
||
| 36 | use or other dealings in this Software without prior written
|
||
| 37 | authorization.
|
||
| 38 | */
|
||
| 39 | |||
| 40 | #ifndef _TESTER_H_
|
||
| 41 | #define _TESTER_H_
|
||
| 42 | |||
| 43 | #include <string> |
||
| 44 | |||
| 45 | #include "Test.h" |
||
| 46 | |||
| 47 | class Tester |
||
| 48 | {
|
||
| 49 | public:
|
||
| 50 | 39:07144cdcbedf | Chris | Tester(std::string pluginKey, Test::Options, std::string singleTestId = "");
|
| 51 | 0:f89128a316e7 | cannam | ~Tester(); |
| 52 | |||
| 53 | 4:d8724c5a6d83 | cannam | bool test(int ¬es, int &warnings, int &errors); |
| 54 | 0:f89128a316e7 | cannam | |
| 55 | 40:649f32c7eb41 | Chris | static void listTests(); |
| 56 | |||
| 57 | 0:f89128a316e7 | cannam | class Registrar {
|
| 58 | public:
|
||
| 59 | 39:07144cdcbedf | Chris | Registrar(std::string id, std::string name) {
|
| 60 | Tester::registerTest(id, name, this); |
||
| 61 | } |
||
| 62 | 15:dde5eb0f1826 | cannam | virtual ~Registrar() { }
|
| 63 | 0:f89128a316e7 | cannam | virtual Test *makeTest() = 0;
|
| 64 | }; |
||
| 65 | |||
| 66 | template <typename T> |
||
| 67 | class TestRegistrar : Registrar {
|
||
| 68 | public:
|
||
| 69 | 39:07144cdcbedf | Chris | TestRegistrar(std::string id, std::string name) : |
| 70 | Registrar(id, name) { }
|
||
| 71 | 0:f89128a316e7 | cannam | virtual Test *makeTest() { return new T(); }
|
| 72 | }; |
||
| 73 | |||
| 74 | 39:07144cdcbedf | Chris | static void registerTest(std::string id, std::string name, Registrar *r) { |
| 75 | nameIndex()[id] = name; |
||
| 76 | registry()[id] = r; |
||
| 77 | 0:f89128a316e7 | cannam | } |
| 78 | |||
| 79 | protected:
|
||
| 80 | std::string m_key; |
||
| 81 | 8:3019cb6b538d | cannam | Test::Options m_options; |
| 82 | 39:07144cdcbedf | Chris | std::string m_singleTest; |
| 83 | typedef std::map<std::string, std::string> NameIndex;
|
||
| 84 | 0:f89128a316e7 | cannam | typedef std::map<std::string, Registrar *> Registry;
|
| 85 | 39:07144cdcbedf | Chris | static NameIndex &nameIndex();
|
| 86 | 0:f89128a316e7 | cannam | static Registry ®istry();
|
| 87 | 39:07144cdcbedf | Chris | |
| 88 | bool performTest(std::string id, int ¬es, int &warnings, int &errors); |
||
| 89 | 0:f89128a316e7 | cannam | }; |
| 90 | |||
| 91 | #endif
|