From c41149f48d473fd59a63d97ec7bea27918f1ea5c Mon Sep 17 00:00:00 2001 From: reuk Date: Wed, 27 Jan 2021 17:24:34 +0000 Subject: [PATCH] String: Fix documentation for getTrailingIntValue --- modules/juce_core/text/juce_String.cpp | 2 ++ modules/juce_core/text/juce_String.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/juce_core/text/juce_String.cpp b/modules/juce_core/text/juce_String.cpp index a685e6a611..2f1b2aeed0 100644 --- a/modules/juce_core/text/juce_String.cpp +++ b/modules/juce_core/text/juce_String.cpp @@ -2577,6 +2577,8 @@ public: expect (String (std::numeric_limits::max()).getLargeIntValue() == std::numeric_limits::max()); expect (String (std::numeric_limits::min()).getLargeIntValue() == std::numeric_limits::min()); expect (("xyz" + s).getTrailingIntValue() == s.getIntValue()); + expect (String ("xyz-5").getTrailingIntValue() == -5); + expect (String ("-12345").getTrailingIntValue() == -12345); expect (s.getHexValue32() == 0x12345678); expect (s.getHexValue64() == (int64) 0x12345678); expect (String::toHexString (0x1234abcd).equalsIgnoreCase ("1234abcd")); diff --git a/modules/juce_core/text/juce_String.h b/modules/juce_core/text/juce_String.h index b3eb7afec2..9dc3ef96cb 100644 --- a/modules/juce_core/text/juce_String.h +++ b/modules/juce_core/text/juce_String.h @@ -1049,7 +1049,8 @@ public: This will look for a value at the end of the string. e.g. for "321 xyz654" it will return 654; for "2 3 4" it'll return 4. - Negative numbers are not handled, so "xyz-5" returns 5. + If the string ends with a hyphen followed by numeric characters, the + return value will be negative. @see getIntValue */