File: ExampleTestCase.cpp

package info (click to toggle)
squid3 3.0.PRE5-5%2Betch2
  • links: PTS
  • area: main
  • in suites: etch
  • size: 21,188 kB
  • ctags: 20,388
  • sloc: cpp: 119,851; ansic: 30,259; sh: 10,465; makefile: 3,289; perl: 1,267; awk: 84; xml: 58
file content (50 lines) | stat: -rw-r--r-- 938 bytes parent folder | download | duplicates (3)
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
#include "ExampleTestCase.h"

CPPUNIT_TEST_SUITE_REGISTRATION( ExampleTestCase );

void ExampleTestCase::example ()
{
   CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, 1.1, 0.05);
   CPPUNIT_ASSERT (1 == 0);
   CPPUNIT_ASSERT (1 == 1);
}


void ExampleTestCase::anotherExample ()
{
   CPPUNIT_ASSERT (1 == 2);
}

void ExampleTestCase::setUp ()
{
   m_value1 = 2.0;
   m_value2 = 3.0;
}

void ExampleTestCase::testAdd ()
{
   double result = m_value1 + m_value2;
   CPPUNIT_ASSERT (result == 6.0);
}


void ExampleTestCase::testDivideByZero ()
{
   int	zero	= 0;
   int result	= 8 / zero;
}


void ExampleTestCase::testEquals ()
{
   std::auto_ptr<long>	l1 (new long (12));
   std::auto_ptr<long>	l2 (new long (12));
   
   CPPUNIT_ASSERT_EQUAL (12, 12);
   CPPUNIT_ASSERT_EQUAL (12L, 12L);
   CPPUNIT_ASSERT_EQUAL (*l1, *l2);
   
   CPPUNIT_ASSERT (12L == 12L);
   CPPUNIT_ASSERT_EQUAL (12, 13);
   CPPUNIT_ASSERT_DOUBLES_EQUAL (12.0, 11.99, 0.5);
}