Skip to main content

Questions tagged [assertions]

Assertions enables you to test your assumptions about your program. For example, if you write a method that calculates the speed of a particle, you might assert that the calculated speed is less than the speed of light.

0 votes
1 answer
272 views

In my experience, it is customary to place local variable declarations at the beginning of their scope. Several questions in this forum ask whether this needs to be so, and their answers tend to agree ...
Severo Raz's user avatar
20 votes
8 answers
9k views

Let's consider the following test. [Fact] public void MyTest() { // Arrange Code var sut = new SystemWeTest(); // Act Code var response = sut.Request(); // Assert ...
BAmadeusJ's user avatar
  • 326
-1 votes
2 answers
1k views

I have a function to be tested fn doNothing(Student student) { //do some other operations here. but student is unmodified return student; } And my unit test is var student = new Student("...
Santhosh Thamaraiselvan's user avatar
6 votes
5 answers
8k views

I'm working in a large company and am doing my first Java project here. We have certain code style guidelines. In the Java guideline, it is said that "assertions are only intended for debugging ...
Green 绿色's user avatar
7 votes
5 answers
2k views

Sometimes when I look at other people's code I see functions that make a bunch of assumptions about the inputs but do not explicitly assert their assumptions. For example, look at the code below: def ...
jss367's user avatar
  • 263
4 votes
4 answers
506 views

I have got a project in C++. Each of my classes has a method void assert_good() const. The usage of that method is solely for debugging purposes: if the object is an inconsistent/impossible internal ...
shuhalo's user avatar
  • 231
7 votes
4 answers
1k views

Let F(x) be a function that calls G(x), in which x must be greater than 0. If G already does assert(x > 0), should F do it as well?
Martel's user avatar
  • 615
1 vote
2 answers
34 views

Imagine a game that needs to score words. A words needs to be scored immediately, in a list of words or even in a list of words from list of players. I've created a scoring module which has the ...
Sven's user avatar
  • 186

15 30 50 per page