|
Hello,
We are running a boost unit test using command line (cmd). The command is:
C:\> /c "D:\MyExecutable.exe" --run_test=testcase1,testcase2,testcase3, --report_format=xml --report_level=detailed --log_format=xml --log_level=all >test_log.xml 2>test_report.xml
The output format is in XML.
I would like to have the call stack for the failed test cases. Is it possible to write the call stack trace in test_report.xml or test_log.xml ?
Is there any macro or Boost API can help me achieve this?
|
|
|
|
|
Hello,
I have observed that in native unit test framework(c++), there is an option to group test cases using attributes which are reflected as traits in the Test Explorer window in MS VS2012.
Following is a an example of the same:
BEGIN_TEST_METHOD_ATTRIBUTE(TestMethod3)
TEST_OWNER(L"SuperMan")
TEST_PRIORITY(2)
TEST_METHOD_ATTRIBUTE(L"Category",L"Slow")
END_TEST_METHOD_ATTRIBUTE()
TEST_METHOD(TestMethod3)
{
Assert::AreEqual(2,6);
}
How can this be achieved via Boost Unit Test Library? Are there macros to achieve the same?
|
|
|
|
|
I have a problem regarding file streams in Qt.
Basically, I read a file using this code:
int LoadSettings(){
QFile* settingsFile = new QFile(storageFileLocation);
if(!settingsFile->open(QIODevice::ReadOnly | QIODevice::Text)){
return SettingsStorage::ErrorReadingFile;
}
QTextStream settingsFileStream(settingsFile);
while(!settingsFileStream.atEnd()){
QString fileLine;
fileLine = settingsFileStream.readLine();
QStringList splittedSettings = fileLine.split(SETTING_NAME_VALUE_SEPARATOR);
int addingStatus = AddSettingIfNotExist(splittedSettings[SETTINGSARRAY_SETTINGNAMEPOS], splittedSettings[SETTINGSARRAY_SETTINGVALUEPOS]);
}
delete(settingsFile);
return SettingsStorage::Ok;
}
AFAIK I have to delete dynamically allocated memory myself. I dynamically allocate the QFile* "settingsFile" and want to delete it as soon as I do not need it anymore. So why do I get a memory access violation message?
I also know that Qt automatically disposes all allocated objects as soon as they derive from the QObject base class, but I want to write to the file later, therefore I have to clean up the allocated memory by myself.
Any help is greatly appreciated.
|
|
|
|
|
Are you sure that the problem is settingsFile? If QObjects really dispose themselves, maybe they assume to be allocated on the heap and give a problem than being allocated on the stack. Have you tried commtenting parts of the code out, especially the loop and the QTextStream?
|
|
|
|
|
Freak30 wrote: Are you sure that the problem is settingsFile?
Yes. And every other dynamically allocated object. I can allocate memory for an object, but not delete it.
Freak30 wrote: Have you tried commtenting parts of the code out, especially the loop and the QTextStream?
Commented out the delete-part and everything was fine. Except that there was a memory leakage.
|
|
|
|
|
Why you are using "delete(settingsFile);" instead of "delete settingsFile;". What does it mean?
I think you should also close settings file before deleting it.
And if the settingsfile->open() fails you will get another memmory leaks, because you are leaving function without deleting settingsfile.
|
|
|
|
|
Newbie00 wrote: What does it mean?
The same this as sizeof(var) and return(result) . Parenthesis are optional.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Certainly looks like the entire code block is suspect to me.
You have something that looks like a file, which is scoped by new/delete. Then that gets used by something else, that looks like a file reader, and the scope of that is the method. Thus it continues to have a reference to the 'file' until the method exits even though you have already deleted it. Either both should be on the heap or neither should be.
And the first has a close method. Which, hopefully the dtor takes care of by certainly I never assume that.
You make a memory allocation and then do an error check and exit - without cleaning up.
|
|
|
|
|
I need to store a structure in a database..but the structure contains another structure..can anybody help me plz
|
|
|
|
|
Are you trying to store all this data in one database field or store its contents in separate fields? Please provide more details.
Use the best guess
|
|
|
|
|
Given that you have two structures, you need something like a foreign key to resolve them when loading them from database.
Given there is structure #1:
struct numberOne{
int childStructId,
int someValue
};
and struct #2:
struct numberTwo{
int id, int anotherValue
};
You need now a database which has two tables, one to store struct #1 and another one for struct #2:
The table for struct #1 has two fields, for the childStructId and onther one for someValue.
The table for struct #2 has also two fields, one for its unique Id and another one for anotherValue.
Afterwards you can load struct #1 from database, and according to the childStructId you can load struct #2 from the database.
I was just guessing what you want, please come back to me if you have further questions.
|
|
|
|
|
sir,
first of all thank u so much for ur reply..
what i need is for example there is a structure
struct example
{
int id;
string name;
struct example2
{
int value;
}
};
now i need to store this structure in a database...as i'm new to database i
dnt have any idea of it...so plz help me...also i'm using sqlite3 database
|
|
|
|
|
Member 7894601 wrote: first of all thank u so much for ur reply..
You're welcome.
Member 7894601 wrote: now i need to store this structure in a database...as i'm new to database i
dnt have any idea of it...so plz help me...also i'm using sqlite3 database
You can find an intro of how to connect to a SQLite database at the SQLite website[^].
The people of the Database forum[^] will help you to find out which tables you will need to create a reliable database.
|
|
|
|
|
You may create two tables where one contains a reference (foreign key) to the other:
TABLE example2
INT id unique ID, usually auto increment
INT value
TABLE example
INT id
VARCHAR name
INT id2 foreign key to access table example2
|
|
|
|
|
but initially how to create a database with two tables using sqlite3
|
|
|
|
|
|
Member 7894601 wrote: can anybody help me plz
The first step is that you need to learn
- How to create a database
- How to create tables
- How to store and retrieve data from a table
None of that has anything to do with your structures, so don't try to do that until you understand the above.
|
|
|
|
|
Sir,
i am nw able to create a database...nw my requirement is how to store the details of files and folders in the database..
|
|
|
|
|
sir,
nw i am able to create a sqlite3 database...but nw i face a problem of storing a variable which is wchar_t...which datatype should i use...plz help me
|
|
|
|
|
I need to send the data to the server in a manner like
00 12 34 00 00 54
when I am doing a strcat of 00 to 1243 or strcat of 1234 to 000054 it's not concatenating 00 to string and the result is 1234 only.
I know strcat treats 00 as a terminating null character that's why it is considering 00 as terminator.I have tried with the memcpy also but then in the server side 00 is coming as 3030.
How can I make my program to treat 00 as the part of the array not as the terminating null character or to treat 00 as it is,not the ascii value as 30.
|
|
|
|
|
If you are sending pure binary data then forget about functions that treat byte sequences as zero terminated strings. Don't use strcat but memcpy should be okay to move bytes here and there if you use it correctly. Along with your binary data you should store the length/size of the data in an int or size_t variable. If you are using C++ you could simply use an std::vector for this job.
class CStorage
{
size_t m_Size;
char m_Bytes[100];
public:
CStorage()
: m_Size(0)
{}
void Append(const char* data, size_t size)
{
memcpy(m_Bytes+m_Size, data, size);
}
};
OR
#include <vector>
#include <iterator>
static const char appendable[] = "abcdefgh";
std::vector<char> bytes;
std::copy(appendable, appendable+sizeof(appendable)/sizeof(appendable[0]), std::back_inserter(bytes));
|
|
|
|
|
You CStorage::Append() should do a m_Size += size; after the memcpy(). 
|
|
|
|
|
Of course. 
|
|
|
|
|
I explained yesterday[^] that you cannot use the string functions for binary data that contains null characters: you must use memcpy() . If the server is receiving 3030 rather than 00 , then it means your sending code is not converting it from characters to binary.
Use the best guess
|
|
|
|
|
Hello,
I need to verify content of my edit control before I let it to loose focus. To do so I wrote my PreTranslateMessage like this:
BOOL CMyFrameWnd::PreTranslateMessage( MSG *pMsg )
{
BOOL bMessageHandled = FALSE;
switch( pMsg->message )
{
case WM_LBUTTONDOWN:
{
if( ::GetFocus == MyEditWnd )
{
if( !IsContentOfMyEditWndOK )
{
ShowMessageBox( "You cannot change value");
}
}
break;
}
}
if( !bMessageHandled )
{
bMessageHandled = CFrameWnd::PreTranslateMessage( pMsg );
}
return bMessageHandled;
}
In order to be able to show modal dialog in PreTranslateMessage and after it forward WM_LBUTTONDOWN I would like to do something like this:
BOOL CMyFrameWnd::PreTranslateMessage( MSG *pMsg )
{
BOOL bMessageHandled = FALSE;
MSG oRememberMsg;
switch( pMsg->message )
{
case WM_LBUTTONDOWN:
{
if( ::GetFocus == MyEditWnd )
{
if( !IsContentOfMyEditWndOK )
{
oRememberMsg = *pMsg;
ShowMessageBox( "You cannot change value");
*pMsg = oRememberMsg;
}
}
break;
}
}
if( !bMessageHandled )
{
bMessageHandled = CFrameWnd::PreTranslateMessage( pMsg );
}
return bMessageHandled;
}
But I am not sure if my code is ok from MFC structural point of view. Can I manipulate with MSG *pMsg parameter as I described above? I tried it and it seems to work, but I don't know... Does it make some side effects? Is something I am missing here? How do you think?
|
|
|
|