FAQ Database Discussion Community


F# NUnit test comes back as not being run

f#,nunit,assert
I am working with VS 2013, F# and NUnit. It is worth noting I am novice with F#. I have added very basic test and when I attach debugger to NUnit and run it in debug mode breakpoint is being hit however test comes back as not being run. NUnit...

Is it possible to check if an interface is activated in pcap?

c++,assert,pcap,libpcap
I am making a basic packet sniffer using pcap.h. While I was unit testing the function that called pcap_dispatch, I gave it non-activated interfaces and invalid interfaces. pcap_dispatch return -3, and as far as the man pages for pcap_dispatch goes, it should only return -2, -1, or more, but never...

How do I disable Java assertions for a junit test in the code

java,junit,assert
How do I disable java assertions (not junit assert) for a junit test in the code Ive written a junit test but when I run it it doesnt fail as expected because assertions are enabled, whereas they are not in production. Is there a way to disable assertions just in...

'assert' function : weird behavior

c++,opencv,assert
I am developping on Windows 7 in C++ with Qt Creator. I also use the library OpenCV I came up against a strange problem with the function assert. I developed a function that makes a linear transformation on an image in order to get a better contrast, with the possibility...

how can I make unconditional assert

c#,assert
I need to have unconditional assert in C#. This is for the case when my code execution gets to the point in the code where it shouldn`t arrive. I want to assert about that. All methods od Assert are conditional. Of course I can do Assert.IsFalse(true) But I am not...

The purpose of Assertation and Assert filter in LogCat how it can be useful and why it is different from Log.e()?

java,android,logcat,assert,android-testing
I'm curious I've never seen in my LogCat any messages marked as Assert. I have read documentation as here and here, but actually I didn't get the purpose of it and how it can be useful? I got that it throws errors, but why it is different with for example...

Expected values in unit tests

c#,assert,unit-testing,object-expected
I am coding some unit tests for a MVC 5 internet application. Should I hard code the expected value in the Assert line of code, or calculate this value from the input values before they have changed. Here is an example: I have a function that subtracts the correct balance...

Using the assert macro while global variables are initialized

c++,c++11,assert,assertion
In the following code, the first assert does not compile because, in MSVC2015RC at least, it is defined essentially as assert(expression) (void)(!!(expression)). int x = 1; assert( x == 1 ); void foo() { assert( x == 1 ); } The error message is C2062 type 'void' unexpected The second...

Assert Failed Expected: Actual:<(null)>

c#,unit-testing,null,assert
So I'm unit testing and I got the above message. I've looked around and cannot find an answer to my problem. I have no idea what this means. Can there be two different kinds of Null? Thanks for the help! //This is invalid input given to the CategoryList constructor. It...

What does System.Diagnostics.Debug.Assert(true) do?

c#,.net,assert
I found the following code in a console application, which seemed a bit strange: System.Diagnostics.Debug.Assert(true); What does it do?...

Why assertEquals and assertSame in junit return the same result for two instances same class?

java,junit,equals,assert
According to documentation assertEquals() Asserts that two objects are equal. assertSame() Asserts that two objects refer to the same object. So I am expecting that if I have a class like below class SomeClass {} then SomeClass someClass1= new SomeClass(); SomeClass someClass2= new SomeClass(); assertSame(someClass1,someClass2); // fail assertEquals(someClass1,someClass2); // fail...

How to assert if the image is zoomed in selenium

java,selenium,selenium-webdriver,assert
Using selenium with java I want to vary whether an image is zoomed when the cursor is moved over the image. From the source code below, element changes: Before zoom: <div class="powatag-zoom powatag-hidden"> After zoom: <div class="powatag-zoom"> Any help to assert the change with working code is welcome....

The file could not be found while using LifecycleCallbacks

php,symfony2,orm,doctrine,assert
I have problem with form validation in symfony2. In my case the $form->isValid() command results in The file could not be found. even though that I provide a file during filling in the form Additionally debuging of setFile function in documents entity leads to conclusion that file value is set...

Guarded function calls in C

c,debugging,assert,specifications
I want to achieve the following: Suppose we have some function foo. We also have two function pre and post that check its precondition and postcondition respectively. We have some foo function calls. Now I want to replace each foo call with a "guarded" call that checks if the conditions...

Java Assertion in Try with multiple catchs

java,exception-handling,assert,assertions
Scenario: class Assert { public static void main(String []args) { try { assert false; } catch (RuntimeException re) { System.out.println("In the handler of RuntimeException"); } catch (Exception e) { System.out.println("In the handler of Exception"); } catch (Error ae) { System.out.println("In the handler of Error"); } catch (Throwable t) { System.out.println("In...

Swift -Ounchecked and Assertions

ios,swift,assert
Preface In Swift, ENABLE_NS_ASSERTIONS is ignored, and whether assertions are on or off is dependent of SWIFT_OPTIMIZATION_LEVEL, see here for more information. assert() is active for -Onone assertionFailure() is active for -Onone precondition() is active for -Onone and -O preconditionFailure() is active for -Onone, -O and -Ounchecked fatalError() is active...

Condition if for Nunit assert

c#,nunit,assert
I need to compare two Lists by NUnit's Assert.AreEqual. If this statement is false (lists not the same) - then I need find elements in lists which not the same. How I can use If statement for know- Assert return true or false?...

assert as a friend class

c++,assert,friend
I can not declare neither assert class, nor assert function as a friendly to my class. Am I right with such a declaration? class Baka { private: friend assert; //invalid friend declaration friend void assert(); //expected an identifer public: } I've already googled a lot, but I can't find right...

C# How I can expect a exception in Assert.AreEqual?

c#,exception,assert
Example: Assert.AreEqual(**null**, Program.nDaysMonth(5, -10), "Error nDaysMonth, Month may -10."); I expect a exception. How I can expect a exception in Assert.AreEqual? Thanks....

chai.assert() wont run methods in a test before the assertion (chai assert lib with protractor)

protractor,assert,chai,e2e-testing
First time I post an issue on SO, I hope I'm doing it right. it (' :: 2.0 service creation :: should fill out service info tab', function(){ createNewService.setServiceName(e2eConfig.newServiceDetails.basicServiceName); createNewService.selectCategory(); createNewService.setIntroText(e2eConfig.newServiceDetails.introText); createNewService.selectParent(); createNewService.uploadIcon(); createNewService.nextTab(); //right now assert will fire off without running the methods above because //we are still on...

Is raising NSInternalInconsistencyException guaranteed to crash by default?

ios,objective-c,assert,nsassert
I use NSAssert to detect unrecoverable conditions in my code. I enabled assertions in release mode as well because if an assertion fails in my code, it's guaranteed to be unrecoverable. NSAssert raises NSInternalInconsistencyException and I've read conflicting posts about NSInternalInconsistencyException being caught by some frameworks and thus not crashing...

Can not catch assert call from native dll in .NET

.net,dll,unmanaged,assert
I am using one function from native .dll in C# code and sometimes the following assert is calling: #include <assert.h> ... assert(e > 0.0); But I can not catch it in my .NET application (it's just crashing). How can I handle this?...

Could not understand java assert mechanism

java,assert
This program is a question in a book of SCJP questions class One { int x = 0; { assert x == 1; } } public class Two { public static void main(String[] args) { int y = 0; assert y == 0; if(args.length > 0) new One(); } }...

Symfony @Assert\Regex preg_ereg

regex,symfony2,assert
I'm trying to validate this: (000 - 001 - 002 ..... 099 ... 100) Use in symfony entity: @Assert\Regex("/^(0[1-9][0-9]|100)$/") This pattern in pcre/php is ok but in the symfony validator it does not work. I've tried to put 007 and form return (invalid input)....

Junit assert something after awaiting and handling an exception

java,junit,exception-handling,mockito,assert
method which throws at first and second call: public void foo() throws Exception test: @test public void testFooThrowsAtFirstAndSecondTime(){ boolean thrown; try { foo(); } catch (Exception e) { thrown = true; } assertTrue(thrown); thrown = false; try { foo(); } catch (Exception e) { thrown = true; } assertTrue(thrown); foo();...

Mocking a method outside of a class

python,unit-testing,mocking,wsgi,assert
I need to write a unit test for credential checking module looks something like below. I apologize I cannot copy the exact code.. but I tried my best to simplify as an example. I want to patch methodA so it returns False as a return value and test MyClass to...

How best to prevent unused variable warnings in custom assert without sizeof?

c++,c++11,lambda,assert,sizeof
Based on advice in http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/ I've been working with my own version of assert (called emp_assert) for a while now. As such, when NDEBUG is set, my assert looks like: #define emp_assert(EXPR) ((void) sizeof(EXPR) ) This definition assures that any variables in EXPR still count as "used" in the compiler,...