Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous message
Werner is currently offline  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

 
Read Message
Read Message
Previous Topic: What does Vector::GetIndex do?
Next Topic: Date Scan Problem
Goto Forum:
  


Current Time: Sat May 04 20:21:10 CEST 2024

Total time taken to generate the page: 0.02148 seconds