File: igstkStringEventTest.cxx

package info (click to toggle)
igstk 4.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 38,980 kB
  • sloc: cpp: 86,267; xml: 96; makefile: 75; python: 38
file content (81 lines) | stat: -rwxr-xr-x 2,297 bytes parent folder | download | duplicates (2)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*=========================================================================

  Program:   Image Guided Surgery Software Toolkit
  Module:    $RCSfile: igstkStringEventTest.cxx,v $
  Language:  C++
  Date:      $Date: 2008-02-11 01:41:51 $
  Version:   $Revision: 1.7 $

  Copyright (c) ISC  Insight Software Consortium.  All rights reserved.
  See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif

#include "igstkMacros.h"
#include "igstkEvents.h"


int igstkStringEventTest( int , char* [] )
{

  igstk::RealTimeClock::Initialize();


  igstk::StringEvent event;

  std::string message = "if it is not tested, it is broken !";

  event.Set( message );

  std::string message2 = event.Get();

  if( message2 != message )
    {
    std::cerr << "ERROR: inconsistency between SetString() and GetString()" 
              << std::endl;
    std::cerr << "Set = " << message << std::endl;
    std::cerr << "Get = " << message2 << std::endl;
    return EXIT_FAILURE;
    }

  std::string eventName = event.GetEventName();
  std::string expectedName = "StringEvent";
  if( eventName != expectedName )
    {
    std::cerr << "ERROR: in GetEventName() it returned " 
              << eventName << std::endl;
    std::cerr << "The expected name is " << expectedName << std::endl;
    return EXIT_FAILURE;
    }

  if( !event.CheckEvent( &event ) )
    {
    std::cerr << "ERROR: in CheckEvent() it didn't recognized itself" 
              << std::endl;
    return EXIT_FAILURE;
    }

  igstk::StringEvent * newEvent = 
      dynamic_cast< igstk::StringEvent *>( event.MakeObject() );

  if( !newEvent->CheckEvent( &event )   || 
      !event.CheckEvent( newEvent )     || 
      newEvent->GetEventName() != event.GetEventName() )
    {
    std::cerr << "ERROR: MakeObject() did not returned an event \
                 of the expected type" << std::endl;
    return EXIT_FAILURE;
    }

  delete newEvent;

  return EXIT_SUCCESS;
}