summaryrefslogtreecommitdiff
path: root/src/tests/testrecordset.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/testrecordset.cpp')
-rw-r--r--src/tests/testrecordset.cpp320
1 files changed, 0 insertions, 320 deletions
diff --git a/src/tests/testrecordset.cpp b/src/tests/testrecordset.cpp
deleted file mode 100644
index df9a7100..00000000
--- a/src/tests/testrecordset.cpp
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * The Mana World Server
- * Copyright 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or any later version.
- *
- * The Mana World 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 The Mana World; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * $Id$
- */
-
-
-#include <sstream>
-
-#include "../utils/logger.h"
-#include "testrecordset.h"
-
-
-// register the fixture into the 'registry'
-CPPUNIT_TEST_SUITE_REGISTRATION(RecordSetTest);
-
-
-using namespace tmwserv::dal;
-
-
-/**
- * Set up fixtures.
- */
-void
-RecordSetTest::setUp(void)
-{
- // populate mNonEmptyRs.
- Row headers;
- headers.push_back("id");
- headers.push_back("name");
- mNonEmptyRs.setColumnHeaders(headers);
-
- Row r1;
- r1.push_back("1");
- r1.push_back("john");
- mNonEmptyRs.add(r1);
-
- Row r2;
- r2.push_back("2");
- r2.push_back("mike");
- mNonEmptyRs.add(r2);
-}
-
-
-/**
- * Tear down fixtures.
- */
-void
-RecordSetTest::tearDown(void)
-{
- // NOOP
-}
-
-
-/**
- * Test RecordSet::rows() on an empty RecordSet.
- */
-void
-RecordSetTest::testRows1(void)
-{
- LOG("RecordSetTest::testRows1()");
-
- CPPUNIT_ASSERT_EQUAL((unsigned int) 0, mEmptyRs.rows());
-}
-
-
-/**
- * Test RecordSet::rows() on a non-empty RecordSet.
- */
-void
-RecordSetTest::testRows2(void)
-{
- LOG("RecordSetTest::testRows2()");
-
- CPPUNIT_ASSERT_EQUAL((unsigned int) 2, mNonEmptyRs.rows());
-}
-
-
-/**
- * Test RecordSet::cols() on an empty RecordSet.
- */
-void
-RecordSetTest::testCols1(void)
-{
- LOG("RecordSetTest::testCols1()");
-
- CPPUNIT_ASSERT_EQUAL((unsigned int) 0, mEmptyRs.cols());
-}
-
-
-/**
- * Test RecordSet::cols() on a non-empty RecordSet.
- */
-void
-RecordSetTest::testCols2(void)
-{
- LOG("RecordSetTest::testCols2()");
-
- CPPUNIT_ASSERT_EQUAL((unsigned int) 2, mNonEmptyRs.cols());
-}
-
-
-/**
- * Call RecordSet::isEmpty() from an empty RecordSet.
- */
-void
-RecordSetTest::testIsEmpty1(void)
-{
- LOG("RecordSetTest::testIsEmpty1()");
-
- CPPUNIT_ASSERT(mEmptyRs.isEmpty());
-}
-
-
-/**
- * Call RecordSet::isEmpty() from a non-empty RecordSet.
- */
-void
-RecordSetTest::testIsEmpty2(void)
-{
- LOG("RecordSetTest::testIsEmpty2()");
-
- CPPUNIT_ASSERT(!mNonEmptyRs.isEmpty());
-}
-
-
-/**
- * Call RecordSet::operator() from an empty RecordSet.
- */
-void
-RecordSetTest::testOperator1(void)
-{
- LOG("RecordSetTest::testOperator1()");
-
- // this should throw std::invalid_argument.
- mEmptyRs(0, 0);
-}
-
-
-/**
- * Call RecordSet::operator() from a non-empty RecordSet with
- * a row index and a column index as parameters.
- */
-void
-RecordSetTest::testOperator2(void)
-{
- LOG("RecordSetTest::testRows1()");
-
- const std::string value("mike");
-
- CPPUNIT_ASSERT_EQUAL(value, mNonEmptyRs(1, 1));
-}
-
-
-/**
- * Call RecordSet::operator() from a non-empty RecordSet with
- * a row index and a column index that are out of range as
- * parameters.
- */
-void
-RecordSetTest::testOperator3(void)
-{
- LOG("RecordSetTest::testOperator3()");
-
- // this should throw std::out_of_range.
- mNonEmptyRs(2, 2);
-}
-
-
-/**
- * Call RecordSet::operator() from a non-empty RecordSet with
- * a row index and a field name as parameters.
- */
-void
-RecordSetTest::testOperator4(void)
-{
- LOG("RecordSetTest::testOperator4()");
-
- const std::string value("1");
-
- CPPUNIT_ASSERT_EQUAL(value, mNonEmptyRs(0, "id"));
-}
-
-
-/**
- * Call RecordSet::operator() from a non-empty RecordSet with
- * a row index that is out of range and a field name as parameters.
- */
-void
-RecordSetTest::testOperator5(void)
-{
- LOG("RecordSetTest::testOperator5()");
-
- // this should throw std::out_of_range.
- mNonEmptyRs(3, "id");
-}
-
-
-/**
- * Call RecordSet::operator() from a non-empty RecordSet with
- * a row index and a field name that does not exist as parameters.
- */
-void
-RecordSetTest::testOperator6(void)
-{
- LOG("RecordSetTest::testOperator6()");
-
- // this should throw std::invalid_argument.
- mNonEmptyRs(1, "noname");
-}
-
-
-/**
- * Test writing an empty RecordSet to an output stream.
- */
-void
-RecordSetTest::testOutputStream1(void)
-{
- LOG("RecordSetTest::testOutputStream1()");
-
- const std::string emptyStr;
-
- std::ostringstream os;
- os << mEmptyRs;
-
- CPPUNIT_ASSERT_EQUAL(emptyStr, os.str());
-}
-
-
-/**
- * Test writing a non-empty RecordSet to an output stream.
- */
-void
-RecordSetTest::testOutputStream2(void)
-{
- LOG("RecordSetTest::testOutputStream2()");
-
- std::ostringstream os1;
- os1 << "|id|name|" << std::endl << std::endl
- << "|1|john|" << std::endl
- << "|2|mike|" << std::endl;
-
- std::ostringstream os2;
- os2 << mNonEmptyRs;
-
- CPPUNIT_ASSERT_EQUAL(os1.str(), os2.str());
-}
-
-
-/**
- * Test RecordSet::add() to add a new now.
- */
-void
-RecordSetTest::testAdd1(void)
-{
- LOG("RecordSetTest::testAdd1()");
-
- const std::string id("3");
- const std::string name("elena");
-
- Row r;
- r.push_back(id);
- r.push_back(name);
- mNonEmptyRs.add(r);
-
- CPPUNIT_ASSERT_EQUAL((unsigned int) 3, mNonEmptyRs.rows());
- CPPUNIT_ASSERT_EQUAL((unsigned int) 2, mNonEmptyRs.cols());
- CPPUNIT_ASSERT_EQUAL(id, mNonEmptyRs(2, 0));
- CPPUNIT_ASSERT_EQUAL(name, mNonEmptyRs(2, 1));
-}
-
-
-/**
- * Test RecordSet::add() to add a new now with a different number
- * of fields.
- */
-void
-RecordSetTest::testAdd2(void)
-{
- LOG("RecordSetTest::testAdd2()");
-
- Row r;
- r.push_back("4");
-
- // this should throw std::invalid_argument.
- mNonEmptyRs.add(r);
-}
-
-
-/**
- * Test RecordSet::add() to add a new now to a RecordSet that does
- * not have column headers.
- */
-void
-RecordSetTest::testAdd3(void)
-{
- LOG("RecordSetTest::testAdd3()");
-
- Row r;
- r.push_back("5");
-
- // this should throw tmw::dal::RsColumnHeadersNotSet.
- mEmptyRs.add(r);
-}