Re: Assert::IsNotNull or Assert::IsNull do not work for my C++ unit test

"Charlie Poole" <[email protected]>
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <007a01c83243$7acd4650$85c8000a@FERRARI>
Hi Greg,

I think you nailed the source of his problem.

Just as a general comment, the NUnit framework lacks a 
good syntactic layer for C++, which is why one must
often do extra work to coerce arguments, etc.

For NUnit 3.0, I envision a C++ friendly layer on
top of the basic framework.

Charlie 

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf 
> Of Greg Fleming
> Sent: Tuesday, November 27, 2007 12:33 PM
> To: [email protected]
> Subject: Re: [Nunit-users] Assert::IsNotNull or 
> Assert::IsNull do not work for my C++ unit test
> 
> [email protected] wrote:
> 
> > Below is the code snippet. I got "error C2665:
> > 'NUnit::Framework::Assert::IsNotNull' : none of the 3 
> overloads could
> > convert all the argument types      ".What I did wrong?
> >
> > Histogram1D<T>* histoptr = new Histogram1D<T> (64); 
> > Assert::IsNotNull(histo, "Test object."); 
> Assert::IsNull(histo, "Test 
> > object.");
> >   
> 
> "new" in C++ produces pointers on the unmanaged heap, whereas 
> Assert::IsNull expects a managed reference, which is produced 
> by gcnew.  
> Try this (VS 2005; syntax will differ in VS 2003):
> 
> 
> System::Object^ myObj = gcnew System::Object();
> System::Object^ nullObj = nullptr;
> Assert::IsNotNull( myObj, gcnew System::String( "this one 
> should not be 
> null" ) );
> Assert::IsNull( nullObj, gcnew System::String( "this one 
> should be null" 
> ) );
> 
> Histogram1D<T>* histoptr = new Histogram1D<T> (64);
> char* p = null;
> Assert::IsFalse( null == histoptr, gcnew System::String( "new 
> operator 
> should nto return null" ));
> Assert::IsTrue( null == p );
> 
> 
> --------------------------------------------------------------
> -----------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Nunit-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/nunit-users
> 



-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.