/* This file is part of the KDE project Copyright (C) 2004 David Faure This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include #include #include #include void testSelectItemSet( KoOasisSettings& settings ) { KoOasisSettings::Items items = settings.itemSet( "notexist" ); assert( items.isNull() ); items = settings.itemSet( "view-settings" ); assert( !items.isNull() ); kdDebug() << "testSelectItemSet OK" << endl; } void testParseConfigItemString( KoOasisSettings& settings ) { KoOasisSettings::Items viewSettings = settings.itemSet( "view-settings" ); const TQString unit = viewSettings.parseConfigItemString( "unit" ); tqDebug( "%s", unit.latin1() ); assert( unit == "mm" ); kdDebug() << "testParseConfigItemString OK" << endl; } void testIndexedMap( KoOasisSettings& settings ) { KoOasisSettings::Items viewSettings = settings.itemSet( "view-settings" ); assert( !viewSettings.isNull() ); KoOasisSettings::IndexedMap viewMap = viewSettings.indexedMap( "Views" ); assert( !viewMap.isNull() ); KoOasisSettings::Items firstView = viewMap.entry( 0 ); assert( !firstView.isNull() ); const short zoomFactor = firstView.parseConfigItemShort( "ZoomFactor" ); assert( zoomFactor == 100 ); KoOasisSettings::Items secondView = viewMap.entry( 1 ); assert( secondView.isNull() ); kdDebug() << "testIndexedMap OK" << endl; } void testNamedMap( KoOasisSettings& settings ) { KoOasisSettings::Items viewSettings = settings.itemSet( "view-settings" ); assert( !viewSettings.isNull() ); KoOasisSettings::NamedMap viewMap = viewSettings.namedMap( "NamedMap" ); assert( !viewMap.isNull() ); KoOasisSettings::Items foo = viewMap.entry( "foo" ); assert( !foo.isNull() ); const int zoomFactor = foo.parseConfigItemShort( "ZoomFactor" ); assert( zoomFactor == 100 ); KoOasisSettings::Items secondView = viewMap.entry( "foobar" ); assert( secondView.isNull() ); kdDebug() << "testNamedMap OK" << endl; } int main( int, char** ) { const TQCString xml = "\ \ \ \ \ mm \ \ \ 100 \ \ \ \ \ 100 \ \ \ \ \ \ "; TQDomDocument doc; bool ok = doc.setContent( xml, true /* namespace processing */ ); assert( ok ); KoOasisSettings settings( doc ); testSelectItemSet( settings ); testParseConfigItemString( settings ); testIndexedMap( settings ); testNamedMap( settings ); return 0; }