File: test_parser.cpp

package info (click to toggle)
libmusicbrainz3 3.0.1-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 848 kB
  • ctags: 977
  • sloc: cpp: 7,302; xml: 882; ansic: 455; makefile: 10
file content (76 lines) | stat: -rw-r--r-- 1,537 bytes parent folder | download | duplicates (3)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <fstream>
#include <string>
#include <iostream>
#include <cppunit/extensions/HelperMacros.h>
#include <musicbrainz3/mbxmlparser.h>
#include <musicbrainz3/metadata.h>
#include <musicbrainz3/model.h>

using namespace std;
using namespace MusicBrainz;

#include "read_file.h"

class BaseParserTest : public CppUnit::TestFixture
{
	CPPUNIT_TEST_SUITE(BaseParserTest);
	CPPUNIT_TEST(testEmptyValid);
	CPPUNIT_TEST(testEmptyInvalid);
	CPPUNIT_TEST_SUITE_END();

protected:

	void testEmptyValid()
	{
		try {
			MbXmlParser().parse(get_file_contents("../test-data/valid/artist/empty_1.xml"));
		}
		catch (ParseError) {
			CPPUNIT_FAIL("empty_1.xml");
		}
		
		try {
			MbXmlParser().parse(get_file_contents("../test-data/valid/artist/empty_2.xml"));
		}
		catch (ParseError) {
			CPPUNIT_FAIL("empty_2.xml");
		}
	}

	void testEmptyInvalid()
	{
		bool error = false;
		try { 
			MbXmlParser().parse(get_file_contents("../test-data/invalid/artist/empty_1.xml"));
		}
		catch (ParseError) { 
			error = true;
		}
		if (!error)
			CPPUNIT_FAIL("empty_1.xml");

		error = false;
		try {
			MbXmlParser().parse(get_file_contents("../test-data/invalid/artist/empty_2.xml"));
		}
		catch (ParseError) { 
			error = true;
		}
		if (!error)
			CPPUNIT_FAIL("empty_2.xml");

		/*error = false;
		try { 
			MbXmlParser().parse(get_file_contents("../test-data/invalid/artist/empty_3.xml"));
		}
		catch (ParseError) { 
			error = true;
		}
		if (!error)
			CPPUNIT_FAIL("empty_3.xml");*/
	}

};

CPPUNIT_TEST_SUITE_REGISTRATION(BaseParserTest);