Unsolved Issue with testing librairies
-
@soufsouf Try to add std::flush:
std::cout << "Le resultat de 'num1ToStr.IntToStr(num1,true)' est: " << num1ToStr.toStdString()<< endl << std::flush;
Also can you show your main function where you call the library function?
-
in my main :
#include "Util.h"
#include <iostream>
using namespace std;int main(int argc, char *argv[])
{QCoreApplication a(argc, argv); int num1=52; UtilString chaine1="toto "; //(UtilString is define in my librairy) std::cout << "La chaine creee par chaine1= toto est:" <<chaine1.toStdString() << endl; //this works just fine UtilString num1ToStr; num1ToStr = IntToStr(num1,true,5); //when i call IntToStr() nothing works anymore even the beginning std::cout << "Le resultat de 'num1ToStr.IntToStr(num1,true)' est: " << num1ToStr.toStdString()<< endl;
return a.exec();
} -
@soufsouf said in Issue with testing librairies:
when i call IntToStr() nothing works anymore even the beginning
Can you show content of IntToStr?
-
int StrToInt(const UtilString& aString)
{
int num = aString.toInt();
if(aString.indexOf(".") != -1)
{
num = RoundToInt(aString.toDouble());
}
return num;
} -
@soufsouf IntToStr not StrToInt
-
@jsulm sorry
UtilString IntToStr(int aValue, bool signPart,int integerPart)
{
UtilString s="";int intpart=abs(aValue); if(signPart) s+=((aValue>=0)?"+":"-"); { UtilString ss; if(integerPart>0) { ss = UtilString("%1").arg(intpart,integerPart); ss.replace(' ','0'); } else { ss = UtilString("%1").arg(intpart); } s+=ss; }
return s;
}
-
@soufsouf If you comment out everything in IntToStr and just return an empty string, does it work then?
-
@jsulm no i already did it (but i did it again) no problem during the compilation but the execution give an empty console without any error message :/
-
@soufsouf It could be toStdString() from your UtilString, you should check it
-
@jsulm if i hide this line: std::cout << "Le resultat de 'num1ToStr.IntToStr(num1,true)' est: " << num1ToStr.toStdString()<< endl; the beginning of the main is not printed in the console because of the IntToStr() call that is why it can't be something related to the printing ! i has been 3 days now that i am dealling with this issue do not know where to search.
-
@soufsouf Did you try to debug step-by-step? Put a break point at the first line in IntToStr().
-
@jsulm I Can not explain why but when you asked me to debug a file in my librairy i changed from release to Debug the compiler of my Library project
And then it worked !!!!
Since my main.cpp to test the project is in Debug mode also i thought you have to be in the same mode in both ( Library and Test ) but when both are in release mode it doesn't work.Whatever thank you for your indications it'a good step.