/
test_file.cpp
66 lines (52 loc) · 1.65 KB
/
test_file.cpp
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
#include "settings.h"
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include "xscript/context.h"
#include "xscript/exception.h"
#include "xscript/script.h"
#include "xscript/script_factory.h"
#include "xscript/state.h"
#include "xscript/test_utils.h"
#include "xscript/xml_util.h"
#include "../file-block/file_block.h"
#include "../file-block/file_extension.h"
#ifdef HAVE_DMALLOC_H
#include <dmalloc.h>
#endif
using namespace xscript;
class FileTest : public CppUnit::TestFixture {
public:
CPPUNIT_TEST_SUITE(FileTest);
CPPUNIT_TEST_EXCEPTION(testUnknowMethod, ParseError);
CPPUNIT_TEST(testLoad);
CPPUNIT_TEST(testInclude);
CPPUNIT_TEST_SUITE_END();
public:
void testUnknowMethod();
void testLoad();
void testInclude();
};
#ifdef HAVE_FILE_BLOCK
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(FileTest, "file");
CPPUNIT_REGISTRY_ADD("file", "xscript");
#endif
void
FileTest::testUnknowMethod() {
boost::shared_ptr<Context> ctx = TestUtils::createEnv("./file-unknownMethod.xml");
}
void
FileTest::testLoad() {
boost::shared_ptr<Context> ctx = TestUtils::createEnv("./file-load.xml");
ContextStopper ctx_stopper(ctx);
XmlDocSharedHelper doc = ctx->script()->invoke(ctx);
CPPUNIT_ASSERT(NULL != doc.get());
CPPUNIT_ASSERT(XmlUtils::xpathExists(doc.get(), "//include-data"));
}
void
FileTest::testInclude() {
boost::shared_ptr<Context> ctx = TestUtils::createEnv("./file-include.xml");
ContextStopper ctx_stopper(ctx);
XmlDocSharedHelper doc = ctx->script()->invoke(ctx);
CPPUNIT_ASSERT(NULL != doc.get());
CPPUNIT_ASSERT(XmlUtils::xpathExists(doc.get(), "//include-data"));
}