Commit a4b80604 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Enable a missing test in the CMake build

Summary: This also silences a few warnings in the stl vector tests.

Reviewed By: yfeldblum

Differential Revision: D5350383

fbshipit-source-id: 84df2a7dbfbb23ebb3f15a09f0cb58080b3e06d6
parent b8ac5f35
...@@ -347,6 +347,7 @@ if (BUILD_TESTS) ...@@ -347,6 +347,7 @@ if (BUILD_TESTS)
DIRECTORY futures/test/ DIRECTORY futures/test/
TEST barrier_test SOURCES BarrierTest.cpp TEST barrier_test SOURCES BarrierTest.cpp
TEST callback_lifetime_test SOURCES CallbackLifetimeTest.cpp
TEST collect_test SOURCES CollectTest.cpp TEST collect_test SOURCES CollectTest.cpp
TEST context_test SOURCES ContextTest.cpp TEST context_test SOURCES ContextTest.cpp
TEST core_test SOURCES CoreTest.cpp TEST core_test SOURCES CoreTest.cpp
......
...@@ -185,10 +185,16 @@ THOUGHTS: ...@@ -185,10 +185,16 @@ THOUGHTS:
#include <boost/preprocessor.hpp> #include <boost/preprocessor.hpp>
#include <folly/Conv.h> #include <folly/Conv.h>
#include <folly/Portability.h>
#include <folly/ScopeGuard.h> #include <folly/ScopeGuard.h>
#include <folly/portability/GFlags.h> #include <folly/portability/GFlags.h>
#include <folly/portability/GTest.h> #include <folly/portability/GTest.h>
// We use some pre-processor magic to auto-generate setup and destruct code,
// but it also means we have some parameters that may not be used.
FOLLY_PUSH_WARNING
FOLLY_GCC_DISABLE_WARNING("-Wunused-parameter")
using namespace std; using namespace std;
using namespace folly; using namespace folly;
...@@ -333,23 +339,23 @@ template <> struct D4<true> { ...@@ -333,23 +339,23 @@ template <> struct D4<true> {
}; };
template <Flags f> template <Flags f>
struct Delete : D0<(f & DC_DELETE) != 0> struct Delete : D0<(f & DC_DELETE) != 0>,
, D1<(f & CC_DELETE) != 0> D1<(f & CC_DELETE) != 0>,
, D2<(f & MC_DELETE) != 0> D2<(f & MC_DELETE) != 0>,
, D3<(f & CA_DELETE) != 0> D3<(f & CA_DELETE) != 0>,
, D4<(f & MA_DELETE) != 0> { D4<(f & MA_DELETE) != 0> {
Delete() = default; Delete() = default;
Delete(const Delete&) = default; Delete(const Delete&) = default;
Delete(Delete&&) = default; Delete(Delete&&) = default;
Delete& operator=(const Delete&) = default; Delete& operator=(const Delete&) = default;
Delete& operator=(Delete&&) = default; Delete& operator=(Delete&&) = default;
explicit Delete(std::nullptr_t) explicit Delete(std::nullptr_t) :
: D0<(f & DC_DELETE) != 0>(nullptr) D0<(f & DC_DELETE) != 0>(nullptr),
, D1<(f & CC_DELETE) != 0>(nullptr) D1<(f & CC_DELETE) != 0>(nullptr),
, D2<(f & MC_DELETE) != 0>(nullptr) D2<(f & MC_DELETE) != 0>(nullptr),
, D3<(f & CA_DELETE) != 0>(nullptr) D3<(f & CA_DELETE) != 0>(nullptr),
, D4<(f & MA_DELETE) != 0>(nullptr) D4<(f & MA_DELETE) != 0>(nullptr)
{} {}
}; };
...@@ -365,7 +371,9 @@ struct Ticker { ...@@ -365,7 +371,9 @@ struct Ticker {
static int CountTicks; static int CountTicks;
static int TicksLeft; static int TicksLeft;
static void Tick(const std::string& s) { static void Tick(const std::string& s) {
if (TicksLeft == 0) throw TickException(s); if (TicksLeft == 0) {
throw TickException(s);
}
CountTicks++; CountTicks++;
TicksLeft--; TicksLeft--;
} }
...@@ -377,23 +385,35 @@ int Ticker::TicksLeft = -1; ...@@ -377,23 +385,35 @@ int Ticker::TicksLeft = -1;
template <Flags f> template <Flags f>
struct DataTicker : Ticker { struct DataTicker : Ticker {
DataTicker() noexcept(f & DC_NOEXCEPT) { DataTicker() noexcept(f & DC_NOEXCEPT) {
if (!(f & DC_NOEXCEPT)) Tick("Data()"); if (!(f & DC_NOEXCEPT)) {
Tick("Data()");
}
} }
DataTicker(const DataTicker&) noexcept((f & CC_NOEXCEPT) != 0) { DataTicker(const DataTicker&) noexcept((f & CC_NOEXCEPT) != 0) {
if (!(f & CC_NOEXCEPT)) Tick("Data(const Data&)"); if (!(f & CC_NOEXCEPT)) {
Tick("Data(const Data&)");
}
} }
DataTicker(DataTicker&&) noexcept((f & MC_NOEXCEPT) != 0) { DataTicker(DataTicker&&) noexcept((f & MC_NOEXCEPT) != 0) {
if (!(f & MC_NOEXCEPT)) Tick("Data(Data&&)"); if (!(f & MC_NOEXCEPT)) {
Tick("Data(Data&&)");
}
} }
explicit DataTicker(std::nullptr_t) noexcept((f & OC_NOEXCEPT) != 0) { explicit DataTicker(std::nullptr_t) noexcept((f & OC_NOEXCEPT) != 0) {
if (!(f & OC_NOEXCEPT)) Tick("Data(int)"); if (!(f & OC_NOEXCEPT)) {
Tick("Data(int)");
}
} }
~DataTicker() noexcept {} ~DataTicker() noexcept {}
void operator=(const DataTicker&) noexcept((f & CA_NOEXCEPT) != 0) { void operator=(const DataTicker&) noexcept((f & CA_NOEXCEPT) != 0) {
if (!(f & CA_NOEXCEPT)) Tick("op=(const Data&)"); if (!(f & CA_NOEXCEPT)) {
Tick("op=(const Data&)");
}
} }
void operator=(DataTicker&&) noexcept((f & MA_NOEXCEPT) != 0) { void operator=(DataTicker&&) noexcept((f & MA_NOEXCEPT) != 0) {
if (!(f & MA_NOEXCEPT)) Tick("op=(Data&&)"); if (!(f & MA_NOEXCEPT)) {
Tick("op=(Data&&)");
}
} }
}; };
...@@ -401,16 +421,44 @@ struct DataTicker : Ticker { ...@@ -401,16 +421,44 @@ struct DataTicker : Ticker {
// Operation counter // Operation counter
struct Counter { struct Counter {
static int CountDC, CountCC, CountMC, CountOC, CountCA, CountMA; static int CountDC;
static int CountDestroy, CountTotalOps, CountLoggedConstruction; static int CountCC;
static int CountMC;
Counter() noexcept { CountTotalOps++; CountDC++; } static int CountOC;
Counter(const Counter&) noexcept { CountTotalOps++; CountCC++; } static int CountCA;
Counter(Counter&&) noexcept { CountTotalOps++; CountMC++; } static int CountMA;
explicit Counter(std::nullptr_t) noexcept { CountTotalOps++; CountOC++; } static int CountDestroy;
void operator=(const Counter&) noexcept { CountTotalOps++; CountCA++; } static int CountTotalOps;
void operator=(Counter&&) noexcept { CountTotalOps++; CountMA++; } static int CountLoggedConstruction;
~Counter() noexcept { CountTotalOps++; CountDestroy++; }
Counter() noexcept {
CountTotalOps++;
CountDC++;
}
Counter(const Counter&) noexcept {
CountTotalOps++;
CountCC++;
}
Counter(Counter&&) noexcept {
CountTotalOps++;
CountMC++;
}
explicit Counter(std::nullptr_t) noexcept {
CountTotalOps++;
CountOC++;
}
void operator=(const Counter&) noexcept {
CountTotalOps++;
CountCA++;
}
void operator=(Counter&&) noexcept {
CountTotalOps++;
CountMA++;
}
~Counter() noexcept {
CountTotalOps++;
CountDestroy++;
}
}; };
int Counter::CountDC = 0; int Counter::CountDC = 0;
...@@ -444,33 +492,43 @@ struct DataTracker : Tracker { ...@@ -444,33 +492,43 @@ struct DataTracker : Tracker {
DataTracker() noexcept : Tracker(this, UID++) { DataTracker() noexcept : Tracker(this, UID++) {
UIDCount[uid]++; UIDCount[uid]++;
UIDTotal++; UIDTotal++;
if (!isRelocatable) Locations[self] = uid; if (!isRelocatable) {
Locations[self] = uid;
}
print("Data()"); print("Data()");
} }
DataTracker(const DataTracker& o) noexcept : Tracker(this, o.uid) { DataTracker(const DataTracker& o) noexcept : Tracker(this, o.uid) {
UIDCount[uid]++; UIDCount[uid]++;
UIDTotal++; UIDTotal++;
if (!isRelocatable) Locations[self] = uid; if (!isRelocatable) {
Locations[self] = uid;
}
print("Data(const Data&)"); print("Data(const Data&)");
} }
DataTracker(DataTracker&& o) noexcept : Tracker(this, o.uid) { DataTracker(DataTracker&& o) noexcept : Tracker(this, o.uid) {
UIDCount[uid]++; UIDCount[uid]++;
UIDTotal++; UIDTotal++;
if (!isRelocatable) Locations[self] = uid; if (!isRelocatable) {
Locations[self] = uid;
}
print("Data(Data&&)"); print("Data(Data&&)");
} }
explicit DataTracker(int uid) noexcept : Tracker(this, uid) { explicit DataTracker(int uid) noexcept : Tracker(this, uid) {
UIDCount[uid]++; UIDCount[uid]++;
UIDTotal++; UIDTotal++;
if (!isRelocatable) Locations[self] = uid; if (!isRelocatable) {
Locations[self] = uid;
}
print("Data(int)"); print("Data(int)");
} }
~DataTracker() noexcept { ~DataTracker() noexcept {
UIDCount[uid]--; UIDCount[uid]--;
UIDTotal--; UIDTotal--;
if (!isRelocatable) Locations.erase(self); if (!isRelocatable) {
Locations.erase(self);
}
print("~Data()"); print("~Data()");
uid = 0xdeadbeef; uid = 0xdeadbeef;
self = (DataTracker*)0xfeebdaed; self = (DataTracker*)0xfeebdaed;
...@@ -480,7 +538,9 @@ struct DataTracker : Tracker { ...@@ -480,7 +538,9 @@ struct DataTracker : Tracker {
UIDCount[uid]--; UIDCount[uid]--;
uid = o.uid; uid = o.uid;
UIDCount[uid]++; UIDCount[uid]++;
if (!isRelocatable) Locations[self] = uid; if (!isRelocatable) {
Locations[self] = uid;
}
print("op=(const Data&)"); print("op=(const Data&)");
return *this; return *this;
} }
...@@ -488,7 +548,9 @@ struct DataTracker : Tracker { ...@@ -488,7 +548,9 @@ struct DataTracker : Tracker {
UIDCount[uid]--; UIDCount[uid]--;
uid = o.uid; uid = o.uid;
UIDCount[uid]++; UIDCount[uid]++;
if (!isRelocatable) Locations[self] = uid; if (!isRelocatable) {
Locations[self] = uid;
}
print("op=(Data&&)"); print("op=(Data&&)");
return *this; return *this;
} }
...@@ -496,7 +558,9 @@ struct DataTracker : Tracker { ...@@ -496,7 +558,9 @@ struct DataTracker : Tracker {
void print(const std::string& fun) { void print(const std::string& fun) {
if (Print) { if (Print) {
std::cerr << std::setw(20) << fun << ": uid = " << std::setw(3) << uid; std::cerr << std::setw(20) << fun << ": uid = " << std::setw(3) << uid;
if (!isRelocatable) std::cerr << ", self = " << self; if (!isRelocatable) {
std::cerr << ", self = " << self;
}
std::cerr << std::endl; std::cerr << std::endl;
} }
} }
...@@ -521,10 +585,11 @@ struct Data : DataTracker<(f & IS_RELOCATABLE) != 0>, ...@@ -521,10 +585,11 @@ struct Data : DataTracker<(f & IS_RELOCATABLE) != 0>,
Data() = default; Data() = default;
Data(const Data&) = default; Data(const Data&) = default;
Data(Data&&) = default; Data(Data&&) = default;
/* implicit */ Data(int i) /* implicit */ Data(int i) :
: DataTracker<(f & IS_RELOCATABLE) != 0>(i), Counter() DataTracker<(f & IS_RELOCATABLE) != 0>(i),
, DataTicker<f>(nullptr) Counter(),
, Delete<f>(nullptr) DataTicker<f>(nullptr),
Delete<f>(nullptr)
{} {}
~Data() = default; ~Data() = default;
Data& operator=(const Data&) = default; Data& operator=(const Data&) = default;
...@@ -619,9 +684,13 @@ struct Alloc : AllocTracker, Ticker { ...@@ -619,9 +684,13 @@ struct Alloc : AllocTracker, Ticker {
} }
if (Allocated[p] != n) { if (Allocated[p] != n) {
cerr << "deallocate(" << p << ", " << n << ") invalid: "; cerr << "deallocate(" << p << ", " << n << ") invalid: ";
if (Allocated[p] == 0) cerr << "never allocated"; if (Allocated[p] == 0) {
else if (Allocated[p] == -1) cerr << "already deallocated"; cerr << "never allocated";
else cerr << "wrong number (want " << Allocated[p] << ")"; } else if (Allocated[p] == size_t(-1)) {
cerr << "already deallocated";
} else {
cerr << "wrong number (want " << Allocated[p] << ")";
}
cerr << endl; cerr << endl;
FAIL() << "deallocate failed"; FAIL() << "deallocate failed";
} }
...@@ -829,15 +898,21 @@ uint64_t ReadTSC() { ...@@ -829,15 +898,21 @@ uint64_t ReadTSC() {
template <class Vector> void test_ ## name ## 2 (std::false_type) {} \ template <class Vector> void test_ ## name ## 2 (std::false_type) {} \
template <class Vector> void test_ ## name ## 2 (std::true_type) { \ template <class Vector> void test_ ## name ## 2 (std::true_type) { \
BOOST_PP_SEQ_FOR_EACH(GEN_LOOPER, _, argseq) \ BOOST_PP_SEQ_FOR_EACH(GEN_LOOPER, _, argseq) \
{ SETUP { \
BOOST_PP_SEQ_FOR_EACH(GEN_VMAKER, _, argseq) \
{ \ { \
test_ ## name <Vector, typename Vector::value_type, \ SETUP \
typename Vector::allocator_type> ( __VA_ARGS__ ); \ { \
if (::testing::Test::HasFatalFailure()) return; \ BOOST_PP_SEQ_FOR_EACH(GEN_VMAKER, _, argseq) \
{ \
test_ ## name <Vector, typename Vector::value_type, \
typename Vector::allocator_type> ( __VA_ARGS__ ); \
if (::testing::Test::HasFatalFailure()) { \
return; \
} \
} \
BOOST_PP_SEQ_FOR_EACH(GEN_UMAKER, _, BOOST_PP_SEQ_REVERSE(argseq)) \
} \
TEARDOWN \
} \ } \
BOOST_PP_SEQ_FOR_EACH(GEN_UMAKER, _, BOOST_PP_SEQ_REVERSE(argseq)) \
} TEARDOWN } \
BOOST_PP_SEQ_FOR_EACH(GEN_CLOSER, _, BOOST_PP_SEQ_REVERSE(argseq)) \ BOOST_PP_SEQ_FOR_EACH(GEN_CLOSER, _, BOOST_PP_SEQ_REVERSE(argseq)) \
} \ } \
template <class Vector> void test_ ## name ## 3 () { \ template <class Vector> void test_ ## name ## 3 () { \
...@@ -867,7 +942,9 @@ uint64_t ReadTSC() { ...@@ -867,7 +942,9 @@ uint64_t ReadTSC() {
BOOST_PP_SEQ_FOR_EACH(GEN_TYPE_TEST, name, INTERFACE_TYPES) \ BOOST_PP_SEQ_FOR_EACH(GEN_TYPE_TEST, name, INTERFACE_TYPES) \
bool one = false; \ bool one = false; \
BOOST_PP_SEQ_FOR_EACH(GEN_RUNNABLE_TEST, name, types) \ BOOST_PP_SEQ_FOR_EACH(GEN_RUNNABLE_TEST, name, types) \
if (!one) FAIL() << "No tests qualified to run"; \ if (!one) { \
FAIL() << "No tests qualified to run"; \
} \
} }
#define DECL(name, ...) \ #define DECL(name, ...) \
...@@ -935,9 +1012,15 @@ typedef VECTOR_<DDSMA, Alloc<DDSMA>> _TSpecialMA; ...@@ -935,9 +1012,15 @@ typedef VECTOR_<DDSMA, Alloc<DDSMA>> _TSpecialMA;
template <typename T> template <typename T>
struct PrettyType { struct PrettyType {
string operator()() { string operator()() {
if (is_same<T, int>::value) return "int"; if (is_same<T, int>::value) {
if (is_same<T, char>::value) return "char"; return "int";
if (is_same<T, uint64_t>::value) return "uint64_t"; }
if (is_same<T, char>::value) {
return "char";
}
if (is_same<T, uint64_t>::value) {
return "uint64_t";
}
return typeid(T).name(); return typeid(T).name();
} }
}; };
...@@ -954,11 +1037,21 @@ struct PrettyType<Data<f, pad>> { ...@@ -954,11 +1037,21 @@ struct PrettyType<Data<f, pad>> {
(f & CA_DELETE) || (f & CA_DELETE) ||
(f & MA_DELETE)) { (f & MA_DELETE)) {
tpe << "[^"; tpe << "[^";
if (f & DC_DELETE) tpe << " DC,"; if (f & DC_DELETE) {
if (f & CC_DELETE) tpe << " CC,"; tpe << " DC,";
if (f & MC_DELETE) tpe << " MC,"; }
if (f & CA_DELETE) tpe << " CA,"; if (f & CC_DELETE) {
if (f & MA_DELETE) tpe << " MA,"; tpe << " CC,";
}
if (f & MC_DELETE) {
tpe << " MC,";
}
if (f & CA_DELETE) {
tpe << " CA,";
}
if (f & MA_DELETE) {
tpe << " MA,";
}
tpe << "]"; tpe << "]";
} }
...@@ -968,11 +1061,21 @@ struct PrettyType<Data<f, pad>> { ...@@ -968,11 +1061,21 @@ struct PrettyType<Data<f, pad>> {
(f & CA_NOEXCEPT) || (f & CA_NOEXCEPT) ||
(f & MA_NOEXCEPT)) { (f & MA_NOEXCEPT)) {
tpe << "[safe"; tpe << "[safe";
if (f & DC_NOEXCEPT) tpe << " DC,"; if (f & DC_NOEXCEPT) {
if (f & CC_NOEXCEPT) tpe << " CC,"; tpe << " DC,";
if (f & MC_NOEXCEPT) tpe << " MC,"; }
if (f & CA_NOEXCEPT) tpe << " CA,"; if (f & CC_NOEXCEPT) {
if (f & MA_NOEXCEPT) tpe << " MA,"; tpe << " CC,";
}
if (f & MC_NOEXCEPT) {
tpe << " MC,";
}
if (f & CA_NOEXCEPT) {
tpe << " CA,";
}
if (f & MA_NOEXCEPT) {
tpe << " MA,";
}
tpe << "]"; tpe << "]";
} }
...@@ -1026,7 +1129,9 @@ struct PrettyType<Alloc<T>> { ...@@ -1026,7 +1129,9 @@ struct PrettyType<Alloc<T>> {
#define VMAKER_z std::nullptr_t z = nullptr; #define VMAKER_z std::nullptr_t z = nullptr;
#define UMAKER_z \ #define UMAKER_z \
verify<Vector>(0); \ verify<Vector>(0); \
if (::testing::Test::HasFatalFailure()) return; if (::testing::Test::HasFatalFailure()) { \
return; \
}
#define CLOSER_z #define CLOSER_z
//------ //------
...@@ -1088,7 +1193,7 @@ void populate(Vector& v, const pair<int, int>& ss) { ...@@ -1088,7 +1193,7 @@ void populate(Vector& v, const pair<int, int>& ss) {
v.emplace_back(populateIndex++); v.emplace_back(populateIndex++);
} }
if (ss.second >= 0) { if (ss.second >= 0) {
while (v.capacity() - v.size() != ss.second) { while (v.capacity() - v.size() != size_t(ss.second)) {
v.emplace_back(populateIndex++); v.emplace_back(populateIndex++);
} }
} }
...@@ -1187,26 +1292,26 @@ iterSpotter(Vector& v, int i) { ...@@ -1187,26 +1292,26 @@ iterSpotter(Vector& v, int i) {
switch(i) { switch(i) {
case 1: case 1:
if (v.empty()) ; // fall through if (!v.empty()) {
else {
it = v.begin(); it = v.begin();
++it; ++it;
msg = "a[1]"; msg = "a[1]";
break; break;
} }
FOLLY_FALLTHROUGH;
case 0: case 0:
it = v.begin(); it = v.begin();
msg = "a.begin"; msg = "a.begin";
break; break;
case 2: case 2:
if (v.empty()) ; // fall through if (!v.empty()) {
else {
it = v.end(); it = v.end();
--it; --it;
msg = "a[-1]"; msg = "a[-1]";
break; break;
} }
FOLLY_FALLTHROUGH;
case 3: case 3:
it = v.end(); it = v.end();
msg = "a.end"; msg = "a.end";
...@@ -1285,8 +1390,8 @@ template <class Vector> ...@@ -1285,8 +1390,8 @@ template <class Vector>
void verifyVector(const Vector& v) { void verifyVector(const Vector& v) {
ASSERT_TRUE(v.begin() <= v.end()) << "end is before begin"; ASSERT_TRUE(v.begin() <= v.end()) << "end is before begin";
ASSERT_TRUE(v.empty() == (v.begin() == v.end())) << "empty != (begin == end)"; ASSERT_TRUE(v.empty() == (v.begin() == v.end())) << "empty != (begin == end)";
ASSERT_TRUE(v.size() == distance(v.begin(), v.end())) ASSERT_TRUE(v.size() == size_t(distance(v.begin(), v.end())))
<< "size != end - begin"; << "size != end - begin";
ASSERT_TRUE(v.size() <= v.capacity()) << "size > capacity"; ASSERT_TRUE(v.size() <= v.capacity()) << "size > capacity";
ASSERT_TRUE(v.capacity() <= v.max_size()) << "capacity > max_size"; ASSERT_TRUE(v.capacity() <= v.max_size()) << "capacity > max_size";
ASSERT_TRUE(v.data() || true); // message won't print - it will just crash ASSERT_TRUE(v.data() || true); // message won't print - it will just crash
...@@ -1298,8 +1403,11 @@ void verifyAllocator(int ele, int cap) { ...@@ -1298,8 +1403,11 @@ void verifyAllocator(int ele, int cap) {
ASSERT_EQ(ele, AllocTracker::Constructed - AllocTracker::Destroyed); ASSERT_EQ(ele, AllocTracker::Constructed - AllocTracker::Destroyed);
int tot = 0; int tot = 0;
for (auto kv : AllocTracker::Allocated) for (auto kv : AllocTracker::Allocated) {
if (kv.second != -1) tot += kv.second; if (kv.second != size_t(-1)) {
tot += kv.second;
}
}
ASSERT_EQ(cap, tot) << "the allocator counts " << tot << " space, " ASSERT_EQ(cap, tot) << "the allocator counts " << tot << " space, "
"but the vector(s) have (combined) capacity " << cap; "but the vector(s) have (combined) capacity " << cap;
} }
...@@ -1437,14 +1545,20 @@ Transformer<It, input_iterator_tag> makeInputIterator(const It& it) { ...@@ -1437,14 +1545,20 @@ Transformer<It, input_iterator_tag> makeInputIterator(const It& it) {
// mutate a value (in contract only) // mutate a value (in contract only)
void mutate(int& i) { void mutate(int& i) {
if (false) i = 0; if ((false)) {
i = 0;
}
} }
void mutate(uint64_t& i) { void mutate(uint64_t& i) {
if (false) i = 0; if ((false)) {
i = 0;
}
} }
template <Flags f, size_t pad> template <Flags f, size_t pad>
void mutate(Data<f, pad>& ds) { void mutate(Data<f, pad>& ds) {
if (false) ds.uid = 0; if ((false)) {
ds.uid = 0;
}
} }
//============================================================================= //=============================================================================
...@@ -1637,8 +1751,8 @@ STL_TEST("23.2.1 Table 96.15-18", iterators, is_destructible, a) { ...@@ -1637,8 +1751,8 @@ STL_TEST("23.2.1 Table 96.15-18", iterators, is_destructible, a) {
ASSERT_TRUE(Citb != Cite) << "cbegin == cend when non-empty"; ASSERT_TRUE(Citb != Cite) << "cbegin == cend when non-empty";
} }
auto dist = std::distance( itb, ite); auto dist = size_t(std::distance(itb, ite));
auto Cdist = std::distance(Citb, Cite); auto Cdist = size_t(std::distance(Citb, Cite));
ASSERT_TRUE( dist == ca.size()) << "distance(begin, end) != size"; ASSERT_TRUE( dist == ca.size()) << "distance(begin, end) != size";
ASSERT_TRUE(Cdist == ca.size()) << "distance(cbegin, cend) != size"; ASSERT_TRUE(Cdist == ca.size()) << "distance(cbegin, cend) != size";
} }
...@@ -1804,8 +1918,8 @@ STL_TEST("23.2.1 Table 97.3-5", reversibleIterators, is_destructible, a) { ...@@ -1804,8 +1918,8 @@ STL_TEST("23.2.1 Table 97.3-5", reversibleIterators, is_destructible, a) {
ASSERT_TRUE(Critb != Crite) << "crbegin == crend when non-empty"; ASSERT_TRUE(Critb != Crite) << "crbegin == crend when non-empty";
} }
auto dist = std::distance( ritb, rite); auto dist = size_t(std::distance(ritb, rite));
auto Cdist = std::distance(Critb, Crite); auto Cdist = size_t(std::distance(Critb, Crite));
ASSERT_TRUE( dist == ca.size()) << "distance(rbegin, rend) != size"; ASSERT_TRUE( dist == ca.size()) << "distance(rbegin, rend) != size";
ASSERT_TRUE(Cdist == ca.size()) << "distance(crbegin, crend) != size"; ASSERT_TRUE(Cdist == ca.size()) << "distance(crbegin, crend) != size";
} }
...@@ -2100,7 +2214,7 @@ void insertNTCheck(const Vector& a, DataState<Vector>& dsa, ...@@ -2100,7 +2214,7 @@ void insertNTCheck(const Vector& a, DataState<Vector>& dsa,
for (; i < idx + n; ++i) { for (; i < idx + n; ++i) {
ASSERT_EQ(val, convertToInt(a.data()[i])) << i; ASSERT_EQ(val, convertToInt(a.data()[i])) << i;
} }
for (; i < a.size(); ++i) { for (; size_t(i) < a.size(); ++i) {
ASSERT_EQ(dsa[i-n], convertToInt(a.data()[i])) << i; ASSERT_EQ(dsa[i-n], convertToInt(a.data()[i])) << i;
} }
} }
...@@ -2183,7 +2297,7 @@ void insertItCheck(const Vector& a, DataState<Vector>& dsa, ...@@ -2183,7 +2297,7 @@ void insertItCheck(const Vector& a, DataState<Vector>& dsa,
for (; i < idx + (e - b); ++i) { for (; i < idx + (e - b); ++i) {
ASSERT_EQ(*(b + i - idx), convertToInt(a.data()[i])); ASSERT_EQ(*(b + i - idx), convertToInt(a.data()[i]));
} }
for (; i < a.size(); ++i) { for (; size_t(i) < a.size(); ++i) {
ASSERT_EQ(dsa[i - (e - b)], convertToInt(a.data()[i])); ASSERT_EQ(dsa[i - (e - b)], convertToInt(a.data()[i]));
} }
} }
...@@ -2270,7 +2384,7 @@ STL_TEST("23.2.3 Table 100.10", iteratorInsertIL, ...@@ -2270,7 +2384,7 @@ STL_TEST("23.2.3 Table 100.10", iteratorInsertIL,
template <class Vector> template <class Vector>
void eraseCheck(Vector& a, DataState<Vector>& dsa, int idx, int n) { void eraseCheck(Vector& a, DataState<Vector>& dsa, int idx, int n) {
ASSERT_EQ(dsa.size() - n, a.size()); ASSERT_EQ(dsa.size() - n, a.size());
size_t i = 0; int i = 0;
auto it = a.begin(); auto it = a.begin();
for (; it != a.end(); ++it, ++i) { for (; it != a.end(); ++it, ++i) {
if (i == idx) i += n; if (i == idx) i += n;
...@@ -2511,7 +2625,7 @@ STL_TEST("23.2.3 Table 100.10", popBack, is_destructible, a) { ...@@ -2511,7 +2625,7 @@ STL_TEST("23.2.3 Table 100.10", popBack, is_destructible, a) {
STL_TEST("23.2.3 Table 100.11", operatorBrace, is_destructible, a) { STL_TEST("23.2.3 Table 100.11", operatorBrace, is_destructible, a) {
const auto& ca = a; const auto& ca = a;
for (int i = 0; i < ca.size(); ++i) for (size_t i = 0; i < ca.size(); ++i)
ASSERT_TRUE(addressof(ca[i]) == ca.data()+i); ASSERT_TRUE(addressof(ca[i]) == ca.data()+i);
ASSERT_EQ(0, Counter::CountTotalOps); ASSERT_EQ(0, Counter::CountTotalOps);
...@@ -2523,7 +2637,7 @@ STL_TEST("23.2.3 Table 100.11", operatorBrace, is_destructible, a) { ...@@ -2523,7 +2637,7 @@ STL_TEST("23.2.3 Table 100.11", operatorBrace, is_destructible, a) {
STL_TEST("23.2.3 Table 100.12", at, is_destructible, a) { STL_TEST("23.2.3 Table 100.12", at, is_destructible, a) {
const auto& ca = a; const auto& ca = a;
for (int i = 0; i < ca.size(); ++i) for (size_t i = 0; i < ca.size(); ++i)
ASSERT_TRUE(addressof(ca.at(i)) == ca.data()+i); ASSERT_TRUE(addressof(ca.at(i)) == ca.data()+i);
ASSERT_EQ(0, Counter::CountTotalOps); ASSERT_EQ(0, Counter::CountTotalOps);
...@@ -2579,11 +2693,11 @@ STL_TEST("23.3.6.3", reserve, is_move_constructible, a, n) { ...@@ -2579,11 +2693,11 @@ STL_TEST("23.3.6.3", reserve, is_move_constructible, a, n) {
a.reserve(n); a.reserve(n);
ASSERT_TRUE(am == a.get_allocator()); ASSERT_TRUE(am == a.get_allocator());
if (n <= ocap) { if (size_t(n) <= ocap) {
ASSERT_EQ(0, Counter::CountTotalOps); ASSERT_EQ(0, Counter::CountTotalOps);
ASSERT_TRUE(adata == a.data()); ASSERT_TRUE(adata == a.data());
} else { } else {
ASSERT_TRUE(a.capacity() >= n); ASSERT_TRUE(a.capacity() >= size_t(n));
ASSERT_LE(Counter::CountTotalOps, 2*a.size()); // move and delete ASSERT_LE(Counter::CountTotalOps, 2*a.size()); // move and delete
} }
} }
...@@ -2729,3 +2843,5 @@ int main(int argc, char** argv) { ...@@ -2729,3 +2843,5 @@ int main(int argc, char** argv) {
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }
FOLLY_POP_WARNING
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment