From a24cf8ab2364600681fa7fb001a4c4cbc706a31a Mon Sep 17 00:00:00 2001 From: methodus Date: Sun, 16 Sep 2012 09:10:44 +0200 Subject: =?UTF-8?q?Tests=20f=C3=BCr=20Parser=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Makefile | 3 +++ tests/test_parser | Bin 0 -> 841785 bytes tests/test_parser.cpp | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 tests/Makefile create mode 100755 tests/test_parser create mode 100644 tests/test_parser.cpp diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..41b056a --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,3 @@ + +tests: test_parser.cpp ../common/parser.cpp + g++ -o test_parser test_parser.cpp ../common/parser.cpp -I../include -I/usr/include -I/usr/local/include \ No newline at end of file diff --git a/tests/test_parser b/tests/test_parser new file mode 100755 index 0000000..0347f1a Binary files /dev/null and b/tests/test_parser differ diff --git a/tests/test_parser.cpp b/tests/test_parser.cpp new file mode 100644 index 0000000..68b2fb0 --- /dev/null +++ b/tests/test_parser.cpp @@ -0,0 +1,36 @@ +/* + * test_parser.cpp + * + * Created on: 16.09.2012 + * Author: savop + */ + +#include "../include/parser.h" +#include + +void checkSearch(string t, string e) { + + string r = upnp::cSearch::parse(t); + + cout << "Suche: \"" << t << "\"" << endl; + cout << "Erwartet: \"" << e << "\"" << endl; + cout << "Ergebnis: \"" << r << "\"" << endl; + cout << "-------> " << (e.compare(r) ? "FEHLGESCHLAGEN!" : "ERFOLGREICH!") << endl << endl; + +} + +int main(){ + checkSearch("upnp:class = \"object.item.imageItem\" and ( dc:date >= \"2001-10-01\" and dc:date <= \"2001-10-31\" )", + "class == 'object.item.imageItem' AND ( date >= '2001-10-01' AND date <= '2001-10-31' ) "); + + checkSearch("@id = \"20\"", + string()); + + checkSearch("dc:title contains \"Christmas\"", + "title LIKE '%Christmas%' "); + + checkSearch("upnp:class derivedfrom \"object.container.album\"", + "class LIKE '%object.container.album%' "); + + return 0; +} -- cgit v1.2.3