diff options
author | David Robillard <d@drobilla.net> | 2012-08-14 04:22:07 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-08-14 04:22:07 +0000 |
commit | 2a429ca76b97cca197f105b665271360b74f6917 (patch) | |
tree | d25d206910bd4a84050918693816240c26d7d0ae /test/symbol_test.cpp | |
parent | 8bf87dc2367caf9d82dbda0382363cda400971dc (diff) | |
download | raul-2a429ca76b97cca197f105b665271360b74f6917.tar.gz raul-2a429ca76b97cca197f105b665271360b74f6917.tar.bz2 raul-2a429ca76b97cca197f105b665271360b74f6917.zip |
Remove glib dependency.
Make Symbol, URI, and Path simpler derivatives of std::string.
100% test coverage by line for Symbol, URI, Path, AtomicInt, and AtomicPtr.
Add Raul::Exception.
git-svn-id: http://svn.drobilla.net/lad/trunk/raul@4686 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'test/symbol_test.cpp')
-rw-r--r-- | test/symbol_test.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/test/symbol_test.cpp b/test/symbol_test.cpp new file mode 100644 index 0000000..9726001 --- /dev/null +++ b/test/symbol_test.cpp @@ -0,0 +1,77 @@ +/* + This file is part of Raul. + Copyright 2007-2012 David Robillard <http://drobilla.net> + + Raul is free software: you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation, either version 3 of the License, or any later version. + + Raul is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Raul. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <cstring> +#include <iostream> +#include <list> + +#include "raul/log.hpp" +#include "raul/Path.hpp" + +using namespace std; +using namespace Raul; + +int +main() +{ +#define CHECK(cond) \ + do { if (!(cond)) { \ + error << "Test failed: " << (cond) << endl; \ + return 1; \ + } } while (0) + + list<string> names; + names.push_back("Dry/Wet Balance"); + names.push_back("foo+1bar(baz)"); + names.push_back("ThisCRAR"); + names.push_back("NAME"); + names.push_back("thing with a bunch of spaces"); + names.push_back("thing-with-a-bunch-of-dashes"); + names.push_back("CamelCaseABC"); + names.push_back("Signal Level [dB]"); + names.push_back("Gain dB"); + names.push_back("Dry/Wet Balance"); + names.push_back("Phaser1 - Similar to CSound's phaser1 by Sean Costello"); + names.push_back(""); + + for (list<string>::iterator i = names.begin(); i != names.end(); ++i) { + CHECK(!Symbol::symbolify(*i).empty()); + } + + Symbol original("sym"); + Symbol copy(original); + CHECK(original == copy); + + bool valid = true; + try { + Symbol symbol("0startswithdigit"); + } catch (const Symbol::BadSymbol& e) { + std::cerr << "Caught exception: " << e.what() << std::endl; + valid = false; + } + CHECK(!valid); + + valid = true; + try { + Symbol symbol(std::string("invalid/symbol")); + } catch (const Symbol::BadSymbol& e) { + std::cerr << "Caught exception: " << e.what() << std::endl; + valid = false; + } + CHECK(!valid); + + return 0; +} |