summaryrefslogtreecommitdiffstats
path: root/lib/kofficecore/tests/korecttest.cpp
blob: f9008b670743e34a2f1dcd68df50891edaa7e5e2 (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 <tdeglobal.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");
}