kpilot/lib

testactions.cc

00001 /* testactions          KPilot
00002 **
00003 ** Copyright (C) 2005 by Adriaan de Groot <groot@kde.org)
00004 **
00005 ** Test the functions related to sync actions.
00006 */
00007 
00008 /*
00009 ** This program is free software; you can redistribute it and/or modify
00010 ** it under the terms of the GNU Lesser General Public License as published by
00011 ** the Free Software Foundation; either version 2.1 of the License, or
00012 ** (at your option) any later version.
00013 **
00014 ** This program is distributed in the hope that it will be useful,
00015 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017 ** GNU Lesser General Public License for more details.
00018 **
00019 ** You should have received a copy of the GNU Lesser General Public License
00020 ** along with this program in a file called COPYING; if not, write to
00021 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00022 ** MA 02110-1301, USA.
00023 */
00024 
00025 /*
00026 ** Bug reports and questions can be sent to kde-pim@kde.org
00027 */
00028 
00029 #include "options.h"
00030 #include "syncAction.h"
00031 
00032 bool run_modes(bool test, bool local)
00033 {
00034     bool ok = true;
00035 
00036     kdDebug() << "***\n*** Sync Modes ("
00037         << ( test ? "" : "no")
00038         << "test, "
00039         << ( local ? "" : "no")
00040         << "local)\n***\n";
00041 
00042 
00043     for (int m = (int)SyncAction::SyncMode::eFastSync;
00044         m <= (int) SyncAction::SyncMode::eRestore ;
00045         m++)
00046     {
00047         SyncAction::SyncMode mode((SyncAction::SyncMode::Mode)m,test,local);
00048         kdDebug() << "* " << mode.name() << endl;
00049         SyncAction::SyncMode mode2(mode.list());
00050         if (!(mode==mode2)) {
00051             kdDebug() << "E " << "Modes mismatch [" << mode.name() << "] ["
00052                 << mode2.name() << "]" << endl;
00053             ok = false;
00054         }
00055     }
00056 
00057     return ok;
00058 }
00059 
00060 bool single_mode(int m, bool test, bool local)
00061 {
00062     SyncAction::SyncMode mode((SyncAction::SyncMode::Mode)m,test,local);
00063 
00064     kdDebug() << "* " << m << " " << test << " " << local << endl;
00065 
00066     if ((mode.mode() == m) && (mode.isTest() == test) && (mode.isLocal() == local))
00067     {
00068         return true;
00069     }
00070     else
00071     {
00072         kdDebug() << "E " << "Modes mismatch " << m << " " << test << " " << local
00073             << "[" << mode.name() << "]" << endl;
00074         return false;
00075     }
00076 }
00077 
00078 int main(int argc, char **argv)
00079 {
00080     if (!run_modes(false,false)) return 1;
00081     if (!run_modes(false,true)) return 1;
00082     if (!run_modes(true,false)) return 1;
00083     if (!run_modes(true,true)) return 1;
00084 
00085     kdDebug() << "***\n*** Sync Modes - misc\n***\n";
00086     if (!single_mode(3,false,false)) return 1;
00087     if (!single_mode(1,true,true)) return 1;
00088 
00089     return 0;
00090 }
00091 
00092 
KDE Home | KDE Accessibility Home | Description of Access Keys