Home » U++ Library support » U++ Core » Serious bug in String comparison or weird feature?
Serious bug in String comparison or weird feature? [message #14082] |
Sat, 09 February 2008 11:13  |
Werner
Messages: 234 Registered: May 2006 Location: Cologne / Germany
|
Experienced Member |
|
|
If you have 2 U++ strings of different length but apart from that identical, U++ tells you that the smaller string is greater (>) than the bigger one.
This seems wrong to me, and indeed std::string behaves the other way round, namely as expected - at least by me.
Consider for example this small app:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
GUI_APP_MAIN
{
/*
// start of U++ String version
const String a = "AddFrame";
const String b = "AddFrameSize";
String less = a < b ? "true" : "false";
String equal = a == b ? "true" : "false";
String greater = a > b ? "true" : "false";
PromptOK(Format("%s-|<-|%s:-|%s&%s-|==-|%s:-|%s&%s-|>-|%s:-|%s", a, b, less, a, b, equal, a, b, greater));
// end of U++ String version
*/
// start of std::string version
const std::string a = "AddFrame";
const std::string b = "AddFrameSize";
String less = a < b ? "true" : "false";
String equal = a == b ? "true" : "false";
String greater = a > b ? "true" : "false";
String au(a.c_str());
String bu(b.c_str());
PromptOK(Format("%s-|<-|%s:-|%s&%s-|==-|%s:-|%s&%s-|>-|%s:-|%s", au, bu, less, au, bu, equal, au, bu, greater));
// end of std::string version
}
By the way, you can easily fix that by adding a space to either of the U++ Strings.
Werner
[Updated on: Sat, 09 February 2008 11:56] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Mon Apr 28 19:50:07 CEST 2025
Total time taken to generate the page: 0.03981 seconds
|