/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 3 * only, as published by the Free Software Foundation. * * OpenOffice.org is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License version 3 for more details * (a copy is included in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU Lesser General Public License * version 3 along with OpenOffice.org. If not, see * * for a copy of the LGPLv3 License. * ************************************************************************/ #include #include #include #include #include #include #include #include using namespace writerfilter; class TestQName : public CppUnit::TestFixture { public: void testAdd(const sal_Char* namespaceUri, const sal_Char *localName) { QName_t t=QName::tokenizer().insert(namespaceUri, localName); const sal_Char *ln=QName::serializer().getLocalName(t); const sal_Char *ns=QName::serializer().getNamespaceUri(t); CPPUNIT_ASSERT(rtl_str_compare(localName, ln)==0); CPPUNIT_ASSERT(rtl_str_compare(namespaceUri, ns)==0); } void test() { rtlRandomPool rndPool=rtl_random_createPool(); int numOfIterations=100000; //int numOfIterations=5000000; for(int i=0;i context=QName::tokenizer().createQNameTokenizerContext(); context->addBinding("xmlns:test", "http://sample.org/test1"); CPPUNIT_ASSERT(rtl_str_compare(context->resolvePrefix("test"), "http://sample.org/test1")==0); } void test_context2() { std::auto_ptr context=QName::tokenizer().createQNameTokenizerContext(); context->addBinding("xmlns:test", "http://sample.org/test1"); context->enterScope(); CPPUNIT_ASSERT(rtl_str_compare(context->resolvePrefix("test"), "http://sample.org/test1")==0); context->leaveScope(); CPPUNIT_ASSERT(rtl_str_compare(context->resolvePrefix("test"), "http://sample.org/test1")==0); } void test_context3() { std::auto_ptr context=QName::tokenizer().createQNameTokenizerContext(); context->addBinding("xmlns:test", "http://sample.org/test1"); context->enterScope(); context->addBinding("xmlns:test", "http://sample.org/test2"); CPPUNIT_ASSERT(rtl_str_compare(context->resolvePrefix("test"), "http://sample.org/test2")==0); context->leaveScope(); CPPUNIT_ASSERT(rtl_str_compare(context->resolvePrefix("test"), "http://sample.org/test1")==0); } void test_resolver1() { QName_t qn; std::auto_ptr context=QName::tokenizer().createQNameTokenizerContext(); context->addBinding("xmlns:text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0"); CPPUNIT_ASSERT(QName::tokenizer().insert("text:span", *context, &qn)); CPPUNIT_ASSERT(qn== NS_text::LN_span); } void test_serializer1() { std::auto_ptr context=QName::tokenizer().createQNameSerializerContext(); { context->addPrefix("text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0"); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:oasis:names:tc:opendocument:xmlns:text:1.0"), "text")==0); } } void test_serializer2() { std::auto_ptr context=QName::tokenizer().createQNameSerializerContext(); { CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://sample.org/test1"), "_p0")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://sample.org/test2"), "_p1")==0); } } void test_prefix() { std::auto_ptr context=QName::tokenizer().createQNameSerializerContext(); CPPUNIT_ASSERT(context->getPrefix("")==QName::EMPTY_STRING); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:oasis:names:tc:opendocument:xmlns:animation:1.0"), "anium")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://www.w3.org/1998/Math/MathML"), "math")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:schemas-microsoft-com:office:word"), "w10")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:oasis:names:tc:opendocument:xmlns:chart:1.0"), "chart")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/excel/2005/8/singlecells"), "sc12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:schemas-microsoft-com:office:odc"), "odc12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:schemas-microsoft-com:office:component:spreadsheet"), "c11")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://relaxng.org/ns/structure/1.0"), "rng")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:oasis:names:tc:opendocument:xmlns:meta:1.0"), "meta")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/data/udc/soap"), "udcs")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://www.w3.org/1999/xlink"), "xlink")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:oasis:names:tc:opendocument:xmlns:style:1.0"), "style")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"), "fo")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://www.w3.org/2002/xforms"), "xforms")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"), "draw")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/project"), "prj12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/package/2005/06/metadata/core-properties"), "mdc12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:oasis:names:tc:opendocument:xmlns:table:1.0"), "table")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:schemas-microsoft-com:rowset"), "rs11")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/excel/2005/8/sxref"), "sxr12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/officeart/2005/8/xldr"), "xldr12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/omml/2004/12/core"), "m12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"), "number")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/package/2005/06/content-types"), "p12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/excel/2005/8/voldeps"), "voldeps12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/excel/2005/8/pivot"), "pt12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://www.w3.org/XML/1998/namespace"), "xml")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/word/2003/wordml"), "w11")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/schemaLibrary/2003/core"), "sl12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/excel/2005/8/styles"), "s12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/data/udc"), "udc")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"), "dr3d")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://www.w3.org/1999/02/22-rdf-syntax-ns#"), "rdf")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/excel/2005/8/supbook"), "sb12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/excel/2005/8/workbook"), "wb12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("#RowsetSchema"), "RowsetSchema")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/excel/2005/8/externalconnection"), "ec12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/excel/2005/8/querytable"), "qt12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:schemas-microsoft-com:office:office"), "o12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"), "s11")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:schemas-microsoft-com:office:excel"), "x11")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:schemas-microsoft-com:office:spreadsheet"), "ss11")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:rtf:1.7"), "rtf")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"), "smil")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/word/2005/8/25/wordml"), "w12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:rtf:schema"), "rtfs")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/excel/2003/xml"), "x2")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/infopath/2003/solutionDefinition"), "ip12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/package/2005/06/relationships"), "rel12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:oasis:names:tc:opendocument:xmlns:config:1.0"), "config")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:oasis:names:tc:opendocument:xmlns:text:1.0"), "text")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/excel/2005/8/table"), "tbl12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"), "pr")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/data/udc/xmlfile"), "udcxf11")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:oasis:names:tc:opendocument:xmlns:office:1.0"), "office")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/excel/2005/8/metadata"), "md12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/powerpoint/2005/8/pml"), "pp12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/visio/2003/core"), "v11")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/excel/2005/8/sst"), "sst12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/excel/2005/8/sharedworkbook"), "swb12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/officeart/2005/8/picture"), "pic12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:schemas-microsoft-com:vml"), "vml")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/activeX/2005/ax"), "ax12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/excel/2005/8/worksheet"), "ws12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/officeart/2005/8/wddr"), "wddr12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/officeart/2005/8/oartml"), "a12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"), "svg")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/onenote/2004/import"), "on12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:oasis:names:tc:opendocument:xmlns:form:1.0"), "form")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("urn:oasis:names:tc:opendocument:xmlns:script:1.0"), "script")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/aml/2001/core"), "aml12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://purl.org/dc/elements/1.1/"), "dc")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/word/2003/auxHint"), "wa11")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/excel/2005/8/sharedworkbookusers"), "swbu12")==0); CPPUNIT_ASSERT(rtl_str_compare(context->getPrefix("http://schemas.microsoft.com/office/2004/7/core"), "c12")==0); } CPPUNIT_TEST_SUITE(TestQName); CPPUNIT_TEST(test); // CPPUNIT_TEST(testperf); CPPUNIT_TEST(testinsert); // CPPUNIT_TEST(testdos); // CPPUNIT_TEST(testperf); CPPUNIT_TEST(test_anium); CPPUNIT_TEST(test_math); CPPUNIT_TEST(test_w10); CPPUNIT_TEST(test_chart); CPPUNIT_TEST(test_sc12); CPPUNIT_TEST(test_odc12); CPPUNIT_TEST(test_c11); CPPUNIT_TEST(test_rng); CPPUNIT_TEST(test_meta); CPPUNIT_TEST(test_udcs); CPPUNIT_TEST(test_xlink); CPPUNIT_TEST(test_style); CPPUNIT_TEST(test_fo); CPPUNIT_TEST(test_xforms); CPPUNIT_TEST(test_draw); CPPUNIT_TEST(test_prj12); CPPUNIT_TEST(test_mdc12); CPPUNIT_TEST(test_table); CPPUNIT_TEST(test_rs11); CPPUNIT_TEST(test_sxr12); CPPUNIT_TEST(test_xldr12); CPPUNIT_TEST(test_m12); CPPUNIT_TEST(test_number); CPPUNIT_TEST(test_p12); CPPUNIT_TEST(test_voldeps12); CPPUNIT_TEST(test_pt12); CPPUNIT_TEST(test_xml); CPPUNIT_TEST(test_w11); CPPUNIT_TEST(test_sl12); CPPUNIT_TEST(test_s12); CPPUNIT_TEST(test_udc); CPPUNIT_TEST(test_dr3d); CPPUNIT_TEST(test_rdf); CPPUNIT_TEST(test_sb12); CPPUNIT_TEST(test_wb12); CPPUNIT_TEST(test_RowsetSchema); CPPUNIT_TEST(test_ec12); CPPUNIT_TEST(test_qt12); CPPUNIT_TEST(test_o12); CPPUNIT_TEST(test_s11); CPPUNIT_TEST(test_x11); CPPUNIT_TEST(test_ss11); CPPUNIT_TEST(test_rtf); CPPUNIT_TEST(test_smil); CPPUNIT_TEST(test_w12); CPPUNIT_TEST(test_rtfs); CPPUNIT_TEST(test_x2); CPPUNIT_TEST(test_ip12); CPPUNIT_TEST(test_rel12); CPPUNIT_TEST(test_NONE); CPPUNIT_TEST(test_config); CPPUNIT_TEST(test_text); CPPUNIT_TEST(test_tbl12); CPPUNIT_TEST(test_pr); CPPUNIT_TEST(test_udcxf11); CPPUNIT_TEST(test_office); CPPUNIT_TEST(test_md12); CPPUNIT_TEST(test_pp12); CPPUNIT_TEST(test_v11); CPPUNIT_TEST(test_sst12); CPPUNIT_TEST(test_swb12); CPPUNIT_TEST(test_pic12); CPPUNIT_TEST(test_vml); CPPUNIT_TEST(test_ax12); CPPUNIT_TEST(test_ws12); CPPUNIT_TEST(test_wddr12); CPPUNIT_TEST(test_a12); CPPUNIT_TEST(test_svg); CPPUNIT_TEST(test_on12); CPPUNIT_TEST(test_form); CPPUNIT_TEST(test_script); CPPUNIT_TEST(test_aml12); CPPUNIT_TEST(test_dc); CPPUNIT_TEST(test_wa11); CPPUNIT_TEST(test_swbu12); CPPUNIT_TEST(test_c12); CPPUNIT_TEST(test_context1); CPPUNIT_TEST(test_context2); CPPUNIT_TEST(test_context3); CPPUNIT_TEST(test_resolver1); CPPUNIT_TEST(test_serializer1); CPPUNIT_TEST(test_serializer2); CPPUNIT_TEST(test_prefix); CPPUNIT_TEST_SUITE_END(); }; //##################################### // register test suites CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(TestQName, "TestQName"); NOADDITIONAL; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */