|
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 .
|
|
If I have a call procedure on asm:
push ebp mov ebp esp sub ebp, 8
Can I assume right now that both [ebp-4] and [ebp-8] are initialized to zero, or can they have random values?
Started by devoured elysium on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
They will definitely have random values unless ....
To be in a predictable state, always init a register or memory cell with a certain value .
You should never depend on this as this might be depending on the implementation .
They will have random values.
|
|
Is is safe to assume that the hiberfil.sys is always located on the boot volume i.e. %SYSTEMDRIVE% ? Or can it be relocated to another volume, or disk?
Started by Jonas Gulle on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at superuser):
This is what this thread, "....
It's always on the %systemdrive%.
I've never heard of or seen a way to move it and I've looked .
It must be located always on the same drive where Windows reside, ala %systemdrive% (which is not necessary the boot volume) .
|
Ask your Facebook Friends
|
On OS from win 2000 or later (any language) can I assume that this path will always exists? For example I know that on win xp in some languages the "Program Files" directory have a different name. So is it true for the System32 folder?
Thanks. Ohad.
Started by Ohad Horesh on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
One solution cannot assume that: Windows could be installed....
Windows can be installed to a different path.
No, you can't assume that.
I would use if it exists.
I do think it's safe to assume it's in %path% somewhere though.
|
|
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 .
|
|
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.
|
|
When we type in or paste it to a browser's address bar:
http://www.google.com/search?q=%E5%A4%A9
i think there is no way to tell whether the encoding is UTF-8 or any other encoding, so the application will usually assume it is UTF-8. So is it entirely...
Started by Jian Lin on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
RFC 3986 says:
"When a new URI scheme defines a component that represents textual data consisting of characters from the Universal Character Set [UCS], the data should first be encoded... .
They just pass it to PHP or Ruby or whatever .
The servers don't care.
|
|
I'm aware that in C it's best practice to never cast the return value of malloc() . I've read that the compiler assumes that malloc() returns an int if you don't include stdlib.h . Of course it would produce an error if you tried to implicitly assign ...
Started by Kai on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Then, if you really haven't defined it, the linker.
Most compilers I've used only, and it will assume the function returns an int.
Not just malloc) it will assume it is extern and returns an int .
|
|
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.
|