mirror of
https://github.com/hyprwm/hyprutils.git
synced 2024-12-22 10:49:48 +01:00
string: fix isNumber accepting - as valid number
This commit is contained in:
parent
8e10e0626f
commit
ea8fd1d3ea
2 changed files with 2 additions and 1 deletions
|
@ -51,7 +51,7 @@ bool Hyprutils::String::isNumber(const std::string& str, bool allowfloat) {
|
|||
}
|
||||
}
|
||||
|
||||
if (str.back() == '.')
|
||||
if (!isdigit(str.back()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -19,6 +19,7 @@ int main(int argc, char** argv, char** envp) {
|
|||
EXPECT(isNumber("---3423--432s"), false);
|
||||
EXPECT(isNumber("1s"), false);
|
||||
EXPECT(isNumber(""), false);
|
||||
EXPECT(isNumber("-"), false);
|
||||
EXPECT(isNumber("--0"), false);
|
||||
EXPECT(isNumber("abc"), false);
|
||||
EXPECT(isNumber("0.0", true), true);
|
||||
|
|
Loading…
Reference in a new issue