Export of internal Abseil changes

--
b95862447354428f62ae1627cf526e42ca0b7a9d by Christian Blichmann <cblichmann@google.com>:

Minor cleanups:
* Sorting using declarations
* Changing the format of a NOLINT statement

PiperOrigin-RevId: 348448885

--
954a4375fb09267e55dfda345605b9aca54998b0 by Abseil Team <absl-team@google.com>:

Enable some more Emscripten tests.
Requires setting -s PRINTF_LONG_DOUBLE=1 in a recent build.

PiperOrigin-RevId: 348043610
GitOrigin-RevId: b95862447354428f62ae1627cf526e42ca0b7a9d
Change-Id: I517c94a5fd0feb9b99823dc8552d28fa598723fe
pull/873/head
Abseil Team 4 years ago committed by Derek Mauro
parent 9f8b87b71b
commit 8a9ef3c5da
  1. 2
      README.md
  2. 4
      absl/base/BUILD.bazel
  3. 19
      absl/base/internal/low_level_alloc_test.cc
  4. 4
      absl/random/exponential_distribution_test.cc
  5. 5
      absl/random/gaussian_distribution_test.cc
  6. 5
      absl/random/internal/iostream_state_saver_test.cc
  7. 4
      absl/random/uniform_real_distribution_test.cc
  8. 8
      absl/strings/numbers.h
  9. 4
      absl/strings/numbers_test.cc

@ -80,7 +80,7 @@ Abseil contains the following C++ library components:
* [`numeric`](absl/numeric/)
<br /> The `numeric` library contains C++11-compatible 128-bit integers.
* [`status`](absl/status/)
<br /> The `status` library contains abstractions for error handling, specifically
<br /> The `status` contains abstractions for error handling, specifically
`absl::Status` and `absl::StatusOr<T>`.
* [`strings`](absl/strings/)
<br /> The `strings` library contains a variety of strings routines and

@ -551,7 +551,9 @@ cc_test(
srcs = ["internal/low_level_alloc_test.cc"],
copts = ABSL_TEST_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,
tags = ["no_test_ios_x86_64"],
tags = [
"no_test_ios_x86_64",
],
deps = [
":malloc_internal",
"//absl/container:node_hash_map",

@ -21,6 +21,10 @@
#include <unordered_map>
#include <utility>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
#include "absl/container/node_hash_map.h"
namespace absl {
@ -158,5 +162,20 @@ ABSL_NAMESPACE_END
int main(int argc, char *argv[]) {
// The actual test runs in the global constructor of `before_main`.
printf("PASS\n");
#ifdef __EMSCRIPTEN__
// clang-format off
// This is JS here. Don't try to format it.
MAIN_THREAD_EM_ASM({
if (ENVIRONMENT_IS_WEB) {
if (typeof TEST_FINISH === 'function') {
TEST_FINISH($0);
} else {
console.error('Attempted to exit with status ' + $0);
console.error('But TEST_FINSIHED is not a function.');
}
}
}, 0);
// clang-format on
#endif
return 0;
}

@ -47,11 +47,7 @@ using absl::random_internal::kChiSquared;
template <typename RealType>
class ExponentialDistributionTypedTest : public ::testing::Test {};
#if defined(__EMSCRIPTEN__)
using RealTypes = ::testing::Types<float, double>;
#else
using RealTypes = ::testing::Types<float, double, long double>;
#endif // defined(__EMSCRIPTEN__)
TYPED_TEST_CASE(ExponentialDistributionTypedTest, RealTypes);
TYPED_TEST(ExponentialDistributionTypedTest, SerializeTest) {

@ -130,15 +130,12 @@ TYPED_TEST(GaussianDistributionInterfaceTest, SerializeTest) {
ss >> after;
#if defined(__powerpc64__) || defined(__PPC64__) || defined(__powerpc__) || \
defined(__ppc__) || defined(__PPC__) || defined(__EMSCRIPTEN__)
defined(__ppc__) || defined(__PPC__)
if (std::is_same<TypeParam, long double>::value) {
// Roundtripping floating point values requires sufficient precision
// to reconstruct the exact value. It turns out that long double
// has some errors doing this on ppc, particularly for values
// near {1.0 +/- epsilon}.
//
// Emscripten is even worse, implementing long double as a 128-bit
// type, but shipping with a strtold() that doesn't support that.
if (mean <= std::numeric_limits<double>::max() &&
mean >= std::numeric_limits<double>::lowest()) {
EXPECT_EQ(static_cast<double>(before.mean()),

@ -14,6 +14,9 @@
#include "absl/random/internal/iostream_state_saver.h"
#include <errno.h>
#include <stdio.h>
#include <sstream>
#include <string>
@ -272,7 +275,6 @@ TEST(IOStreamStateSaver, RoundTripDoubles) {
}
}
#if !defined(__EMSCRIPTEN__)
TEST(IOStreamStateSaver, RoundTripLongDoubles) {
// Technically, C++ only guarantees that long double is at least as large as a
// double. Practically it varies from 64-bits to 128-bits.
@ -350,7 +352,6 @@ TEST(IOStreamStateSaver, RoundTripLongDoubles) {
}
}
}
#endif // !defined(__EMSCRIPTEN__)
TEST(StrToDTest, DoubleMin) {
const char kV[] = "2.22507385850720138e-308";

@ -55,11 +55,7 @@ namespace {
template <typename RealType>
class UniformRealDistributionTest : public ::testing::Test {};
#if defined(__EMSCRIPTEN__)
using RealTypes = ::testing::Types<float, double>;
#else
using RealTypes = ::testing::Types<float, double, long double>;
#endif // defined(__EMSCRIPTEN__)
TYPED_TEST_SUITE(UniformRealDistributionTest, RealTypes);

@ -1,4 +1,3 @@
//
// Copyright 2017 The Abseil Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
@ -245,13 +244,6 @@ inline size_t FastHexToBufferZeroPad16(uint64_t val, char* out) {
} // namespace numbers_internal
// SimpleAtoi()
//
// Converts a string to an integer, using `safe_strto?()` functions for actual
// parsing, returning `true` if successful. The `safe_strto?()` functions apply
// strict checking; the string must be a base-10 integer, optionally followed or
// preceded by ASCII whitespace, with a value in the range of the corresponding
// integer type.
template <typename int_type>
ABSL_MUST_USE_RESULT bool SimpleAtoi(absl::string_view str, int_type* out) {
return numbers_internal::safe_strtoi_base(str, out, 10);

@ -46,6 +46,7 @@
namespace {
using absl::SimpleAtoi;
using absl::numbers_internal::kSixDigitsToBufferSize;
using absl::numbers_internal::safe_strto32_base;
using absl::numbers_internal::safe_strto64_base;
@ -55,7 +56,6 @@ using absl::numbers_internal::SixDigitsToBuffer;
using absl::strings_internal::Itoa;
using absl::strings_internal::strtouint32_test_cases;
using absl::strings_internal::strtouint64_test_cases;
using absl::SimpleAtoi;
using testing::Eq;
using testing::MatchesRegex;
@ -380,7 +380,7 @@ TEST(NumbersTest, Atoi) {
VerifySimpleAtoiGood<uint32_t>(42, 42);
VerifySimpleAtoiGood<unsigned int>(42, 42);
VerifySimpleAtoiGood<int64_t>(-42, -42);
VerifySimpleAtoiGood<long>(-42, -42); // NOLINT(runtime/int)
VerifySimpleAtoiGood<long>(-42, -42); // NOLINT: runtime-int
VerifySimpleAtoiGood<uint64_t>(42, 42);
VerifySimpleAtoiGood<size_t>(42, 42);
VerifySimpleAtoiGood<std::string::size_type>(42, 42);

Loading…
Cancel
Save