Add tests for binary literals

This commit is contained in:
Jason Turner
2015-10-03 21:01:52 -06:00
parent e221ceaa4c
commit d2cf12f948
2 changed files with 43 additions and 2 deletions

View File

@@ -650,11 +650,14 @@ namespace chaiscript
const auto val = prefixed?std::string(t_val.begin()+2,t_val.end()):t_val;
// static_assert(sizeof(long) == sizeof(uint64_t) || sizeof(long) * 2 == sizeof(uint64_t), "Unexpected sizing of integer types");
try {
auto u = std::stoll(val,nullptr,base);
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-compare"
#endif
if (!unsigned_ && !long_ && u >= std::numeric_limits<int>::min() && u <= std::numeric_limits<int>::max()) {
return const_var(static_cast<int>(u));
} else if ((unsigned_ || base != 10) && !long_ && u >= std::numeric_limits<unsigned int>::min() && u <= std::numeric_limits<unsigned int>::max()) {
@@ -669,6 +672,11 @@ namespace chaiscript
return const_var(static_cast<unsigned long long>(u));
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
} catch (const std::out_of_range &) {
auto u = std::stoull(val,nullptr,base);