[1146] | 1 | // ****************************************************************
|
---|
| 2 | // This is free software licensed under the NUnit license. You
|
---|
| 3 | // may obtain a copy of the license as well as information regarding
|
---|
| 4 | // copyright ownership at http://nunit.org/?p=license&r=2.4.
|
---|
| 5 | // ****************************************************************
|
---|
| 6 |
|
---|
| 7 | #include "cppsample.h"
|
---|
| 8 |
|
---|
| 9 | namespace NUnitSamples {
|
---|
| 10 |
|
---|
| 11 | void SimpleCPPSample::Init() {
|
---|
| 12 | fValue1 = 2;
|
---|
| 13 | fValue2 = 3;
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | void SimpleCPPSample::Add() {
|
---|
| 17 | int result = fValue1 + fValue2;
|
---|
| 18 | Assert::AreEqual(6,result);
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | void SimpleCPPSample::DivideByZero()
|
---|
| 22 | {
|
---|
| 23 | int zero= 0;
|
---|
| 24 | int result= 8/zero;
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | void SimpleCPPSample::Equals() {
|
---|
| 28 | Assert::AreEqual(12, 12, "Integer");
|
---|
| 29 | Assert::AreEqual(12L, 12L, "Long");
|
---|
| 30 | Assert::AreEqual('a', 'a', "Char");
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 | Assert::AreEqual(12, 13, "Expected Failure (Integer)");
|
---|
| 34 | Assert::AreEqual(12.0, 11.99, 0.0, "Expected Failure (Double)");
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | void SimpleCPPSample::IgnoredTest()
|
---|
| 38 | {
|
---|
| 39 | throw gcnew InvalidCastException();
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | void SimpleCPPSample::ExpectAnException()
|
---|
| 43 | {
|
---|
| 44 | throw gcnew InvalidCastException();
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | }
|
---|
| 48 |
|
---|