summaryrefslogtreecommitdiff
path: root/tests/test_parser.cpp
blob: 68b2fb046d83ea6ef4bcaecf4cf9728875a1071d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 * test_parser.cpp
 *
 *  Created on: 16.09.2012
 *      Author: savop
 */

#include "../include/parser.h"
#include <iostream>

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;
}