summaryrefslogtreecommitdiff
path: root/adb/adb_utils_test.cpp
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2019-02-20 19:46:26 -0800
committerJosh Gao <jmgao@google.com>2019-02-25 13:49:25 -0800
commitaeca208385ba5a8307e1c297548eef0ef1999c6f (patch)
treeb82df75b46cfa7b4ccd29b23037b2a99add9b210 /adb/adb_utils_test.cpp
parent3be9bff5172e14c7cc7953f589d05cdcab95a10f (diff)
adb: make ParseUint reject garbage at the end by default.
Test: adb_test on host Change-Id: Ie63d89bd08f0b296a3d54ff66aae85fe52d8cd0f
Diffstat (limited to 'adb/adb_utils_test.cpp')
-rw-r--r--adb/adb_utils_test.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/adb/adb_utils_test.cpp b/adb/adb_utils_test.cpp
index 8518e17825..bd676c2deb 100644
--- a/adb/adb_utils_test.cpp
+++ b/adb/adb_utils_test.cpp
@@ -206,6 +206,14 @@ void TestParseUint(std::string_view string, bool expected_success, uint32_t expe
EXPECT_EQ(remaining, "foo");
}
}
+
+ // With trailing text, without remaining.
+ {
+ std::string text = std::string(string) + "foo";
+ uint32_t value;
+ bool success = ParseUint(&value, text, nullptr);
+ EXPECT_EQ(success, false);
+ }
}
TEST(adb_utils, ParseUint) {