From cbac30b07bae6c72be5eefd5e47fe83650a16acd Mon Sep 17 00:00:00 2001 From: Hugo Lima Date: Mon, 17 Aug 2009 17:36:11 -0300 Subject: The genesis... --- tests/sphinxtabletest.cpp | 269 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 269 insertions(+) create mode 100644 tests/sphinxtabletest.cpp (limited to 'tests/sphinxtabletest.cpp') diff --git a/tests/sphinxtabletest.cpp b/tests/sphinxtabletest.cpp new file mode 100644 index 000000000..058a3b522 --- /dev/null +++ b/tests/sphinxtabletest.cpp @@ -0,0 +1,269 @@ +/* +* This file is part of the Boost Python Generator project. +* +* Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +* +* Contact: PySide team +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* version 2 as published by the Free Software Foundation. +* +* This program 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 +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA +* +*/ + +#include "sphinxtabletest.h" +#include "docgenerator.h" +#include +#include + +QString SphinxTableTest::transformXml(const char* xml) +{ + return QtXmlToSphinx(m_generator, xml).result(); +} + +void SphinxTableTest::setUp() +{ + m_generator = new DocGenerator; +} + +void SphinxTableTest::tearDown() +{ + delete m_generator; +} + +void SphinxTableTest::testEmptyString() +{ + const char* xml = ""; + QCOMPARE(transformXml(xml), QString()); +} + +void SphinxTableTest::testSimpleTable() +{ + const char* xml = "\ +\ +
\ + \ + Header 1\ + \ + \ + Header 2\ + \ +
\ + \ + \ + 1 1\ + \ + \ + 1 2\ + \ + \ + \ + \ + 2 1\ + \ + \ + 2 2\ + \ + \ +
"; + QCOMPARE(transformXml(xml), QString("\ + +--------+--------+\n\ + |Header 1|Header 2|\n\ + +--------+--------+\n\ + |1 1 |1 2 |\n\ + +--------+--------+\n\ + |2 1 |2 2 |\n\ + +--------+--------+\n\ +\n")); +} + +void SphinxTableTest::testColSpan() +{ + const char* xml = "\ +\ +
\ + \ + Header 1\ + \ + \ + Header 2\ + \ +
\ + \ + \ + I'm a big text!\ + \ + \ + \ + \ + 2 1\ + \ + \ + 2 2\ + \ + \ +
"; + QCOMPARE(transformXml(xml), QString("\ + +---------------+--------+\n\ + |Header 1 |Header 2|\n\ + +---------------+--------+\n\ + |I'm a big text! |\n\ + +---------------+--------+\n\ + |2 1 |2 2 |\n\ + +---------------+--------+\n\ +\n")); +} + + +void SphinxTableTest::testRowSpan() +{ + const char* xml = "\ +\ +
\ + \ + Header 1\ + \ + \ + Header 2\ + \ +
\ + \ + \ + 1.1\ + \ + \ + 1.2\ + \ + \ + \ + \ + 2 2\ + \ + \ +
"; + QCOMPARE(transformXml(xml), QString("\ + +--------+--------+\n\ + |Header 1|Header 2|\n\ + +--------+--------+\n\ + |1.1 |1.2 |\n\ + + +--------+\n\ + | |2 2 |\n\ + +--------+--------+\n\ +\n")); +} + + +void SphinxTableTest::testComplexTable() +{ + const char* xml = "\ +\ +
\ + \ + Header 1\ + \ + \ + Header 2\ + \ + \ + Header 3\ + \ +
\ + \ + \ + 1.1\ + \ + \ + 1.2\ + \ + \ + \ + \ + 2 2\ + \ + \ + 2 3\ + \ + \ +
"; + QCOMPARE(transformXml(xml), QString("\ + +--------+--------+--------+\n\ + |Header 1|Header 2|Header 3|\n\ + +--------+--------+--------+\n\ + |1.1 |1.2 |\n\ + + +--------+--------+\n\ + | |2 2 |2 3 |\n\ + +--------+--------+--------+\n\ +\n")); +} + +void SphinxTableTest::testRowSpan2() +{ + const char* xml = "\ +\ +
\ + h1\ + h2\ + h3\ + h4\ +
\ + \ + A\ + B\ + C\ + D\ + \ + \ + E\ + F\ + \ + \ + E\ + F\ + \ + \ + E\ + F\ + \ + \ + E\ + F\ + \ + \ + E\ + F\ + \ +
"; + QCOMPARE(transformXml(xml), QString("\ + +--+--+--+--+\n\ + |h1|h2|h3|h4|\n\ + +--+--+--+--+\n\ + |A |B |C |D |\n\ + + + +--+--+\n\ + | | |E |F |\n\ + + + +--+--+\n\ + | | |E |F |\n\ + + + +--+--+\n\ + | | |E |F |\n\ + + + +--+--+\n\ + | | |E |F |\n\ + + + +--+--+\n\ + | | |E |F |\n\ + +--+--+--+--+\n\ +\n")); +} + + + +QTEST_APPLESS_MAIN( SphinxTableTest ) + +#include "sphinxtabletest.moc" -- cgit v1.2.3