assertion

Android - AssertionFailedError on startActivity method in ActivityUnitTestCase test class

微笑、不失礼 提交于 2019-12-03 01:29:19
I am trying to test an activity in a module. I am just trying to start this activity in the test method, but I always have a AssertionFailedError . I searched the web for this issue but could not find any solution. Any help is appreciated. This is my test class: public class ContactActivityTest extends ActivityUnitTestCase<ContactActivity> { public ContactActivityTest() { super(ContactActivity.class); } @Override public void setUp() throws Exception { super.setUp(); } public void testWebViewHasNotSetBuiltInZoomControls() throws Exception { Intent intent = new Intent(getInstrumentation()

Using assertion in the Linux kernel

雨燕双飞 提交于 2019-12-03 01:11:24
I have a question about assert() in Linux: can I use it in the kernel? If no, what techniques do you usually use if, for example I don't want to enter NULL pointer? The corresponding kernel macros are BUG_ON and WARN_ON . The former is for when you want to make the kernel panic and bring the system down (i.e., unrecoverable error). The latter is for when you want to log something to the kernel log (viewable via dmesg ). As @Michael says, in the kernel, you need to validate anything that comes from userspace and just handle it , whatever it is. BUG_ON and WARN_ON are to catch bugs in your own

Getting strange debugger message: Assertion failed: (cls), function getName: what is this?

旧巷老猫 提交于 2019-12-02 18:59:59
Since I upgraded from Xcode 3.2.3 to 3.2.4 and iOS 4.0.1 to iOS 4.1 SDK, when I set a breakpoint in my code and single-step over instructions, at each step, the debugger will spit one or more of that line: Assertion failed: (cls), function getName, file /SourceCache/objc4_Sim/objc4-427.1.1/runtime/objc-runtime-new.m, line 3939 It doesn't happen on a specific line or for a specific instructions. I have a few breakpoints in my code and each time I hit one of those, the debugger starts spewing those messages. It doesn't seem to have any detrimental effect as the program works correctly. It's just

What are contracts (as proposed for C++17)?

谁都会走 提交于 2019-12-02 17:03:10
I was reading about contracts in Thoughts about C++17 by B. Stroustrup and assisted a small presentation talking about them but I am not sure I have understood them really. So I have a some interrogations and if it is possible to illustrate them with some examples : Are contracts just a better replacement of the classic assert() and should they be used together ? What contracts really are put in simple terms for a software dev ? Would contracts have an impact on how we handle exceptions ? If yes, how should we use exceptions and contracts ? Would using contracts imply an overhead at execution

Chai assertion testing whether object structure contains at least other object structure

孤街浪徒 提交于 2019-12-01 05:18:47
I'm using Mocha for unit testing and Chai for assertions. I'd like to find an easy to use solution to check if an object has the structure and properties as defined in my comparison object. But I don't need the objects to be completely equal. The subject under test should contain at least all the properties in my test object, but it might also contain other properties which are not under test at that moment. So, I want to test a unit to check if the object it returns has at least a property named 'foo', which itself is an object that at least contains the property 'bar' with value 10. So, I

assert(false) vs RuntimeException?

巧了我就是萌 提交于 2019-12-01 04:20:53
I'm reading the source of XWalkUIClientInternal and I ran into the following code: switch(type) { case JAVASCRIPT_ALERT: return onJsAlert(view, url, message, result); case JAVASCRIPT_CONFIRM: return onJsConfirm(view, url, message, result); case JAVASCRIPT_PROMPT: return onJsPrompt(view, url, message, defaultValue, result); case JAVASCRIPT_BEFOREUNLOAD: // Reuse onJsConfirm to show the dialog. return onJsConfirm(view, url, message, result); default: break; } assert(false); return false; I've never really seen this technique nor really thought about it before, but I guess this essentially means

Chai assertion testing whether object structure contains at least other object structure

寵の児 提交于 2019-12-01 02:54:22
问题 I'm using Mocha for unit testing and Chai for assertions. I'd like to find an easy to use solution to check if an object has the structure and properties as defined in my comparison object. But I don't need the objects to be completely equal. The subject under test should contain at least all the properties in my test object, but it might also contain other properties which are not under test at that moment. So, I want to test a unit to check if the object it returns has at least a property

How to programmatically test if assertions are enabled?

隐身守侯 提交于 2019-12-01 02:37:13
One of the correct answers from OCP Java SE 6 Programmer Practice Exams is: You can programmatically test wheather assertions have been enabled without throwing an AssertionError . How can I do that? I use this boolean assertOn = false; // *assigns* true if assertions are on. assert assertOn = true; I am not sure this is the "official" way. I guess you should use Class.desiredAssertionStatus() http://docs.oracle.com/javase/6/docs/api/java/lang/Class.html#desiredAssertionStatus() Joe The Oracle Java Tutorial provides information about how to do it... http://docs.oracle.com/javase/7/docs

assert(false) vs RuntimeException?

旧巷老猫 提交于 2019-12-01 01:41:15
问题 I'm reading the source of XWalkUIClientInternal and I ran into the following code: switch(type) { case JAVASCRIPT_ALERT: return onJsAlert(view, url, message, result); case JAVASCRIPT_CONFIRM: return onJsConfirm(view, url, message, result); case JAVASCRIPT_PROMPT: return onJsPrompt(view, url, message, defaultValue, result); case JAVASCRIPT_BEFOREUNLOAD: // Reuse onJsConfirm to show the dialog. return onJsConfirm(view, url, message, result); default: break; } assert(false); return false; I've

CUDA: How to assert in kernel code?

て烟熏妆下的殇ゞ 提交于 2019-11-30 11:13:16
What is the equivalent technique of an assertion in CUDA kernel code? There does not seem to be an assert for CUDA kernel code. I want a way to catch programmer mistakes easily in kernel code. A mechanism where I can set conditions that need to be true and the kernel should bail out when the condition is false with an error message. You won't be able to return an error message or error code to the host from a kernel. Instead, I would set a error state and check it from the host. Use device global memory or (better) mapped host memory for storing an error state, passed as a parameter to each