assert

Unexplainable NSUndoManager crash / assert in Cocoa app

Hi. I'm having a weird issue, with a Cocoa, OpenGL application I am working on. Whenever I launch my application I am getting the following messages / assertion failure on the console, related to eh NSUndoManager. I am not using the undo manager, by the way. 2010-09-05 03:28:49.184 CocoaCoreTest[51721:a0f] *** Assertion failure in +[NS...

Any reason to use a run-time assert instead of compile-time assert?

While reviewing Visual C++ codebase I found a following strange thing. A run-time assert (which is check the condition and throw an exception if the condition is violated) was used in a case when the condition could be evaluated at compile time: assert( sizeof( SomeType ) == sizeof( SomeOtherType ) ); clearly the compiler will evaluat...

How should I debug-check an assumption that is valid in the future?

Sorry for the weird caption. Here's what I'm going to do: I'm in the client code, calling a method on the server. As a result, the server is going to send certain data to the client. I'd like to validate that these data have arrived within a second, which is necessarily the case unless something went seriously wrong. The code looks like...

Assert vs exception when developing the library

I am developing a library for further usage in other libraries or final products. Let's say a user uses the library in a wrong way - passing an inappropriate value to a public function, calling functions in the wrong order etc. In this case I might throw an exception, but these are usually designed for the final products and must be app...

Add custom messages in assert?

Hello, exists a way to add or edit the message thronw by assert. I'd like to use something like assert(a==b,"A must be equal to B"); Then, the compiler adds line, time and so on.... It is posible? ...

When should assert() be used?

In developing a large C++ programming project with many developers, we have run into issues with inappropriate use of assert() in the code which results in poor quality where the assertion does indeed occur and the product crashes. The question is what are good principles to apply to use assert() appropriately? When is it proper to use...

Preventing catch of NUnit AssertionException?

I'm working on a project at the moment where I need to inter-operate with code that swallows exceptions. In particular, I'm writing NUnit unit tests. There are some places where I want to embed assertions within code that gets passed as a delegate, as part of mocking a particular behavior. The problem I'm having is that the AssertionE...

Example use of assert in Python?

I've read about when to use assert vs. exceptions, but I'm still not "getting it". It seems like whenever I think I'm in a situation where I should use assert, later on in development I find that I'm "looking before I leap" to make sure the assert doesn't fail when I call the function. Since there's another Python idiom about preferrin...

Adding message to assert

Hallo! I'm looking for a way to add custom messages to assert statements. I found this questions http://stackoverflow.com/questions/3692954/add-custom-messages-in-assert but the message is static there. I want to do something like this: assert((0 < x) && (x < 10), std::string("x was ") + myToString(x)); When the assertion fails I wan...

Assert keyword in java

Hi! Do you use this keyword or throw some validation runtime exception? What benefits it gives to you or why you think it's not worth to use? Thanks. ...

What is the safe way to call Debug.Assert from C++ CLI?

This blog does not recommend it: http://blog.kalmbachnet.de/?postid=78 But I want to do it anyway. I suppose I need to wrap my Debug.Assert with some sort of #if or #ifdef or something like that. Also, does anyone have a good example of a Debug.Assert in C++ CLI? Suppose I have the following variable: String^ validationError = bldError...

Unit Testing - How to Compare Two Paged Collections To Assert All Items Different?

Hi Guys, Had a quick look here, couldn't find a duplicate (correct me if im wrong). I've got the following Unit Test for some Paging with LINQ: // Arrange. const int locationId = 1; const LocationType locationType = LocationType.City; int pageSize = 10; // Act. var postsPageOne = PostService.FindAllPostsForLoc...

How to use assert to test for string

I'm currently trying to test a strcat() function that I wrote myself. Instead of printing the outputs and checking them line by line manually, I've decided to use assert from assert.h. The problem is that assert is showing errors even though the outputs look totally fine. The following is my code: void mystrcat_test() { char str[BUF...

Will a child process send SIGCHLD on abort()?

If an application does a fork() and the child dies with an abort() (due to failing an assert()), will the parent process receive a SIGCHLD? If it's relevant this is on Debian 4 (gcc version 4.1.2). ...

PHPUnit: assert two arrays are equal, but order of elements not important

What is a good way to assert that two arrays of objects are equal, when the order of the elements in the array is unimportant, or even subject to change? ...

How c++ assert() can create an infinite loop?

Robot judges suck! I've been accepted by UVA, only after removing the following chunks of code: cin >> ntc; /* extract newline from previous read */ char dummy(0); cin.get(dummy); assert( '\n'==dummy ); /* newline extract completes */ Replacing it with : cin >> ntc; getline( cin, inputN ); /* extract remaining '\n' */ Before replac...

How to make VS Unit Test show the Error Message from exceptions other than UnitTestAssertException?

I'm using VS Unit Testing Framework and Moq. When a Moq verification fails, I'll get a Moq.MockException. In the Test Results window, instead of showing the helpful message inside the exception, it just says "Test method XXX threw exception: ..." Is there a way to tell the VS Unit Test framework always display the message of exceptions...

boost_assert that a parameter class implements a certain method

Hi, Suppose you have a certain template that takes a parameter class template <typename ConnectorClass> struct myClass { } I want to add a BOOST_ASSERT_MSG to validate that ConnectorClass implements a certain method of signature returnType MethodName(param1, param2) How should i write the assert condition in this case? EDIT: si...

Assertion Failed! error

Hi I have a C# web application with a C# ActiveX tool that connects to the user's hardware to collect information. anyways all works fine on most computer except on some it shows me a (sometime on resetting of CAS permissions it works but soon starts throwing a fit) "Assertion failed!" error (See screenshot) new SecurityPermission(P...

Getting more information when an Objective-C exception is raised due to assertion failure

I'm getting an assertion failure from a UIKit function in my iPhone app. The error message looks a bit like this: 2010-10-27 02:31:49.058 MyProgram[114:207] *** Assertion failure in <some random UIKit function>, <location in UIKit source code> The exact error isn't really important, but my problem is just that the message is a bit shor...