summaryrefslogtreecommitdiffstats
path: root/lib/kofficecore/tests/korecttest.cpp
blob: 8a2455bfb477f1f24cad405db1c69b1bd2b21194 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <KoRect.h>
#include <stdio.h>
#include <tdeapplication.h>
#include <stdlib.h>
#include <kdebug.h>
#include <kglobal.h>

bool check(TQString txt, bool res, bool expected)
{
  if (res == expected) {
    kdDebug() << txt << " : checking '" << res << "' against expected value '" << expected << "'... " << "ok" << endl;
  }
  else {
    kdDebug() << txt << " : checking '" << res << "' against expected value '" << expected << "'... " << "KO !" << endl;
    exit(1);
  }
  return true;
}

bool check(TQString txt, TQString a, TQString b)
{
  if (a.isEmpty())
     a = TQString();
  if (b.isEmpty())
     b = TQString();
  if (a == b) {
    kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl;
  }
  else {
    kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl;
    exit(1);
  }
  return true;
}

int main(int argc, char *argv[])
{
  TDEApplication app(argc,argv,"korecttest",false,false);

  KoRect emptyRect;
  check( "KoRect() is null", emptyRect.isNull(), true );
  check( "KoRect() is empty", emptyRect.isEmpty(), true );
  KoRect rect( 1, 15, 250, 156.14 );
  check( "KoRect(...) is not null", rect.isNull(), false );
  check( "KoRect(...) is not empty", rect.isEmpty(), false );
  KoRect unionRect = rect | emptyRect;
  check( "Union is not null", unionRect.isNull(), false );
  check( "Union is not empty", unionRect.isEmpty(), false );
  kdDebug() << unionRect << endl;

  printf("\nTest OK !\n");
}