Questions tagged [assertion]

An assertion is a software construct where the developer states ("asserts") a condition that he believes will always be true. If the condition evaluates to false in some languages an exception is thrown, in others a message is printed, and in others the program ceases to operate.

An assertion is a software construct where the developer states ("asserts") a condition that he believes will always be true. If the condition evaluates to false, in some languages an exception is thrown, in others a message is printed, and in still others the program ceases to operate.

Assertions can exist in most high-level languages (C, Java, etc...) as well as in register-transfer-languages (RTL) such as Verilog, System Verilog, and VHDL.

1445 questions
27
votes
2 answers

Any idea how to avoid this assertion in DDTokenCache and what it means?

I am using NSDataDetector with NSTextCheckingTypeLink to search a string for links (e.g. https://stackoverflow.com/questions) within it. Generally, it works fine, but when the string contains certain very long links (200+ chars) followed by a space…
Jim
  • 1,014
  • 1
  • 11
  • 22
27
votes
8 answers

Use CodeCeption assertion in conditional (if) statement

I'm totally new with CodeCeption. I want to do an action/assertion depending on another assertion result, like this: if ($I->see('message')){ $I->click('button_close'); } Is something like that possible? I tried, but doesn't work. Probably…
26
votes
2 answers

Unit test for the 'none' type in Python

How would I go about testing for a function that does not return anything? For example, say I have this function: def is_in(char): my_list = [] my_list.append(char) and then if I were to test it: class TestIsIn(unittest.TestCase): def…
peppy
  • 407
  • 2
  • 7
  • 14
25
votes
6 answers

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

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,…
nemesys
  • 554
  • 5
  • 14
24
votes
8 answers

How to programmatically test if assertions are enabled?

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?
Joe
  • 7,749
  • 19
  • 60
  • 110
23
votes
2 answers

Why Q_ASSERT instead of assert

In Qt there is a Q_ASSERT macro. What's the advantage of using this instead of assert from ?
Zitrax
  • 19,036
  • 20
  • 88
  • 110
22
votes
6 answers

golang type assertion using reflect.Typeof()

I've tried to identify a struct with string value(name). reflect.TypeOf returns Type. But type assertion needs a type. How can I casting Type to type? Or any suggestion to handle it? http://play.golang.org/p/3PJG3YxIyf package main import…
dorajistyle
  • 468
  • 1
  • 5
  • 14
22
votes
10 answers

How to assert that two list contains elements with the same public properties in NUnit?

I want to assert that the elements of two list contains values that I expected, something like: var foundCollection = fooManager.LoadFoo(); var expectedCollection = new List() { new Foo() { Bar = "a", Bar2 = "b" }, new Foo() { Bar =…
Louis Rhys
  • 34,517
  • 56
  • 153
  • 221
20
votes
8 answers

'CityListViewSet' should either include a `serializer_class` attribute, or override the `get_serializer_class()` method

I am assuming by the error in the title, once more here for clarity 'CityListViewSet' should either include a `serializer_class` attribute, or override the `get_serializer_class()` method. that my serializer isn't connected to my view, which in my…
user6781560
20
votes
3 answers

countNonZero function gives an assertion error in openCV

I tried to get horizontal projection using countNonZero() function as below. Mat src = imread(INPUT_FILE, CV_LOAD_IMAGE_COLOR); Mat binaryImage = src.clone(); cvtColor(src, src, CV_BGR2GRAY); Mat horizontal = Mat::zeros(1,binaryImage.cols,…
Samitha Chathuranga
  • 1,689
  • 5
  • 30
  • 57
20
votes
1 answer

Android - AssertionFailedError on startActivity method in ActivityUnitTestCase test class

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…
20
votes
3 answers

Why doesn't Guava have postconditions? What can I use instead?

So, Guava has simple yet useful Preconditions to check method arguments. But I guess it would be reasonable to have a "Postconditions" class too. Or is it just because java provides assertions? Since a class like this doesn't exist, what is the…
Flo
  • 1,367
  • 1
  • 13
  • 27
19
votes
4 answers

xUnit assert two values are equal with some tolerance

I'm trying to compare the precision of two numbers with some tolerance. This is how it was being checked in nUnit: Assert.That(turnOver, Is.EqualTo(turnoverExpected).Within(0.00001).Percent); I'm trying to do the same in xUnit but this is all I've…
nick gowdy
  • 6,191
  • 25
  • 88
  • 157
19
votes
3 answers

Why do we use assert() and assert_options() in PHP?

I am new to using PHP and am learning it by reading the documentation on php.net- currently the page for assert() to know about those assert() and assert_options() functions, but it does not explain why we use them and what these functions do in…
Stack Overflow
  • 1
  • 5
  • 23
  • 51
17
votes
5 answers

How to continue execution when Assertion is failed

I am using Selenium RC using Java with eclipse and TestNG framework. I have the following code snippet: assertTrue(selenium.isTextPresent("Please enter Email ID")); assertTrue(selenium.isTextPresent("Please enter Password")); First assertion was…
Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
1 2
3
96 97