diff --git a/include/XPath/impl/xpath_expression.hpp b/include/XPath/impl/xpath_expression.hpp index fc0a4f08..7210f5a3 100644 --- a/include/XPath/impl/xpath_expression.hpp +++ b/include/XPath/impl/xpath_expression.hpp @@ -50,27 +50,119 @@ private: XPathExpression_impl& operator=(const XPathExpression_impl&); }; // class XPathExpression_impl +template class XPathExpressionPtr; + template > -class XPathExpressionPtr +class XPathExpression { public: - XPathExpressionPtr() : ptr_() { } - explicit XPathExpressionPtr(XPathExpression_impl* xp) : ptr_(xp) { } - XPathExpressionPtr(const XPathExpressionPtr& rhs) : ptr_(rhs.ptr_) { } - XPathExpressionPtr& operator=(const XPathExpressionPtr& rhs) + XPathExpression() : ptr_() { } + explicit XPathExpression(XPathExpression_impl* xp) : ptr_(xp) { } + XPathExpression(const XPathExpression& rhs) : ptr_(rhs.ptr_) { } + XPathExpression& operator=(const XPathExpression& rhs) { ptr_ = rhs.ptr_; return *this; } // operator= const XPathExpression_impl* get() const { return ptr_.get(); } - const XPathExpression_impl* operator->() const { return ptr_.get(); } operator bool() const { return ptr_.get(); } + XPathValue evaluate(const DOM::Node& context) const + { + return ptr_->evaluate(context); + } // evaluate + + bool evaluateAsBool(const DOM::Node& context) const + { + return ptr_->evaluateAsBool(context); + } // evaluateAsBool + + double evaluateAsNumber(const DOM::Node& context) const + { + return ptr_->evaluateAsNumber(context); + } // evaluateAsNumber + + string_type evaluateAsString(const DOM::Node& context) const + { + return ptr_->evaluateAsString(context); + } // evaluateAsString + + NodeSet evaluateAsNodeSet(const DOM::Node& context) const + { + return ptr_->evaluate(context).asNodeSet(); + } // evaluateAsNodeSet + + + XPathValue evaluate(const DOM::Node& context, + const ExecutionContext& executionContext) const + { + return ptr_->evaluate(context, executionContext); + } // evaluate + + bool evaluateAsBool(const DOM::Node& context, + const ExecutionContext& executionContext) const + { + return ptr_->evaluateAsBool(context, executionContext); + } // evaluateAsBool + + double evaluateAsNumber(const DOM::Node& context, + const ExecutionContext& executionContext) const + { + return ptr_->evaluateAsNumber(context, executionContext); + } // evaluateAsNumber + + string_type evaluateAsString(const DOM::Node& context, + const ExecutionContext& executionContext) const + { + return ptr_->evaluateAsString(context, executionContext); + } // evaluateAsString + + NodeSet evaluateAsNodeSet(const DOM::Node& context, + const ExecutionContext& executionContext) const + { + return ptr_->evaluate(context, executionContext).asNodeSet(); + } // evaluateAsNodeSet + private: typedef boost::shared_ptr > ExpressionPtr; ExpressionPtr ptr_; + + explicit XPathExpression(ExpressionPtr ptr) : ptr_(ptr) { } + + friend class XPathExpressionPtr; +}; // class XPathExpression + +template > +class XPathExpressionPtr +{ +public: + explicit XPathExpressionPtr() : ptr_() { } + explicit XPathExpressionPtr(const XPathExpression_impl* v) : ptr_(v) { } + XPathExpressionPtr(const XPathExpression& rhs) : ptr_(rhs.ptr_) { } + XPathExpressionPtr(const XPathExpressionPtr& rhs) : ptr_(rhs.ptr_) { } + XPathExpressionPtr& operator=(const XPathExpression& rhs) + { + ptr_ = rhs.ptr_; + return *this; + } // operator= + XPathExpressionPtr& operator=(const XPathExpressionPtr& rhs) + { + ptr_ = rhs.ptr_; + return *this; + } // operator= + + const XPathExpression_impl* operator->() const { return ptr_.get(); } + + operator bool() const { return ptr_.get(); } + operator XPathExpression() const { return XPathExpression(ptr_); } + +private: + bool operator==(const XPathExpressionPtr&) const; + + typedef boost::shared_ptr > ExpressionPtr; + ExpressionPtr ptr_; }; // class XPathExpressionPtr namespace impl diff --git a/include/XPath/impl/xpath_function.hpp b/include/XPath/impl/xpath_function.hpp index 11f1b849..5dd46d9f 100644 --- a/include/XPath/impl/xpath_function.hpp +++ b/include/XPath/impl/xpath_function.hpp @@ -18,7 +18,7 @@ template >& args) : + XPathFunction(int minArgs, int maxArgs, const std::vector >& args) : args_(args) { if(((minArgs != -1) && (static_cast(args.size()) < minArgs)) || @@ -39,39 +39,39 @@ protected: const DOM::Node& context, const ExecutionContext& executionContext) const { - return args_[index]->evaluate(context, executionContext); + return args_[index].evaluate(context, executionContext); } // argAsBool bool argAsBool(size_t index, const DOM::Node& context, const ExecutionContext& executionContext) const { - return args_[index]->evaluate(context, executionContext).asBool(); + return args_[index].evaluate(context, executionContext).asBool(); } // argAsBool double argAsNumber(size_t index, const DOM::Node& context, const ExecutionContext& executionContext) const { - return args_[index]->evaluate(context, executionContext).asNumber(); + return args_[index].evaluate(context, executionContext).asNumber(); } // argAsNumber string_type argAsString(size_t index, const DOM::Node& context, const ExecutionContext& executionContext) const { - return args_[index]->evaluate(context, executionContext).asString(); + return args_[index].evaluate(context, executionContext).asString(); } // argAsString NodeSet argAsNodeSet(size_t index, const DOM::Node& context, const ExecutionContext& executionContext) const { - return args_[index]->evaluate(context, executionContext).asNodeSet(); + return args_[index].evaluate(context, executionContext).asNodeSet(); } // argAsNodeSet private: - const std::vector > args_; + const std::vector > args_; }; // class XPathFunction namespace impl @@ -83,7 +83,7 @@ template class LastFn : public XPathFunction { public: - LastFn(const std::vector >& args) : XPathFunction(0, 0, args) { } + LastFn(const std::vector >& args) : XPathFunction(0, 0, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -97,7 +97,7 @@ template class PositionFn : public XPathFunction { public: - PositionFn(const std::vector >& args) : XPathFunction(0, 0, args) { } + PositionFn(const std::vector >& args) : XPathFunction(0, 0, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -112,7 +112,7 @@ class CountFn : public XPathFunction { typedef XPathFunction baseT; public: - CountFn(const std::vector >& args) : XPathFunction(1, 1, args) { } + CountFn(const std::vector >& args) : XPathFunction(1, 1, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -128,7 +128,7 @@ class LocalNameFn : public XPathFunction { typedef XPathFunction baseT; public: - LocalNameFn(const std::vector >& args) : XPathFunction(0, 1, args) { } + LocalNameFn(const std::vector >& args) : XPathFunction(0, 1, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -163,7 +163,7 @@ class NamespaceURIFn : public XPathFunction { typedef XPathFunction baseT; public: - NamespaceURIFn(const std::vector >& args) : XPathFunction(0, 1, args) { } + NamespaceURIFn(const std::vector >& args) : XPathFunction(0, 1, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -197,7 +197,7 @@ class NameFn : public XPathFunction { typedef XPathFunction baseT; public: - NameFn(const std::vector >& args) : XPathFunction(0, 1, args) { } + NameFn(const std::vector >& args) : XPathFunction(0, 1, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -236,7 +236,7 @@ class StringFn : public XPathFunction { typedef XPathFunction baseT; public: - StringFn(const std::vector >& args) : XPathFunction(0, 1, args) { } + StringFn(const std::vector >& args) : XPathFunction(0, 1, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -251,7 +251,7 @@ class ConcatFn : public XPathFunction { typedef XPathFunction baseT; public: - ConcatFn(const std::vector >& args) : XPathFunction(2, -1, args) { } + ConcatFn(const std::vector >& args) : XPathFunction(2, -1, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -269,7 +269,7 @@ class StartsWithFn : public XPathFunction { typedef XPathFunction baseT; public: - StartsWithFn(const std::vector >& args) : XPathFunction(2, 2, args) { } + StartsWithFn(const std::vector >& args) : XPathFunction(2, 2, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -297,7 +297,7 @@ class ContainsFn : public XPathFunction { typedef XPathFunction baseT; public: - ContainsFn(const std::vector >& args) : XPathFunction(2, 2, args) { } + ContainsFn(const std::vector >& args) : XPathFunction(2, 2, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -313,7 +313,7 @@ class SubstringBeforeFn : public XPathFunction { typedef XPathFunction baseT; public: - SubstringBeforeFn(const std::vector >& args) : XPathFunction(2, 2, args) { } + SubstringBeforeFn(const std::vector >& args) : XPathFunction(2, 2, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -334,7 +334,7 @@ class SubstringAfterFn : public XPathFunction { typedef XPathFunction baseT; public: - SubstringAfterFn(const std::vector >& args) : XPathFunction(2, 2, args) { } + SubstringAfterFn(const std::vector >& args) : XPathFunction(2, 2, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -356,7 +356,7 @@ class SubstringFn : public XPathFunction { typedef XPathFunction baseT; public: - SubstringFn(const std::vector >& args) : XPathFunction(2, 3, args) { } + SubstringFn(const std::vector >& args) : XPathFunction(2, 3, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -386,7 +386,7 @@ class StringLengthFn : public XPathFunction { typedef XPathFunction baseT; public: - StringLengthFn(const std::vector >& args) : XPathFunction(0, 1, args) { } + StringLengthFn(const std::vector >& args) : XPathFunction(0, 1, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -402,7 +402,7 @@ class NormalizeSpaceFn : public XPathFunction { typedef XPathFunction baseT; public: - NormalizeSpaceFn(const std::vector >& args) : XPathFunction(0, 1, args) { } + NormalizeSpaceFn(const std::vector >& args) : XPathFunction(0, 1, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -419,7 +419,7 @@ class TranslateFn : public XPathFunction { typedef XPathFunction baseT; public: - TranslateFn(const std::vector >& args) : XPathFunction(3, 3, args) { } + TranslateFn(const std::vector >& args) : XPathFunction(3, 3, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -453,7 +453,7 @@ class BooleanFn : public XPathFunction { typedef XPathFunction baseT; public: - BooleanFn(const std::vector >& args) : XPathFunction(1, 1, args) { } + BooleanFn(const std::vector >& args) : XPathFunction(1, 1, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -468,7 +468,7 @@ class NotFn : public XPathFunction { typedef XPathFunction baseT; public: - NotFn(const std::vector >& args) : XPathFunction(1, 1, args) { } + NotFn(const std::vector >& args) : XPathFunction(1, 1, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -482,7 +482,7 @@ template class TrueFn : public XPathFunction { public: - TrueFn(const std::vector >& args) : XPathFunction(0, 0, args) { } + TrueFn(const std::vector >& args) : XPathFunction(0, 0, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -496,7 +496,7 @@ template class FalseFn : public XPathFunction { public: - FalseFn(const std::vector >& args) : XPathFunction(0, 0, args) { } + FalseFn(const std::vector >& args) : XPathFunction(0, 0, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -516,7 +516,7 @@ class NumberFn : public XPathFunction { typedef XPathFunction baseT; public: - NumberFn(const std::vector >& args) : XPathFunction(0, 1, args) { } + NumberFn(const std::vector >& args) : XPathFunction(0, 1, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -533,7 +533,7 @@ class SumFn : public XPathFunction { typedef XPathFunction baseT; public: - SumFn(const std::vector >& args) : XPathFunction(1, 1, args) { } + SumFn(const std::vector >& args) : XPathFunction(1, 1, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -552,7 +552,7 @@ class FloorFn : public XPathFunction { typedef XPathFunction baseT; public: - FloorFn(const std::vector >& args) : XPathFunction(1, 1, args) { } + FloorFn(const std::vector >& args) : XPathFunction(1, 1, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -567,7 +567,7 @@ class CeilingFn : public XPathFunction { typedef XPathFunction baseT; public: - CeilingFn(const std::vector >& args) : XPathFunction(1, 1, args) { } + CeilingFn(const std::vector >& args) : XPathFunction(1, 1, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const @@ -582,7 +582,7 @@ class RoundFn : public XPathFunction { typedef XPathFunction baseT; public: - RoundFn(const std::vector >& args) : XPathFunction(1, 1, args) { } + RoundFn(const std::vector >& args) : XPathFunction(1, 1, args) { } virtual XPathValue_impl* evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const diff --git a/include/XPath/impl/xpath_function_holder.hpp b/include/XPath/impl/xpath_function_holder.hpp index 0e799549..317daf5b 100644 --- a/include/XPath/impl/xpath_function_holder.hpp +++ b/include/XPath/impl/xpath_function_holder.hpp @@ -13,7 +13,7 @@ namespace impl { template -XPathFunction* CreateFn(const std::vector >& argExprs) { return new function_type(argExprs); } +XPathFunction* CreateFn(const std::vector >& argExprs) { return new function_type(argExprs); } template class FunctionHolder : public XPathExpression_impl @@ -37,7 +37,7 @@ public: static FunctionHolder* createFunction(const string_type& namespace_uri, const string_type& name, - const std::vector >& argExprs, + const std::vector >& argExprs, const CompilationContext& context) { if(string_adaptor::empty(namespace_uri)) @@ -66,7 +66,7 @@ public: private: XPathFunction* func_; - typedef XPathFunction* (*CreateFnPtr)(const std::vector >& argExprs); + typedef XPathFunction* (*CreateFnPtr)(const std::vector >& argExprs); struct NamedFunction { const char* name; CreateFnPtr creator; }; diff --git a/include/XPath/impl/xpath_function_resolver.hpp b/include/XPath/impl/xpath_function_resolver.hpp index 0053e4dd..e1c0688c 100644 --- a/include/XPath/impl/xpath_function_resolver.hpp +++ b/include/XPath/impl/xpath_function_resolver.hpp @@ -7,7 +7,7 @@ namespace XPath { template class XPathFunction; -template class XPathExpressionPtr; +template class XPathExpression; class UndefinedFunctionException : public std::runtime_error { @@ -25,7 +25,7 @@ public: virtual XPathFunction* resolveFunction(const string_type& namespace_uri, const string_type& name, - const std::vector >& argExprs) const = 0; + const std::vector >& argExprs) const = 0; }; // class FunctionResolver template @@ -45,7 +45,7 @@ public: virtual XPathFunction* resolveFunction(const string_type& namespace_uri, const string_type& name, - const std::vector >& argExprs) const + const std::vector >& argExprs) const { string_type error; if(!string_adaptor::empty(namespace_uri)) diff --git a/include/XPath/impl/xpath_match.hpp b/include/XPath/impl/xpath_match.hpp index 81e127e6..f42b877a 100644 --- a/include/XPath/impl/xpath_match.hpp +++ b/include/XPath/impl/xpath_match.hpp @@ -25,13 +25,13 @@ public: bool evaluate(const DOM::Node& context, const ExecutionContext& executionContext) const { - return match_->evaluateAsBool(context, executionContext); + return match_.evaluateAsBool(context, executionContext); } // evaluate void override_priority(double p) { priority_ = p; } private: - XPathExpressionPtr match_; + XPathExpression match_; double priority_; }; // MatchExpr diff --git a/include/XPath/impl/xpath_parser.hpp b/include/XPath/impl/xpath_parser.hpp index b5064cdb..855101c6 100644 --- a/include/XPath/impl/xpath_parser.hpp +++ b/include/XPath/impl/xpath_parser.hpp @@ -64,24 +64,24 @@ public: { } // ~XPath - XPathExpressionPtr compile(const string_type& xpath) const + XPathExpression compile(const string_type& xpath) const { return do_compile(xpath, &XPath::parse_xpath, expression_factory()); } // compile - XPathExpressionPtr compile_expr(const string_type& xpath) const + XPathExpression compile_expr(const string_type& xpath) const { return do_compile(xpath, &XPath::parse_xpath_expr, expression_factory()); } // compile_expr - XPathExpressionPtr compile_attribute_value_template(const string_type& xpath) const + XPathExpression compile_attribute_value_template(const string_type& xpath) const { return do_compile(xpath, &XPath::parse_xpath_attribute_value_template, attribute_value_factory()); } // compile_attribute_value_template std::vector > compile_match(const string_type& xpath) const { - XPathExpressionPtr wrapper = do_compile(xpath, &XPath::parse_xpath_match, match_factory()); + XPathExpression wrapper = do_compile(xpath, &XPath::parse_xpath_match, match_factory()); return (static_cast*>(wrapper.get()))->matches(); } // compile_match @@ -89,14 +89,14 @@ public: { ExecutionContext executionContext; executionContext.setVariableResolver(getVariableResolver()); - return compile(xpath)->evaluate(context, executionContext); + return compile(xpath).evaluate(context, executionContext); } // evaluate XPathValue evaluate_expr(const string_type& xpath, const DOM::Node& context) const { ExecutionContext executionContext; executionContext.setVariableResolver(getVariableResolver()); - return compile_expr(xpath)->evaluate(context, executionContext); + return compile_expr(xpath).evaluate(context, executionContext); } // evaluate_expr void setNamespaceContext(const NamespaceContext& namespaceContext) { namespaceContext_.set(namespaceContext); } @@ -120,7 +120,7 @@ private: impl::CompilationContext& context); typedef typename impl::types::tree_info_t(XPath::*parserFn)(const string_type& str) const; - XPathExpressionPtr do_compile(const string_type& xpath, + XPathExpression do_compile(const string_type& xpath, parserFn parser, const std::map& factory) const { @@ -132,7 +132,7 @@ private: impl::CompilationContext context(*this, getNamespaceContext(), getFunctionResolver()); //XPath::dump(ast.trees.begin(), 0); - return XPathExpressionPtr(compile_with_factory(ast.trees.begin(), + return XPathExpression(compile_with_factory(ast.trees.begin(), ast.trees.end(), context, factory)); @@ -573,10 +573,10 @@ XPathExpression_impl* XPath(c); - std::vector > args; + std::vector > args; while(impl::getNodeId(c) != impl::RightBracket_id) { - XPathExpressionPtr arg(XPath::compile_expression(c++, i->children.end(), context)); + XPathExpression arg(XPath::compile_expression(c++, i->children.end(), context)); args.push_back(arg); impl::skipWhitespace(c); @@ -962,10 +962,10 @@ impl::StepList XPath:: template XPathExpression_impl* XPath::createAttributeValue(typename impl::types::node_iter_t const& i, typename impl::types::node_iter_t const& ie, impl::CompilationContext& context) { - std::vector > args; + std::vector > args; for(typename impl::types::node_iter_t a = i->children.begin(), e = i->children.end(); a != e; ++a) { - XPathExpressionPtr arg(XPath::compile_attribute_value(a, e, context)); + XPathExpression arg(XPath::compile_attribute_value(a, e, context)); args.push_back(arg); } // while ... // maybe trailing whitespace ... diff --git a/include/XSLT/impl/xslt_functions.hpp b/include/XSLT/impl/xslt_functions.hpp index 67a0e413..8d0d2f98 100644 --- a/include/XSLT/impl/xslt_functions.hpp +++ b/include/XSLT/impl/xslt_functions.hpp @@ -15,7 +15,7 @@ class CurrentFunction : public Arabica::XPath::XPathFunction typedef Arabica::XPath::XPathFunction baseT; public: - CurrentFunction(const std::vector >& args) : + CurrentFunction(const std::vector >& args) : Arabica::XPath::XPathFunction(0, 0, args) { } virtual Arabica::XPath::XPathValue_impl* evaluate(const DOM::Node& context, @@ -34,7 +34,7 @@ class DocumentFunction : public Arabica::XPath::XPathFunction public: DocumentFunction(const std::string& currentBase, - const std::vector >& args) : + const std::vector >& args) : Arabica::XPath::XPathFunction(1, 2, args), baseURI_(currentBase) { } @@ -81,7 +81,7 @@ class SystemPropertyFunction : public Arabica::XPath::XPathFunction typedef Arabica::XPath::XPathFunction baseT; public: - SystemPropertyFunction (const std::vector >& args) : + SystemPropertyFunction (const std::vector >& args) : Arabica::XPath::XPathFunction(1, 1, args) { } virtual Arabica::XPath::XPathValue_impl* evaluate(const DOM::Node& context, diff --git a/include/XSLT/impl/xslt_stylesheet_compiler.hpp b/include/XSLT/impl/xslt_stylesheet_compiler.hpp index 8ea864e7..2430109f 100755 --- a/include/XSLT/impl/xslt_stylesheet_compiler.hpp +++ b/include/XSLT/impl/xslt_stylesheet_compiler.hpp @@ -199,7 +199,7 @@ private: virtual Arabica::XPath::XPathFunction* resolveFunction( const std::string& namespace_uri, const std::string& name, - const std::vector >& argExprs) const + const std::vector >& argExprs) const { if(!namespace_uri.empty()) return 0; diff --git a/tests/XPath/arithmetic_test.hpp b/tests/XPath/arithmetic_test.hpp index 9744e13f..857d5269 100644 --- a/tests/XPath/arithmetic_test.hpp +++ b/tests/XPath/arithmetic_test.hpp @@ -25,10 +25,10 @@ public: XPathExpression_impl* p1 = new NumericValue(1); XPathExpression_impl* p2 = new NumericValue(2); - XPathExpressionPtr add(new impl::PlusOperator(p1, p2)); + XPathExpression add(new impl::PlusOperator(p1, p2)); - add->evaluate(dummy_); - assertEquals(3.0, add->evaluateAsNumber(dummy_), 0.0); + add.evaluate(dummy_); + assertEquals(3.0, add.evaluateAsNumber(dummy_), 0.0); } // test1 void test2() @@ -37,9 +37,9 @@ public: XPathExpression_impl* p1 = new NumericValue(1); XPathExpression_impl* p2 = new NumericValue(2); - XPathExpressionPtr minus(new impl::MinusOperator(p1, p2)); + XPathExpression minus(new impl::MinusOperator(p1, p2)); - assertEquals(-1.0, minus->evaluateAsNumber(dummy_), 0.0); + assertEquals(-1.0, minus.evaluateAsNumber(dummy_), 0.0); } // test2 void test3() @@ -48,9 +48,9 @@ public: XPathExpression_impl* p1 = new NumericValue(3); XPathExpression_impl* p2 = new NumericValue(2); - XPathExpressionPtr mult(new impl::MultiplyOperator(p1, p2)); + XPathExpression mult(new impl::MultiplyOperator(p1, p2)); - assertEquals(6, mult->evaluateAsNumber(dummy_), 0.0); + assertEquals(6, mult.evaluateAsNumber(dummy_), 0.0); } // test3 void test4() @@ -58,10 +58,10 @@ public: using namespace Arabica::XPath; XPathExpression_impl* mult = new impl::MultiplyOperator(new NumericValue(4), new NumericValue(2)); - XPathExpressionPtr minus(new impl::MinusOperator(mult, new NumericValue(2))); + XPathExpression minus(new impl::MinusOperator(mult, new NumericValue(2))); assertEquals(8, mult->evaluateAsNumber(dummy_), 0.0); - assertEquals(6, minus->evaluateAsNumber(dummy_), 0.0); + assertEquals(6, minus.evaluateAsNumber(dummy_), 0.0); } // test4 void test5() @@ -70,9 +70,9 @@ public: XPathExpression_impl* p1 = new NumericValue(12); XPathExpression_impl* p2 = new NumericValue(2); - XPathExpressionPtr div(new impl::DivideOperator(p1, p2)); + XPathExpression div(new impl::DivideOperator(p1, p2)); - assertEquals(6, div->evaluateAsNumber(dummy_), 0.0); + assertEquals(6, div.evaluateAsNumber(dummy_), 0.0); } // test5 void test6() @@ -81,9 +81,9 @@ public: XPathExpression_impl* p1 = new NumericValue(12); XPathExpression_impl* p2 = new NumericValue(2); - XPathExpressionPtr mod(new impl::ModOperator(p1, p2)); + XPathExpression mod(new impl::ModOperator(p1, p2)); - assertEquals(0, mod->evaluateAsNumber(dummy_), 0.0); + assertEquals(0, mod.evaluateAsNumber(dummy_), 0.0); } // test6 void test7() @@ -92,9 +92,9 @@ public: XPathExpression_impl* p1 = new NumericValue(11); XPathExpression_impl* p2 = new NumericValue(2); - XPathExpressionPtr div(new impl::DivideOperator(p1, p2)); + XPathExpression div(new impl::DivideOperator(p1, p2)); - assertEquals(5.5, div->evaluateAsNumber(dummy_), 0.0); + assertEquals(5.5, div.evaluateAsNumber(dummy_), 0.0); } // test7 void test8() @@ -103,9 +103,9 @@ public: XPathExpression_impl* p1 = new NumericValue(11); XPathExpression_impl* p2 = new NumericValue(4); - XPathExpressionPtr mod(new impl::ModOperator(p1, p2)); + XPathExpression mod(new impl::ModOperator(p1, p2)); - assertEquals(3, mod->evaluateAsNumber(dummy_), 0.0); + assertEquals(3, mod.evaluateAsNumber(dummy_), 0.0); } // test8 void test9() @@ -114,9 +114,9 @@ public: XPathExpression_impl* p1 = new NumericValue(5); XPathExpression_impl* p2 = new NumericValue(2); - XPathExpressionPtr mod(new impl::ModOperator(p1, p2)); + XPathExpression mod(new impl::ModOperator(p1, p2)); - assertEquals(1.0, mod->evaluateAsNumber(dummy_), 0.0); + assertEquals(1.0, mod.evaluateAsNumber(dummy_), 0.0); } // test9 void test10() @@ -125,9 +125,9 @@ public: XPathExpression_impl* p1 = new NumericValue(5); XPathExpression_impl* p2 = new NumericValue(-2); - XPathExpressionPtr mod(new impl::ModOperator(p1, p2)); + XPathExpression mod(new impl::ModOperator(p1, p2)); - assertEquals(1.00, mod->evaluateAsNumber(dummy_), 0.0); + assertEquals(1.00, mod.evaluateAsNumber(dummy_), 0.0); } // test10 void test11() @@ -136,9 +136,9 @@ public: XPathExpression_impl* p1 = new NumericValue(-5); XPathExpression_impl* p2 = new NumericValue(2); - XPathExpressionPtr mod(new impl::ModOperator(p1, p2)); + XPathExpression mod(new impl::ModOperator(p1, p2)); - assertEquals(-1.0, mod->evaluateAsNumber(dummy_), 0.0); + assertEquals(-1.0, mod.evaluateAsNumber(dummy_), 0.0); } // test11 void test12() @@ -147,27 +147,27 @@ public: XPathExpression_impl* p1 = new NumericValue(-5); XPathExpression_impl* p2 = new NumericValue(-2); - XPathExpressionPtr mod(new impl::ModOperator(p1, p2)); + XPathExpression mod(new impl::ModOperator(p1, p2)); - assertEquals(-1.0, mod->evaluateAsNumber(dummy_), 0.0); + assertEquals(-1.0, mod.evaluateAsNumber(dummy_), 0.0); } // test12 void test13() { using namespace Arabica::XPath; XPathExpression_impl* p1 = new NumericValue(5); - XPathExpressionPtr p2(new impl::UnaryNegative(p1)); + XPathExpression p2(new impl::UnaryNegative(p1)); - assertEquals(-5.0, p2->evaluateAsNumber(dummy_), 0.0); + assertEquals(-5.0, p2.evaluateAsNumber(dummy_), 0.0); } // test13 void test14() { using namespace Arabica::XPath; XPathExpression_impl* p1 = new NumericValue(-5); - XPathExpressionPtr p2(new impl::UnaryNegative(p1)); + XPathExpression p2(new impl::UnaryNegative(p1)); - assertEquals(5.0, p2->evaluateAsNumber(dummy_), 0.0); + assertEquals(5.0, p2.evaluateAsNumber(dummy_), 0.0); } // test14 private: diff --git a/tests/XPath/attr_value_test.hpp b/tests/XPath/attr_value_test.hpp index 33dc38e3..dd9c222d 100644 --- a/tests/XPath/attr_value_test.hpp +++ b/tests/XPath/attr_value_test.hpp @@ -25,16 +25,16 @@ public: void testParse() { Arabica::DOM::Node dummy; - assertTrue(SA::construct_from_utf8("hello") == compileThis("hello")->evaluateAsString(dummy)); - assertTrue(SA::construct_from_utf8("") == compileThis("{hello}")->evaluateAsString(dummy)); - assertTrue(SA::construct_from_utf8("{hello}") == compileThis("{{hello}}")->evaluateAsString(dummy)); - assertTrue(SA::construct_from_utf8("{hello}") == compileThis("{{{'hello'}}}")->evaluateAsString(dummy)); - assertTrue(SA::construct_from_utf8("{}") == compileThis("{{{hello}}}")->evaluateAsString(dummy)); - assertTrue(SA::construct_from_utf8("{") == compileThis("{{")->evaluateAsString(dummy)); - assertTrue(SA::construct_from_utf8("}") == compileThis("}}")->evaluateAsString(dummy)); - assertTrue(SA::construct_from_utf8("hello") == compileThis("hello{@there}")->evaluateAsString(dummy)); - assertTrue(SA::construct_from_utf8("helloMOTHER{}") == compileThis("hello{@there}MOTHER{{}}")->evaluateAsString(dummy)); - assertTrue(SA::construct_from_utf8("hello there everyone look a }") == compileThis("hello {string('there')} everyone {string('look a }')}")->evaluateAsString(dummy)); + assertTrue(SA::construct_from_utf8("hello") == compileThis("hello").evaluateAsString(dummy)); + assertTrue(SA::construct_from_utf8("") == compileThis("{hello}").evaluateAsString(dummy)); + assertTrue(SA::construct_from_utf8("{hello}") == compileThis("{{hello}}").evaluateAsString(dummy)); + assertTrue(SA::construct_from_utf8("{hello}") == compileThis("{{{'hello'}}}").evaluateAsString(dummy)); + assertTrue(SA::construct_from_utf8("{}") == compileThis("{{{hello}}}").evaluateAsString(dummy)); + assertTrue(SA::construct_from_utf8("{") == compileThis("{{").evaluateAsString(dummy)); + assertTrue(SA::construct_from_utf8("}") == compileThis("}}").evaluateAsString(dummy)); + assertTrue(SA::construct_from_utf8("hello") == compileThis("hello{@there}").evaluateAsString(dummy)); + assertTrue(SA::construct_from_utf8("helloMOTHER{}") == compileThis("hello{@there}MOTHER{{}}").evaluateAsString(dummy)); + assertTrue(SA::construct_from_utf8("hello there everyone look a }") == compileThis("hello {string('there')} everyone {string('look a }')}").evaluateAsString(dummy)); } // testParse void testParseFail() @@ -60,7 +60,7 @@ public: return true; } // dontCompileThis - Arabica::XPath::XPathExpressionPtr compileThis(const char* match) + Arabica::XPath::XPathExpression compileThis(const char* match) { //std::cout << "----\n" << match << std::endl; return parser.compile_attribute_value_template(SA::construct_from_utf8(match)); diff --git a/tests/XPath/execute_test.hpp b/tests/XPath/execute_test.hpp index a483162a..4376e2a6 100644 --- a/tests/XPath/execute_test.hpp +++ b/tests/XPath/execute_test.hpp @@ -62,7 +62,7 @@ class TestFunction : public Arabica::XPath::XPathFunction >& args) : + TestFunction(const std::vector >& args) : Arabica::XPath::XPathFunction(0, 0, args) { } virtual Arabica::XPath::XPathValue_impl* evaluate(const Arabica::DOM::Node& context, @@ -82,7 +82,7 @@ public: virtual Arabica::XPath::XPathFunction* resolveFunction( const string_type& namespace_uri, const string_type& name, - const std::vector >& argExprs) const + const std::vector >& argExprs) const { if(name == string_adaptor::construct_from_utf8("test-function")) return new TestFunction(argExprs); @@ -176,9 +176,9 @@ public: void test1() { using namespace Arabica::XPath; - XPathExpressionPtr xpath; + XPathExpression xpath; xpath = parser.compile(SA::construct_from_utf8("root")); - XPathValue result = xpath->evaluate(document_); + XPathValue result = xpath.evaluate(document_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(1, result.asNodeSet().size()); @@ -189,8 +189,8 @@ public: void test2() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("root/child2")); - XPathValue result = xpath->evaluate(document_); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("root/child2")); + XPathValue result = xpath.evaluate(document_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(1, result.asNodeSet().size()); @@ -201,8 +201,8 @@ public: void test3() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("root/*")); - XPathValue result = xpath->evaluate(document_); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("root/*")); + XPathValue result = xpath.evaluate(document_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(3, result.asNodeSet().size()); @@ -214,8 +214,8 @@ public: void test4() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("root/*/text()")); - XPathValue result = xpath->evaluate(document_); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("root/*/text()")); + XPathValue result = xpath.evaluate(document_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(1, result.asNodeSet().size()); @@ -226,36 +226,36 @@ public: void test5() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("root/*/text()")); - assertTrue(text_.getNodeValue() == xpath->evaluateAsString(document_)); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("root/*/text()")); + assertTrue(text_.getNodeValue() == xpath.evaluateAsString(document_)); } // test5 void test6() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("*")); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("*")); - XPathValue result = xpath->evaluate(document_); + XPathValue result = xpath.evaluate(document_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(1, result.asNodeSet().size()); assertTrue(root_ == result.asNodeSet()[0]); - result = xpath->evaluate(root_); + result = xpath.evaluate(root_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(3, result.asNodeSet().size()); assertTrue(element1_ == result.asNodeSet()[0]); assertTrue(element2_ == result.asNodeSet()[1]); assertTrue(element3_ == result.asNodeSet()[2]); - result = xpath->evaluate(element1_); + result = xpath.evaluate(element1_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(0, result.asNodeSet().size()); - result = xpath->evaluate(element2_); + result = xpath.evaluate(element2_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(1, result.asNodeSet().size()); - result = xpath->evaluate(element3_); + result = xpath.evaluate(element3_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(0, result.asNodeSet().size()); } // test6 @@ -263,14 +263,14 @@ public: void test7() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("/root")); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("/root")); - XPathValue result = xpath->evaluate(document_); + XPathValue result = xpath.evaluate(document_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(1, result.asNodeSet().size()); assertTrue(root_ == result.asNodeSet()[0]); - result = xpath->evaluate(text_); + result = xpath.evaluate(text_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(1, result.asNodeSet().size()); assertTrue(root_ == result.asNodeSet()[0]); @@ -282,14 +282,14 @@ public: StandardNamespaceContext nsContext; nsContext.addNamespaceDeclaration(SA::construct_from_utf8("urn:something:or:other"), SA::construct_from_utf8("ns")); parser.setNamespaceContext(nsContext); - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("/ns:root")); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("/ns:root")); parser.resetNamespaceContext(); - XPathValue result = xpath->evaluate(document_); + XPathValue result = xpath.evaluate(document_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(0, result.asNodeSet().size()); - result = xpath->evaluate(text_); + result = xpath.evaluate(text_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(0, result.asNodeSet().size()); } // test8 @@ -297,15 +297,15 @@ public: void test9() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("child2")); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("child2")); - XPathValue result = xpath->evaluate(root_); + XPathValue result = xpath.evaluate(root_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(1, result.asNodeSet().size()); assertTrue(element2_ == result.asNodeSet()[0]); xpath = parser.compile(SA::construct_from_utf8("./child2")); - result = xpath->evaluate(root_); + result = xpath.evaluate(root_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(1, result.asNodeSet().size()); assertTrue(element2_ == result.asNodeSet()[0]); @@ -325,9 +325,9 @@ public: void test11() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("..")); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("..")); - XPathValue result = xpath->evaluate(element3_); + XPathValue result = xpath.evaluate(element3_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(1, result.asNodeSet().size()); assertTrue(root_ == result.asNodeSet()[0]); @@ -336,8 +336,8 @@ public: void test12() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("root/*[2]")); - XPathValue result = xpath->evaluate(document_); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("root/*[2]")); + XPathValue result = xpath.evaluate(document_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(1, result.asNodeSet().size()); @@ -409,8 +409,8 @@ public: void test19() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("root/*[position() = 2]")); - XPathValue result = xpath->evaluate(document_); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("root/*[position() = 2]")); + XPathValue result = xpath.evaluate(document_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(1, result.asNodeSet().size()); @@ -421,8 +421,8 @@ public: void test20() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("root/*[last()]")); - XPathValue result = xpath->evaluate(document_); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("root/*[last()]")); + XPathValue result = xpath.evaluate(document_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(1, result.asNodeSet().size()); @@ -432,8 +432,8 @@ public: void test21() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("root/*[position() != last()]")); - XPathValue result = xpath->evaluate(document_); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("root/*[position() != last()]")); + XPathValue result = xpath.evaluate(document_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(2, result.asNodeSet().size()); @@ -444,8 +444,8 @@ public: void test22() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("root/*[position() = 2 or position() = 1]")); - XPathValue result = xpath->evaluate(document_); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("root/*[position() = 2 or position() = 1]")); + XPathValue result = xpath.evaluate(document_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(2, result.asNodeSet().size()); @@ -456,8 +456,8 @@ public: void test23() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("root/*[position() = 2 and @two = '1']")); - XPathValue result = xpath->evaluate(document_); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("root/*[position() = 2 and @two = '1']")); + XPathValue result = xpath.evaluate(document_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(1, result.asNodeSet().size()); @@ -467,8 +467,8 @@ public: void test24() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("root/*[last()][1]")); - XPathValue result = xpath->evaluate(document_); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("root/*[last()][1]")); + XPathValue result = xpath.evaluate(document_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(1, result.asNodeSet().size()); @@ -478,8 +478,8 @@ public: void test25() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("root/*[last()][2]")); - XPathValue result = xpath->evaluate(document_); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("root/*[last()][2]")); + XPathValue result = xpath.evaluate(document_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(0, result.asNodeSet().size()); @@ -488,8 +488,8 @@ public: void test26() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("/root/child2/spinkle/ancestor::node()[2]")); - XPathValue result = xpath->evaluate(document_); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("/root/child2/spinkle/ancestor::node()[2]")); + XPathValue result = xpath.evaluate(document_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(1, result.asNodeSet().size()); @@ -500,8 +500,8 @@ public: void test27() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("/root/child2/spinkle/ancestor-or-self::node()[2]")); - XPathValue result = xpath->evaluate(document_); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("/root/child2/spinkle/ancestor-or-self::node()[2]")); + XPathValue result = xpath.evaluate(document_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(1, result.asNodeSet().size()); @@ -512,8 +512,8 @@ public: void test28() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile(SA::construct_from_utf8("/root/child2/spinkle/ancestor-or-self::node()[3]")); - XPathValue result = xpath->evaluate(document_); + XPathExpression xpath = parser.compile(SA::construct_from_utf8("/root/child2/spinkle/ancestor-or-self::node()[3]")); + XPathValue result = xpath.evaluate(document_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(1, result.asNodeSet().size()); diff --git a/tests/XPath/expression_test.hpp b/tests/XPath/expression_test.hpp index 7bd5e782..c5e80dba 100644 --- a/tests/XPath/expression_test.hpp +++ b/tests/XPath/expression_test.hpp @@ -95,14 +95,14 @@ public: void testNode1() { using namespace Arabica::XPath; - XPathExpressionPtr xpath = parser.compile_expr(SA::construct_from_utf8("node()")); - XPathValue result = xpath->evaluate(document_); + XPathExpression xpath = parser.compile_expr(SA::construct_from_utf8("node()")); + XPathValue result = xpath.evaluate(document_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(1, result.asNodeSet().size()); assertTrue(root_ == result.asNodeSet()[0]); - result = xpath->evaluate(element2_); + result = xpath.evaluate(element2_); assertValuesEqual(NODE_SET, result.type()); assertValuesEqual(4, result.asNodeSet().size()); } // testNode1 diff --git a/tests/XPath/logical_test.hpp b/tests/XPath/logical_test.hpp index 2f66ba9f..ac161255 100644 --- a/tests/XPath/logical_test.hpp +++ b/tests/XPath/logical_test.hpp @@ -22,57 +22,57 @@ public: void test1() { using namespace Arabica::XPath; - XPathExpressionPtr orTest(new impl::OrOperator(new BoolValue(false), new BoolValue(false))); - assertEquals(false, orTest->evaluateAsBool(dummy_)); + XPathExpression orTest(new impl::OrOperator(new BoolValue(false), new BoolValue(false))); + assertEquals(false, orTest.evaluateAsBool(dummy_)); } // test1 void test2() { using namespace Arabica::XPath; - XPathExpressionPtr orTest(new impl::OrOperator(new BoolValue(false), new BoolValue(true))); - assertEquals(true, orTest->evaluateAsBool(dummy_)); + XPathExpression orTest(new impl::OrOperator(new BoolValue(false), new BoolValue(true))); + assertEquals(true, orTest.evaluateAsBool(dummy_)); } // test2 void test3() { using namespace Arabica::XPath; - XPathExpressionPtr orTest(new impl::OrOperator(new BoolValue(true), new BoolValue(false))); - assertEquals(true, orTest->evaluateAsBool(dummy_)); + XPathExpression orTest(new impl::OrOperator(new BoolValue(true), new BoolValue(false))); + assertEquals(true, orTest.evaluateAsBool(dummy_)); } // test3 void test4() { using namespace Arabica::XPath; - XPathExpressionPtr orTest(new impl::OrOperator(new BoolValue(true), new BoolValue(true))); - assertEquals(true, orTest->evaluateAsBool(dummy_)); + XPathExpression orTest(new impl::OrOperator(new BoolValue(true), new BoolValue(true))); + assertEquals(true, orTest.evaluateAsBool(dummy_)); } // test4 void test5() { using namespace Arabica::XPath; - XPathExpressionPtr andTest(new impl::AndOperator(new BoolValue(false), new BoolValue(false))); - assertEquals(false, andTest->evaluateAsBool(dummy_)); + XPathExpression andTest(new impl::AndOperator(new BoolValue(false), new BoolValue(false))); + assertEquals(false, andTest.evaluateAsBool(dummy_)); } // test5 void test6() { using namespace Arabica::XPath; - XPathExpressionPtr andTest(new impl::AndOperator(new BoolValue(false), new BoolValue(true))); - assertEquals(false, andTest->evaluateAsBool(dummy_)); + XPathExpression andTest(new impl::AndOperator(new BoolValue(false), new BoolValue(true))); + assertEquals(false, andTest.evaluateAsBool(dummy_)); } // test6 void test7() { using namespace Arabica::XPath; - XPathExpressionPtr andTest(new impl::AndOperator(new BoolValue(true), new BoolValue(false))); - assertEquals(false, andTest->evaluateAsBool(dummy_)); + XPathExpression andTest(new impl::AndOperator(new BoolValue(true), new BoolValue(false))); + assertEquals(false, andTest.evaluateAsBool(dummy_)); } // test7 void test8() { using namespace Arabica::XPath; - XPathExpressionPtr andTest(new impl::AndOperator(new BoolValue(true), new BoolValue(true))); - assertEquals(true, andTest->evaluateAsBool(dummy_)); + XPathExpression andTest(new impl::AndOperator(new BoolValue(true), new BoolValue(true))); + assertEquals(true, andTest.evaluateAsBool(dummy_)); } // test8 private: diff --git a/tests/XPath/parse_test.hpp b/tests/XPath/parse_test.hpp index 93d0df37..df4bb9d3 100644 --- a/tests/XPath/parse_test.hpp +++ b/tests/XPath/parse_test.hpp @@ -14,7 +14,7 @@ public: virtual Arabica::XPath::XPathFunction* resolveFunction( const string_type& namespace_uri, const string_type& name, - const std::vector >& argExprs) const + const std::vector >& argExprs) const { if((namespace_uri == string_adaptor::construct_from_utf8("something")) && (name == string_adaptor::construct_from_utf8("true"))) diff --git a/tests/XPath/relational_test.hpp b/tests/XPath/relational_test.hpp index 95576ac3..c5ec6f8b 100644 --- a/tests/XPath/relational_test.hpp +++ b/tests/XPath/relational_test.hpp @@ -22,29 +22,29 @@ public: void test1() { using namespace Arabica::XPath; - XPathExpressionPtr equals1(new impl::EqualsOperator(new NumericValue(1), new NumericValue(1))); - XPathExpressionPtr equals2(new impl::EqualsOperator(new NumericValue(1), new NumericValue(1))); + XPathExpression equals1(new impl::EqualsOperator(new NumericValue(1), new NumericValue(1))); + XPathExpression equals2(new impl::EqualsOperator(new NumericValue(1), new NumericValue(1))); - assertEquals(true, equals1->evaluateAsBool(dummy_)); - assertEquals(true, equals2->evaluateAsBool(dummy_)); + assertEquals(true, equals1.evaluateAsBool(dummy_)); + assertEquals(true, equals2.evaluateAsBool(dummy_)); } // test1 void test2() { using namespace Arabica::XPath; - XPathExpressionPtr equals1(new impl::EqualsOperator(new NumericValue(1), new NumericValue(2))); - XPathExpressionPtr equals2(new impl::EqualsOperator(new NumericValue(2), new NumericValue(1))); + XPathExpression equals1(new impl::EqualsOperator(new NumericValue(1), new NumericValue(2))); + XPathExpression equals2(new impl::EqualsOperator(new NumericValue(2), new NumericValue(1))); - assertEquals(false, equals1->evaluateAsBool(dummy_)); - assertEquals(false, equals2->evaluateAsBool(dummy_)); + assertEquals(false, equals1.evaluateAsBool(dummy_)); + assertEquals(false, equals2.evaluateAsBool(dummy_)); } // test2 void test3() { using namespace Arabica::XPath; - XPathExpressionPtr equals1(new impl::EqualsOperator(new NumericValue(1), new NumericValue(1))); + XPathExpression equals1(new impl::EqualsOperator(new NumericValue(1), new NumericValue(1))); - assertEquals(true, equals1->evaluateAsBool(dummy_)); + assertEquals(true, equals1.evaluateAsBool(dummy_)); } // test3 void test4() @@ -53,9 +53,9 @@ public: XPathExpression_impl* p1 = new StringValue("charlie"); XPathExpression_impl* p2 = new StringValue("charlie"); - XPathExpressionPtr equals1(new impl::EqualsOperator(p1, p2)); + XPathExpression equals1(new impl::EqualsOperator(p1, p2)); - assertEquals(true, equals1->evaluateAsBool(dummy_)); + assertEquals(true, equals1.evaluateAsBool(dummy_)); } // test4 void test5() @@ -64,113 +64,113 @@ public: XPathExpression_impl* p1 = new StringValue("trousers"); XPathExpression_impl* p2 = new StringValue("charlie"); - XPathExpressionPtr equals1(new impl::EqualsOperator(p1, p2)); + XPathExpression equals1(new impl::EqualsOperator(p1, p2)); - assertEquals(false, equals1->evaluateAsBool(dummy_)); + assertEquals(false, equals1.evaluateAsBool(dummy_)); } // test5 void test6() { using namespace Arabica::XPath; - XPathExpressionPtr equals1(new impl::EqualsOperator(new BoolValue(true), new BoolValue(true))); - XPathExpressionPtr equals2(new impl::EqualsOperator(new BoolValue(false), new BoolValue(false))); + XPathExpression equals1(new impl::EqualsOperator(new BoolValue(true), new BoolValue(true))); + XPathExpression equals2(new impl::EqualsOperator(new BoolValue(false), new BoolValue(false))); - assertEquals(true, equals1->evaluateAsBool(dummy_)); - assertEquals(true, equals2->evaluateAsBool(dummy_)); + assertEquals(true, equals1.evaluateAsBool(dummy_)); + assertEquals(true, equals2.evaluateAsBool(dummy_)); } // test6 void test7() { using namespace Arabica::XPath; - XPathExpressionPtr equals1(new impl::EqualsOperator(new BoolValue(true), new BoolValue(false))); - XPathExpressionPtr equals2(new impl::EqualsOperator(new BoolValue(false), new BoolValue(true))); + XPathExpression equals1(new impl::EqualsOperator(new BoolValue(true), new BoolValue(false))); + XPathExpression equals2(new impl::EqualsOperator(new BoolValue(false), new BoolValue(true))); - assertEquals(false, equals1->evaluateAsBool(dummy_)); - assertEquals(false, equals2->evaluateAsBool(dummy_)); + assertEquals(false, equals1.evaluateAsBool(dummy_)); + assertEquals(false, equals2.evaluateAsBool(dummy_)); } // test7 void testLessThan1() { using namespace Arabica::XPath; - XPathExpressionPtr lessThan1(new impl::LessThanOperator(new BoolValue(true), new BoolValue(true))); - XPathExpressionPtr lessThan2(new impl::LessThanOperator(new BoolValue(false), new BoolValue(false))); - XPathExpressionPtr lessThan3(new impl::LessThanOperator(new BoolValue(true), new BoolValue(false))); - XPathExpressionPtr lessThan4(new impl::LessThanOperator(new BoolValue(false), new BoolValue(true))); + XPathExpression lessThan1(new impl::LessThanOperator(new BoolValue(true), new BoolValue(true))); + XPathExpression lessThan2(new impl::LessThanOperator(new BoolValue(false), new BoolValue(false))); + XPathExpression lessThan3(new impl::LessThanOperator(new BoolValue(true), new BoolValue(false))); + XPathExpression lessThan4(new impl::LessThanOperator(new BoolValue(false), new BoolValue(true))); - assertEquals(false, lessThan1->evaluateAsBool(dummy_)); - assertEquals(false, lessThan2->evaluateAsBool(dummy_)); - assertEquals(false, lessThan3->evaluateAsBool(dummy_)); - assertEquals(true, lessThan4->evaluateAsBool(dummy_)); + assertEquals(false, lessThan1.evaluateAsBool(dummy_)); + assertEquals(false, lessThan2.evaluateAsBool(dummy_)); + assertEquals(false, lessThan3.evaluateAsBool(dummy_)); + assertEquals(true, lessThan4.evaluateAsBool(dummy_)); } // testLessThan1 void testLessThan2() { using namespace Arabica::XPath; - XPathExpressionPtr lessThan1(new impl::LessThanOperator(new NumericValue(1.0), new NumericValue(1.0))); - XPathExpressionPtr lessThan2(new impl::LessThanOperator(new NumericValue(3.0), new NumericValue(2.0))); - XPathExpressionPtr lessThan3(new impl::LessThanOperator(new NumericValue(2.0), new NumericValue(3.0))); - XPathExpressionPtr lessThan4(new impl::LessThanOperator(new NumericValue(-1), new NumericValue(1))); + XPathExpression lessThan1(new impl::LessThanOperator(new NumericValue(1.0), new NumericValue(1.0))); + XPathExpression lessThan2(new impl::LessThanOperator(new NumericValue(3.0), new NumericValue(2.0))); + XPathExpression lessThan3(new impl::LessThanOperator(new NumericValue(2.0), new NumericValue(3.0))); + XPathExpression lessThan4(new impl::LessThanOperator(new NumericValue(-1), new NumericValue(1))); - assertEquals(false, lessThan1->evaluateAsBool(dummy_)); - assertEquals(false, lessThan2->evaluateAsBool(dummy_)); - assertEquals(true, lessThan3->evaluateAsBool(dummy_)); - assertEquals(true, lessThan4->evaluateAsBool(dummy_)); + assertEquals(false, lessThan1.evaluateAsBool(dummy_)); + assertEquals(false, lessThan2.evaluateAsBool(dummy_)); + assertEquals(true, lessThan3.evaluateAsBool(dummy_)); + assertEquals(true, lessThan4.evaluateAsBool(dummy_)); } // testLessThan2 void testLessThan3() { using namespace Arabica::XPath; - XPathExpressionPtr lessThan1(new impl::LessThanOperator(new StringValue("1.0"), new StringValue("1.0"))); - XPathExpressionPtr lessThan2(new impl::LessThanOperator(new StringValue("3.0"), new StringValue("2.0"))); - XPathExpressionPtr lessThan3(new impl::LessThanOperator(new StringValue("2.0"), new StringValue("3.0"))); - XPathExpressionPtr lessThan4(new impl::LessThanOperator(new StringValue("-1"), new StringValue("1"))); + XPathExpression lessThan1(new impl::LessThanOperator(new StringValue("1.0"), new StringValue("1.0"))); + XPathExpression lessThan2(new impl::LessThanOperator(new StringValue("3.0"), new StringValue("2.0"))); + XPathExpression lessThan3(new impl::LessThanOperator(new StringValue("2.0"), new StringValue("3.0"))); + XPathExpression lessThan4(new impl::LessThanOperator(new StringValue("-1"), new StringValue("1"))); - assertEquals(false, lessThan1->evaluateAsBool(dummy_)); - assertEquals(false, lessThan2->evaluateAsBool(dummy_)); - assertEquals(true, lessThan3->evaluateAsBool(dummy_)); - assertEquals(true, lessThan4->evaluateAsBool(dummy_)); + assertEquals(false, lessThan1.evaluateAsBool(dummy_)); + assertEquals(false, lessThan2.evaluateAsBool(dummy_)); + assertEquals(true, lessThan3.evaluateAsBool(dummy_)); + assertEquals(true, lessThan4.evaluateAsBool(dummy_)); } // testLessThan3 void testLessThanEquals1() { using namespace Arabica::XPath; - XPathExpressionPtr lessThanEquals1(new impl::LessThanEqualsOperator(new BoolValue(true), new BoolValue(true))); - XPathExpressionPtr lessThanEquals2(new impl::LessThanEqualsOperator(new BoolValue(false), new BoolValue(false))); - XPathExpressionPtr lessThanEquals3(new impl::LessThanEqualsOperator(new BoolValue(true), new BoolValue(false))); - XPathExpressionPtr lessThanEquals4(new impl::LessThanEqualsOperator(new BoolValue(false), new BoolValue(true))); + XPathExpression lessThanEquals1(new impl::LessThanEqualsOperator(new BoolValue(true), new BoolValue(true))); + XPathExpression lessThanEquals2(new impl::LessThanEqualsOperator(new BoolValue(false), new BoolValue(false))); + XPathExpression lessThanEquals3(new impl::LessThanEqualsOperator(new BoolValue(true), new BoolValue(false))); + XPathExpression lessThanEquals4(new impl::LessThanEqualsOperator(new BoolValue(false), new BoolValue(true))); - assertEquals(true, lessThanEquals1->evaluateAsBool(dummy_)); - assertEquals(true, lessThanEquals2->evaluateAsBool(dummy_)); - assertEquals(false, lessThanEquals3->evaluateAsBool(dummy_)); - assertEquals(true, lessThanEquals4->evaluateAsBool(dummy_)); + assertEquals(true, lessThanEquals1.evaluateAsBool(dummy_)); + assertEquals(true, lessThanEquals2.evaluateAsBool(dummy_)); + assertEquals(false, lessThanEquals3.evaluateAsBool(dummy_)); + assertEquals(true, lessThanEquals4.evaluateAsBool(dummy_)); } // testLessThanEquals1 void testLessThanEquals2() { using namespace Arabica::XPath; - XPathExpressionPtr lessThanEquals1(new impl::LessThanEqualsOperator(new NumericValue(1.0), new NumericValue(1.0))); - XPathExpressionPtr lessThanEquals2(new impl::LessThanEqualsOperator(new NumericValue(3.0), new NumericValue(2.0))); - XPathExpressionPtr lessThanEquals3(new impl::LessThanEqualsOperator(new NumericValue(2.0), new NumericValue(3.0))); - XPathExpressionPtr lessThanEquals4(new impl::LessThanEqualsOperator(new NumericValue(-1), new NumericValue(1))); + XPathExpression lessThanEquals1(new impl::LessThanEqualsOperator(new NumericValue(1.0), new NumericValue(1.0))); + XPathExpression lessThanEquals2(new impl::LessThanEqualsOperator(new NumericValue(3.0), new NumericValue(2.0))); + XPathExpression lessThanEquals3(new impl::LessThanEqualsOperator(new NumericValue(2.0), new NumericValue(3.0))); + XPathExpression lessThanEquals4(new impl::LessThanEqualsOperator(new NumericValue(-1), new NumericValue(1))); - assertEquals(true, lessThanEquals1->evaluateAsBool(dummy_)); - assertEquals(false, lessThanEquals2->evaluateAsBool(dummy_)); - assertEquals(true, lessThanEquals3->evaluateAsBool(dummy_)); - assertEquals(true, lessThanEquals4->evaluateAsBool(dummy_)); + assertEquals(true, lessThanEquals1.evaluateAsBool(dummy_)); + assertEquals(false, lessThanEquals2.evaluateAsBool(dummy_)); + assertEquals(true, lessThanEquals3.evaluateAsBool(dummy_)); + assertEquals(true, lessThanEquals4.evaluateAsBool(dummy_)); } // testLessThanEquals2 void testLessThanEquals3() { using namespace Arabica::XPath; - XPathExpressionPtr lessThanEquals1(new impl::LessThanEqualsOperator(new StringValue("1.0"), new StringValue("1.0"))); - XPathExpressionPtr lessThanEquals2(new impl::LessThanEqualsOperator(new StringValue("3.0"), new StringValue("2.0"))); - XPathExpressionPtr lessThanEquals3(new impl::LessThanEqualsOperator(new StringValue("2.0"), new StringValue("3.0"))); - XPathExpressionPtr lessThanEquals4(new impl::LessThanEqualsOperator(new StringValue("-1"), new StringValue("1"))); + XPathExpression lessThanEquals1(new impl::LessThanEqualsOperator(new StringValue("1.0"), new StringValue("1.0"))); + XPathExpression lessThanEquals2(new impl::LessThanEqualsOperator(new StringValue("3.0"), new StringValue("2.0"))); + XPathExpression lessThanEquals3(new impl::LessThanEqualsOperator(new StringValue("2.0"), new StringValue("3.0"))); + XPathExpression lessThanEquals4(new impl::LessThanEqualsOperator(new StringValue("-1"), new StringValue("1"))); - assertEquals(true, lessThanEquals1->evaluateAsBool(dummy_)); - assertEquals(false, lessThanEquals2->evaluateAsBool(dummy_)); - assertEquals(true, lessThanEquals3->evaluateAsBool(dummy_)); - assertEquals(true, lessThanEquals4->evaluateAsBool(dummy_)); + assertEquals(true, lessThanEquals1.evaluateAsBool(dummy_)); + assertEquals(false, lessThanEquals2.evaluateAsBool(dummy_)); + assertEquals(true, lessThanEquals3.evaluateAsBool(dummy_)); + assertEquals(true, lessThanEquals4.evaluateAsBool(dummy_)); } // testLessThanEquals3 private: diff --git a/tests/XPath/step_test.hpp b/tests/XPath/step_test.hpp index 1e19f7b2..9851c8d4 100644 --- a/tests/XPath/step_test.hpp +++ b/tests/XPath/step_test.hpp @@ -56,9 +56,9 @@ public: void test1() { using namespace Arabica::XPath; - XPathExpressionPtr step(new impl::TestStepExpression(CHILD, new impl::AnyNodeTest())); + XPathExpression step(new impl::TestStepExpression(CHILD, new impl::AnyNodeTest())); - XPathValue value = step->evaluate(root_); + XPathValue value = step.evaluate(root_); const NodeSet& set = value.asNodeSet(); assertEquals(set.size(), 3); @@ -70,9 +70,9 @@ public: void test2() { using namespace Arabica::XPath; - XPathExpressionPtr step(new impl::TestStepExpression(ATTRIBUTE, new impl::AnyNodeTest())); + XPathExpression step(new impl::TestStepExpression(ATTRIBUTE, new impl::AnyNodeTest())); - NodeSet set = step->evaluateAsNodeSet(element2_); + NodeSet set = step.evaluateAsNodeSet(element2_); assertEquals(4, set.size()); Arabica::DOM::Attr attr = static_cast >(set[0]); @@ -88,10 +88,10 @@ public: void test3() { using namespace Arabica::XPath; - XPathExpressionPtr step(new impl::TestStepExpression step(new impl::TestStepExpression(CHILD, new impl::NameNodeTest(SA::construct_from_utf8("child2")))); - XPathValue value = step->evaluate(root_); + XPathValue value = step.evaluate(root_); const NodeSet& set = value.asNodeSet(); assertEquals(1, set.size()); diff --git a/tests/XPath/value_test.hpp b/tests/XPath/value_test.hpp index 6082beda..793bbed7 100644 --- a/tests/XPath/value_test.hpp +++ b/tests/XPath/value_test.hpp @@ -26,147 +26,147 @@ public: void test1() { using namespace Arabica::XPath; - XPathExpressionPtr b(new BoolValue(true)); - assertEquals(true, b->evaluateAsBool(dummy_)); - assertEquals(1.0, b->evaluateAsNumber(dummy_), 0.0); - assertTrue(SA::construct_from_utf8("true") == b->evaluateAsString(dummy_)); + XPathExpression b(new BoolValue(true)); + assertEquals(true, b.evaluateAsBool(dummy_)); + assertEquals(1.0, b.evaluateAsNumber(dummy_), 0.0); + assertTrue(SA::construct_from_utf8("true") == b.evaluateAsString(dummy_)); } void test2() { using namespace Arabica::XPath; - XPathExpressionPtr b2(new BoolValue(false)); - assertEquals(false, b2->evaluateAsBool(dummy_)); - assertEquals(0.0, b2->evaluateAsNumber(dummy_), 0.0); - assertTrue(SA::construct_from_utf8("false") == b2->evaluateAsString(dummy_)); + XPathExpression b2(new BoolValue(false)); + assertEquals(false, b2.evaluateAsBool(dummy_)); + assertEquals(0.0, b2.evaluateAsNumber(dummy_), 0.0); + assertTrue(SA::construct_from_utf8("false") == b2.evaluateAsString(dummy_)); } // test2 void test3() { using namespace Arabica::XPath; - XPathExpressionPtr n(new NumericValue(99.5)); - assertEquals(true, n->evaluateAsBool(dummy_)); - assertEquals(99.5, n->evaluateAsNumber(dummy_), 0.0); - assertTrue(SA::construct_from_utf8("99.5") == n->evaluateAsString(dummy_)); + XPathExpression n(new NumericValue(99.5)); + assertEquals(true, n.evaluateAsBool(dummy_)); + assertEquals(99.5, n.evaluateAsNumber(dummy_), 0.0); + assertTrue(SA::construct_from_utf8("99.5") == n.evaluateAsString(dummy_)); } void test4() { using namespace Arabica::XPath; - XPathExpressionPtr n(new NumericValue(0.0)); - assertEquals(false, n->evaluateAsBool(dummy_)); - assertEquals(0, n->evaluateAsNumber(dummy_), 0); - assertTrue(SA::construct_from_utf8("0") == n->evaluateAsString(dummy_)); + XPathExpression n(new NumericValue(0.0)); + assertEquals(false, n.evaluateAsBool(dummy_)); + assertEquals(0, n.evaluateAsNumber(dummy_), 0); + assertTrue(SA::construct_from_utf8("0") == n.evaluateAsString(dummy_)); } void test5() { using namespace Arabica::XPath; - XPathExpressionPtr s(new StringValue("hello")); - assertEquals(true, s->evaluateAsBool(dummy_)); - assertTrue(SA::construct_from_utf8("hello") == s->evaluateAsString(dummy_)); + XPathExpression s(new StringValue("hello")); + assertEquals(true, s.evaluateAsBool(dummy_)); + assertTrue(SA::construct_from_utf8("hello") == s.evaluateAsString(dummy_)); } // test5 void test6() { using namespace Arabica::XPath; - XPathExpressionPtr s(new StringValue("")); - assertEquals(false, s->evaluateAsBool(dummy_)); + XPathExpression s(new StringValue("")); + assertEquals(false, s.evaluateAsBool(dummy_)); } void test7() { using namespace Arabica::XPath; - XPathExpressionPtr s(new StringValue("100")); - assertEquals(true, s->evaluateAsBool(dummy_)); - assertEquals(100.0, s->evaluateAsNumber(dummy_), 0.0); - assertTrue(SA::construct_from_utf8("100") == s->evaluateAsString(dummy_)); + XPathExpression s(new StringValue("100")); + assertEquals(true, s.evaluateAsBool(dummy_)); + assertEquals(100.0, s.evaluateAsNumber(dummy_), 0.0); + assertTrue(SA::construct_from_utf8("100") == s.evaluateAsString(dummy_)); } // test7 void test8() { using namespace Arabica::XPath; - XPathExpressionPtr s(new StringValue("0")); - assertEquals(true, s->evaluateAsBool(dummy_)); - assertEquals(0.0, s->evaluateAsNumber(dummy_), 0.0); - assertTrue(SA::construct_from_utf8("0") == s->evaluateAsString(dummy_)); + XPathExpression s(new StringValue("0")); + assertEquals(true, s.evaluateAsBool(dummy_)); + assertEquals(0.0, s.evaluateAsNumber(dummy_), 0.0); + assertTrue(SA::construct_from_utf8("0") == s.evaluateAsString(dummy_)); } // test8 void test9() { using namespace Arabica::XPath; - XPathExpressionPtr bt(new BoolValue(true)); - XPathExpressionPtr st(new StringValue("true")); - XPathExpressionPtr bf(new BoolValue(false)); - XPathExpressionPtr sf(new StringValue("")); + XPathExpression bt(new BoolValue(true)); + XPathExpression st(new StringValue("true")); + XPathExpression bf(new BoolValue(false)); + XPathExpression sf(new StringValue("")); - assertTrue((impl::areEqual(bt->evaluate(dummy_), (st->evaluate(dummy_))))); - assertTrue((impl::areEqual(st->evaluate(dummy_), (bt->evaluate(dummy_))))); + assertTrue((impl::areEqual(bt.evaluate(dummy_), (st.evaluate(dummy_))))); + assertTrue((impl::areEqual(st.evaluate(dummy_), (bt.evaluate(dummy_))))); - assertTrue((impl::areEqual(sf->evaluate(dummy_), (bf->evaluate(dummy_))))); - assertTrue((impl::areEqual(bf->evaluate(dummy_), (sf->evaluate(dummy_))))); + assertTrue((impl::areEqual(sf.evaluate(dummy_), (bf.evaluate(dummy_))))); + assertTrue((impl::areEqual(bf.evaluate(dummy_), (sf.evaluate(dummy_))))); - assertTrue((impl::areEqual(bt->evaluate(dummy_), (bt->evaluate(dummy_))))); - assertTrue((impl::areEqual(bf->evaluate(dummy_), (bf->evaluate(dummy_))))); - assertTrue((impl::areEqual(st->evaluate(dummy_), (st->evaluate(dummy_))))); - assertTrue((impl::areEqual(sf->evaluate(dummy_), (sf->evaluate(dummy_))))); + assertTrue((impl::areEqual(bt.evaluate(dummy_), (bt.evaluate(dummy_))))); + assertTrue((impl::areEqual(bf.evaluate(dummy_), (bf.evaluate(dummy_))))); + assertTrue((impl::areEqual(st.evaluate(dummy_), (st.evaluate(dummy_))))); + assertTrue((impl::areEqual(sf.evaluate(dummy_), (sf.evaluate(dummy_))))); } // test9 void test10() { using namespace Arabica::XPath; - XPathExpressionPtr bt(new BoolValue(true)); - XPathExpressionPtr nt(new NumericValue(1.0)); - XPathExpressionPtr bf(new BoolValue(false)); - XPathExpressionPtr nf(new NumericValue(0.0)); + XPathExpression bt(new BoolValue(true)); + XPathExpression nt(new NumericValue(1.0)); + XPathExpression bf(new BoolValue(false)); + XPathExpression nf(new NumericValue(0.0)); - assertTrue((impl::areEqual(bt->evaluate(dummy_), (nt->evaluate(dummy_))))); - assertTrue((impl::areEqual(nt->evaluate(dummy_), (bt->evaluate(dummy_))))); + assertTrue((impl::areEqual(bt.evaluate(dummy_), (nt.evaluate(dummy_))))); + assertTrue((impl::areEqual(nt.evaluate(dummy_), (bt.evaluate(dummy_))))); - assertTrue((impl::areEqual(bf->evaluate(dummy_), (nf->evaluate(dummy_))))); - assertTrue((impl::areEqual(nf->evaluate(dummy_), (bf->evaluate(dummy_))))); + assertTrue((impl::areEqual(bf.evaluate(dummy_), (nf.evaluate(dummy_))))); + assertTrue((impl::areEqual(nf.evaluate(dummy_), (bf.evaluate(dummy_))))); } // test10 void test11() { using namespace Arabica::XPath; - XPathExpressionPtr nt(new NumericValue(1.0)); - XPathValue ns = nt->evaluate(dummy_); + XPathExpression nt(new NumericValue(1.0)); + XPathValue ns = nt.evaluate(dummy_); - assertTrue((impl::areEqual(ns, (nt->evaluate(dummy_))))); + assertTrue((impl::areEqual(ns, (nt.evaluate(dummy_))))); } // test11 void test12() { using namespace Arabica::XPath; - XPathExpressionPtr n(new NumericValue(NaN)); - assertEquals(false, n->evaluateAsBool(dummy_)); - assertTrue(isNaN(n->evaluateAsNumber(dummy_))); - assertTrue(SA::construct_from_utf8("NaN") == n->evaluateAsString(dummy_)); + XPathExpression n(new NumericValue(NaN)); + assertEquals(false, n.evaluateAsBool(dummy_)); + assertTrue(isNaN(n.evaluateAsNumber(dummy_))); + assertTrue(SA::construct_from_utf8("NaN") == n.evaluateAsString(dummy_)); } void test13() { using namespace Arabica::XPath; - XPathExpressionPtr s(new StringValue(" 100 ")); - assertEquals(true, s->evaluateAsBool(dummy_)); - assertEquals(100.0, s->evaluateAsNumber(dummy_), 0.0); + XPathExpression s(new StringValue(" 100 ")); + assertEquals(true, s.evaluateAsBool(dummy_)); + assertEquals(100.0, s.evaluateAsNumber(dummy_), 0.0); } // test13 void test14() { using namespace Arabica::XPath; - XPathExpressionPtr s(new StringValue(" -100 ")); - assertEquals(true, s->evaluateAsBool(dummy_)); - assertEquals(-100.0, s->evaluateAsNumber(dummy_), 0.0); + XPathExpression s(new StringValue(" -100 ")); + assertEquals(true, s.evaluateAsBool(dummy_)); + assertEquals(-100.0, s.evaluateAsNumber(dummy_), 0.0); } // test14 void test15() { using namespace Arabica::XPath; - XPathExpressionPtr s(new StringValue("trousers")); - assertEquals(true, s->evaluateAsBool(dummy_)); - assertTrue(isNaN(s->evaluateAsNumber(dummy_))); + XPathExpression s(new StringValue("trousers")); + assertEquals(true, s.evaluateAsBool(dummy_)); + assertTrue(isNaN(s.evaluateAsNumber(dummy_))); } // test15 }; // ValueTest