• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

test/TestCommand.cpp

00001 /*
00002  *   This file is part of the Standard Portable Library (SPL).
00003  *
00004  *   SPL is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   SPL is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with SPL.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 #include <spl/Debug.h>
00018 #include <spl/data/Connection.h>
00019 
00020 #ifdef DEBUG
00021 
00022 #include <spl/Log.h>
00023 
00024 static void _TestCommand1()
00025 {
00026         Command *cmd = new Command("text");
00027         UNIT_ASSERT("command text", cmd->CommandTextGet().Equals("text"));
00028         DEBUG_CLEAR_MEM_CHECK_POINTS();
00029         DEBUG_NOTE_MEM(cmd);
00030         cmd->CheckMem();
00031         DEBUG_DUMP_MEM_LEAKS();
00032         UNIT_ASSERT_MEM_NOTED("Command 1.2");
00033 
00034         delete cmd;
00035         DEBUG_CLEAR_MEM_CHECK_POINTS();
00036         DEBUG_DUMP_MEM_LEAKS();
00037         UNIT_ASSERT_MEM_NOTED("Command 1.2");
00038         Log::SWriteOkFail( "Command 1" );
00039 }
00040 
00041 static void _TestCommand2()
00042 {
00043         Command *cmd = new Command("text");
00044         cmd->CreateParameter("c1", 1);
00045         UNIT_ASSERT("prm count", cmd->ParameterCount() == 1);
00046 
00047         UNIT_ASSERT("command text", cmd->CommandTextGet().Equals("text"));
00048         DEBUG_CLEAR_MEM_CHECK_POINTS();
00049         DEBUG_NOTE_MEM(cmd);
00050         cmd->CheckMem();
00051         DEBUG_DUMP_MEM_LEAKS();
00052         UNIT_ASSERT_MEM_NOTED("Command 2.1");
00053 
00054         UNIT_ASSERT("c1==1", cmd->GetParameter("c1")->GetInt32() == 1 );
00055         UNIT_ASSERT("prm count", cmd->ParameterCount() == 1);
00056 
00057         delete cmd;
00058         DEBUG_CLEAR_MEM_CHECK_POINTS();
00059         DEBUG_DUMP_MEM_LEAKS();
00060         UNIT_ASSERT_MEM_NOTED("Command 2.2");
00061         Log::SWriteOkFail( "Command 2" );
00062 }
00063 
00064 void _TestCommand()
00065 {
00066         _TestCommand1();
00067         DEBUG_CLEAR_MEM_CHECK_POINTS();
00068         DEBUG_DUMP_MEM_LEAKS();
00069 
00070         _TestCommand2();
00071         DEBUG_CLEAR_MEM_CHECK_POINTS();
00072         DEBUG_DUMP_MEM_LEAKS();
00073 }
00074 
00075 #endif