Implement s3fs_strtoofft via strtoll

This tightens error checking and aligns s3fs with known good behavior.
This commit is contained in:
Andrew Gaul
2019-07-12 18:52:35 -07:00
parent e936854493
commit 4adcd4a6c8
3 changed files with 18 additions and 38 deletions

View File

@ -79,7 +79,12 @@ void test_strtoofft()
{
ASSERT_EQUALS(s3fs_strtoofft("0"), static_cast<off_t>(0L));
ASSERT_EQUALS(s3fs_strtoofft("9"), static_cast<off_t>(9L));
ASSERT_EQUALS(s3fs_strtoofft("A"), static_cast<off_t>(0L));
try{
s3fs_strtoofft("A");
abort();
}catch(std::exception &e){
// expected
}
ASSERT_EQUALS(s3fs_strtoofft("A", /*is_base_16=*/ true), static_cast<off_t>(10L));
ASSERT_EQUALS(s3fs_strtoofft("F", /*is_base_16=*/ true), static_cast<off_t>(15L));
ASSERT_EQUALS(s3fs_strtoofft("a", /*is_base_16=*/ true), static_cast<off_t>(10L));