|
When testing in any language, how does everybody phrase their assertion messages ?
I see three obvious ways:
# assume failure assert (4-2) == 2, "Subtracting 2 from 4 doesn't equal 2" # describe success assert (4-2) == 2, "Subtracting 2 from 4 should ...
Started by Daniel Beardsley on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
My code just outputs
Assert Failed: (4-2)==2 : Line 123, File foo.c
If you're lucky... .
In C you can use the preprocessor "stringization" to output the actual condition being tested .
The important thing with an assert is the actual condition being tested .
|
|
I am learning about C# refs right now.
Is it safe to assume that all variables that are assigned with a new are references and not values?
Example:
SomeType variable = new SomeType()
Started by Unknown on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
Looks like you are confusing references with objects....
In C# structs are also instantiated using new(), but are treated as values .
But with any other non-valuetype type and 'ref/out' parameter, they are references .
No, value types are not references.
|
|
If you have an STL vector which has been resized, is it safe to take the address of element 0 and assume the rest of the vector will follow in memory?
e.g.
vector<char> vc(100); // do some stuff with vc vc.resize(200); char* p = &vc[0]; // do stuff...
Started by Ferruccio on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
If you had a pointer, reference, or iterator on element zero (or any element) before a capacity-changing operation... .
It should alway be contiguous
Yes it's contiguous
Storage is always contiguous, but it may move as the vector's capacity is changed .
|
Ask your Facebook Friends
|
I understand that server-side validation is an absolute must to prevent malicious users (or simply users who choose to disable javascript) from bypassing client-side validation. But that's mainly to protect your application, not to provide value for those...
Started by Kevin Pang on
, 24 posts
by 24 people.
Answer Snippets (Read the full thread at stackoverflow):
With that said, you should strive trying to cater to paranoid computer security professionals - assume they might not have JavaScript the site is accessible to those using screen....
It is ok in these days to assume your visitors have JS enabled.
|
|
Do you generally assume that toString() on any given object has a low cost (i.e. for logging)? I do. Is that assumption valid? If it has a high cost should that normally be changed? What are valid reasons to make a toString() method with a high cost? ...
Started by James A. N. Stauffer on
, 18 posts
by 18 people.
Answer Snippets (Read the full thread at stackoverflow):
I think the question....
Why would you do pragmatic answer would be: yes, you always assume a toString() call is cheap, unless you make be, but generally there won't be.
Generally assume that toString() on any given object has a low cost? I do.
|
|
If server has php libcurl enabled, does it have all setopt options available (unless something new was added in new libcurl version and server didn't upgraded, of course) or is it possible for admins to turn off parts of functionality?
I'm especially ...
Started by Phil on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Although the admins can't directly turn....
As far as I'm aware, the admin can't prevent you from defining a specific constant, so you should be safe in that regard .
All you're doing when setting a cURL option is defining a constant within your cURL object .
|
|
Given Java's "write once, run anywhere" paradigm and the fact that the Java tutorials give explicit bit sizes for all the primitive data types without the slightest hint that this is dependent on anything, I would say that, yes, an int is always 32 bit...
Started by Hanno Fietz on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
In the specification, there's also a part that is definitive about representation:
The integral types are byte, short, int, and long, whose values are 8-bit, 16-bit... .
Java code always works as though ints are 32-bit, regardless of the native architecture .
|
|
Is there any way to have to tabcontrol take the size of the largest tab item (well, actually, the tabitem's content)?
Since the tabcontrol has no specific size assigned it should autosize: it does that correctly, but when you switch tabs it automatically...
Started by Inferis on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
You should be able to change the TabControl such that it never destroys its children... .
Therefore it only knows about the size of the content in the currently active tab .
The problem is that the TabControl unloads and reloads its content as you switch tabs .
|
|
I have the following code section, designed to count how many Excel processes are currently open:
Func<int> OpenExcelProcessesCount = () => System.Diagnostics.Process.GetProcessesByName("Excel") .Where(p => !p.HasExited) .Count();
And then...
Started by Mike Rosenblum on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
As I understand it, it's basically saying that if the process you're looking at is running under a different user account, then HasExited can't get the permissions it needs to determine if the process has exited... .
The answer you quote may apply in your case.
|
|
The TransactionScope expects a call to its Complete method as follows. Otherwise the transaction will not be committed.
using(TransactionScope scope = new TransactionScope()) { /* Perform transactional work here */ scope.Complete(); }
Wouldn't an implementation...
Started by Scott Munro on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Committing a transaction.
And assume that unless success was explicitly indicated you would roll it back.
|