Issue with testing librairies
-
wrote on 20 Jun 2017, 08:52 last edited by kshegunov
Hello everyone,
After creating a librairy i want to test it in an other console application but as soon as i call a fonction from the librairy the result is an empty console where it is only written press <Entry> to close the window...
I did a small example to test including a librairy and i have no problem doing it.
Where this issue can come from ?
Thank you in advance for any help.
[Moved to General and Desktop ~kshegunov]
-
Hello everyone,
After creating a librairy i want to test it in an other console application but as soon as i call a fonction from the librairy the result is an empty console where it is only written press <Entry> to close the window...
I did a small example to test including a librairy and i have no problem doing it.
Where this issue can come from ?
Thank you in advance for any help.
[Moved to General and Desktop ~kshegunov]
@soufsouf How exactly do you test? It is completely unclear from your description! Does the function from the library which you call print anything?
-
@soufsouf How exactly do you test? It is completely unclear from your description! Does the function from the library which you call print anything?
wrote on 20 Jun 2017, 11:38 last edited byyes i am printing the result of the fonction called.
I built a library called Util: libUtil.a where you have for example this fonction :
int StrToInt(const UtilString& aString)
{
int num = aString.toInt();if(aString.indexOf(".") != -1) { num = RoundToInt(aString.toDouble()); } return num;
}
and when i call this function in the main of the test project (in which i included the Library):
UtilString num1ToStr = IntToStr(num1,true,5);
std::cout << "Le resultat de 'num1ToStr.IntToStr(num1,true)' est: " << num1ToStr.toStdString()<< endl;i have always the console with nothing on it.
In an other hand i did a small example with a fonction that print hello and increase the value of an int by +1 and it works just fine.
thank you in advance for your time.
-
yes i am printing the result of the fonction called.
I built a library called Util: libUtil.a where you have for example this fonction :
int StrToInt(const UtilString& aString)
{
int num = aString.toInt();if(aString.indexOf(".") != -1) { num = RoundToInt(aString.toDouble()); } return num;
}
and when i call this function in the main of the test project (in which i included the Library):
UtilString num1ToStr = IntToStr(num1,true,5);
std::cout << "Le resultat de 'num1ToStr.IntToStr(num1,true)' est: " << num1ToStr.toStdString()<< endl;i have always the console with nothing on it.
In an other hand i did a small example with a fonction that print hello and increase the value of an int by +1 and it works just fine.
thank you in advance for your time.
@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?
-
wrote on 20 Jun 2017, 11:57 last edited by
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();
} -
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?
-
wrote on 20 Jun 2017, 12:13 last edited by
int StrToInt(const UtilString& aString)
{
int num = aString.toInt();
if(aString.indexOf(".") != -1)
{
num = RoundToInt(aString.toDouble());
}
return num;
} -
int StrToInt(const UtilString& aString)
{
int num = aString.toInt();
if(aString.indexOf(".") != -1)
{
num = RoundToInt(aString.toDouble());
}
return num;
}@soufsouf IntToStr not StrToInt
-
wrote on 20 Jun 2017, 12:19 last edited by
@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;
}
-
@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?
-
@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
-
wrote on 20 Jun 2017, 12:50 last edited by
@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.
-
@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().
-
@soufsouf Did you try to debug step-by-step? Put a break point at the first line in IntToStr().
wrote on 20 Jun 2017, 13:30 last edited by@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.
1/15