File: pltestcountedpointer.cpp

package info (click to toggle)
paintlib 2.6.2-14
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 7,920 kB
  • ctags: 3,874
  • sloc: cpp: 25,209; sh: 10,605; ansic: 1,891; makefile: 120
file content (83 lines) | stat: -rw-r--r-- 2,036 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
82
83
/*
/--------------------------------------------------------------------
|
|      $Id: pltestcountedpointer.cpp,v 1.3 2004/09/11 12:41:36 uzadow Exp $
|
|      Copyright (c) 1996-2002 Ulrich von Zadow
|
\--------------------------------------------------------------------
*/

#include "pltestcountedpointer.h"
#include "pltester.h"

#include <iostream>
#include <string>
#include <fstream>

#include "plpaintlibdefs.h"

#include "plcountedpointer.h"

PLTestCountedPointer::PLTestCountedPointer ()
{
}

PLTestCountedPointer::~PLTestCountedPointer ()
{
}

void PLTestCountedPointer::RunTests ()
{
  PLTRACE ("  Testing basic counted pointer...\n");
  int j;
  PLCountedPointer<int> IntPtr(new int(3));
  j = *IntPtr;
  PLASSERT(j==3);
  
  PLCountedPointer<int> IntPtr2(IntPtr);
  PLASSERT(*IntPtr2==3);
  PLASSERT(IntPtr2==IntPtr);
  
  IntPtr = PLCountedPointer<int>(NULL);
  PLASSERT(*IntPtr2==3);
  
  IntPtr2 = PLCountedPointer<int>(new int(4));
  PLASSERT(*IntPtr2!=3);
  
  PLTRACE ("  Testing counted array pointer...\n");
  PLCountedArrayPointer<PLBYTE> ByteArrayPtr(new PLBYTE[5]);
  ByteArrayPtr[0] = 23;
  PLASSERT (ByteArrayPtr[0] == 23);
  PLASSERT (ByteArrayPtr[0] != 24);
  
  PLCountedArrayPointer<PLBYTE> ByteArrayPtr2(ByteArrayPtr);
  PLASSERT(ByteArrayPtr2[0]==23);
  PLASSERT(ByteArrayPtr2==ByteArrayPtr);
  PLASSERT((*ByteArrayPtr2)==23);
  
  ByteArrayPtr = PLCountedArrayPointer<PLBYTE>(NULL);
  PLASSERT(ByteArrayPtr2[0]==23);
  
  ByteArrayPtr2 = PLCountedArrayPointer<PLBYTE>(new PLBYTE[2]);
  PLASSERT(ByteArrayPtr2[0]!=23);
  
}

/*
/--------------------------------------------------------------------
|
|      $Log: pltestcountedpointer.cpp,v $
|      Revision 1.3  2004/09/11 12:41:36  uzadow
|      removed plstdpch.h
|
|      Revision 1.2  2004/09/11 10:30:40  uzadow
|      Linux build fixes, automake dependency fixes.
|
|      Revision 1.1  2003/04/13 20:13:21  uzadow
|      Added counted pointer classes (windows ver.)
|
|
|
\--------------------------------------------------------------------
*/