summaryrefslogtreecommitdiffstats
path: root/test/std/utilities/tuple
diff options
context:
space:
mode:
authorStephan T. Lavavej <stl@exchange.microsoft.com>2016-12-08 21:38:32 +0000
committerStephan T. Lavavej <stl@exchange.microsoft.com>2016-12-08 21:38:32 +0000
commit0e8cbce107862187f8f75c1e8b7e49d11015d9f0 (patch)
tree40908baacd22be1c4a5fcf02d2397604ed8c8923 /test/std/utilities/tuple
parent62cd72c4e63e5de9bc50f2cbe458f9613bb6a1c3 (diff)
downloadexternal_libcxx-0e8cbce107862187f8f75c1e8b7e49d11015d9f0.tar.gz
external_libcxx-0e8cbce107862187f8f75c1e8b7e49d11015d9f0.tar.bz2
external_libcxx-0e8cbce107862187f8f75c1e8b7e49d11015d9f0.zip
[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 5/7.
Instead of storing double in double and then truncating to int, store int in long and then widen to long long. This preserves test coverage (as these tests are interested in various tuple conversions) while avoiding truncation warnings. test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp Since we aren't physically truncating anymore, t1 is equal to p0. test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp One edit is different from the usual pattern. Previously, we were storing double in double and then converting to A, which has an implicitly converting constructor from int. Now, we're storing int in int and then converting to A, avoiding the truncation. Fixes D27542. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289109 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/std/utilities/tuple')
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp6
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp26
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp32
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp6
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp4
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp12
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp14
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp34
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp30
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp6
10 files changed, 85 insertions, 85 deletions
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
index a3d14487b..a66fba22d 100644
--- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
@@ -23,9 +23,9 @@
int main()
{
{
- typedef std::pair<double, char> T0;
- typedef std::tuple<int, short> T1;
- T0 t0(2.5, 'a');
+ typedef std::pair<long, char> T0;
+ typedef std::tuple<long long, short> T1;
+ T0 t0(2, 'a');
T1 t1;
t1 = t0;
assert(std::get<0>(t1) == 2);
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
index 91892efaf..85dcee893 100644
--- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
@@ -36,26 +36,26 @@ struct D
int main()
{
{
- typedef std::tuple<double> T0;
- typedef std::tuple<int> T1;
- T0 t0(2.5);
+ typedef std::tuple<long> T0;
+ typedef std::tuple<long long> T1;
+ T0 t0(2);
T1 t1;
t1 = t0;
assert(std::get<0>(t1) == 2);
}
{
- typedef std::tuple<double, char> T0;
- typedef std::tuple<int, int> T1;
- T0 t0(2.5, 'a');
+ typedef std::tuple<long, char> T0;
+ typedef std::tuple<long long, int> T1;
+ T0 t0(2, 'a');
T1 t1;
t1 = t0;
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
}
{
- typedef std::tuple<double, char, D> T0;
- typedef std::tuple<int, int, B> T1;
- T0 t0(2.5, 'a', D(3));
+ typedef std::tuple<long, char, D> T0;
+ typedef std::tuple<long long, int, B> T1;
+ T0 t0(2, 'a', D(3));
T1 t1;
t1 = t0;
assert(std::get<0>(t1) == 2);
@@ -65,10 +65,10 @@ int main()
{
D d(3);
D d2(2);
- typedef std::tuple<double, char, D&> T0;
- typedef std::tuple<int, int, B&> T1;
- T0 t0(2.5, 'a', d2);
- T1 t1(1.5, 'b', d);
+ typedef std::tuple<long, char, D&> T0;
+ typedef std::tuple<long long, int, B&> T1;
+ T0 t0(2, 'a', d2);
+ T1 t1(1, 'b', d);
t1 = t0;
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
index b0754ec2f..1a32acd55 100644
--- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
@@ -47,26 +47,26 @@ struct E {
int main()
{
{
- typedef std::tuple<double> T0;
- typedef std::tuple<int> T1;
- T0 t0(2.5);
+ typedef std::tuple<long> T0;
+ typedef std::tuple<long long> T1;
+ T0 t0(2);
T1 t1;
t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
}
{
- typedef std::tuple<double, char> T0;
- typedef std::tuple<int, int> T1;
- T0 t0(2.5, 'a');
+ typedef std::tuple<long, char> T0;
+ typedef std::tuple<long long, int> T1;
+ T0 t0(2, 'a');
T1 t1;
t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
}
{
- typedef std::tuple<double, char, D> T0;
- typedef std::tuple<int, int, B> T1;
- T0 t0(2.5, 'a', D(3));
+ typedef std::tuple<long, char, D> T0;
+ typedef std::tuple<long long, int, B> T1;
+ T0 t0(2, 'a', D(3));
T1 t1;
t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
@@ -76,19 +76,19 @@ int main()
{
D d(3);
D d2(2);
- typedef std::tuple<double, char, D&> T0;
- typedef std::tuple<int, int, B&> T1;
- T0 t0(2.5, 'a', d2);
- T1 t1(1.5, 'b', d);
+ typedef std::tuple<long, char, D&> T0;
+ typedef std::tuple<long long, int, B&> T1;
+ T0 t0(2, 'a', d2);
+ T1 t1(1, 'b', d);
t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
assert(std::get<2>(t1).id_ == 2);
}
{
- typedef std::tuple<double, char, std::unique_ptr<D>> T0;
- typedef std::tuple<int, int, std::unique_ptr<B>> T1;
- T0 t0(2.5, 'a', std::unique_ptr<D>(new D(3)));
+ typedef std::tuple<long, char, std::unique_ptr<D>> T0;
+ typedef std::tuple<long long, int, std::unique_ptr<B>> T1;
+ T0 t0(2, 'a', std::unique_ptr<D>(new D(3)));
T1 t1;
t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp
index 812e6329b..27656a675 100644
--- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp
@@ -39,9 +39,9 @@ struct D
int main()
{
{
- typedef std::pair<double, std::unique_ptr<D>> T0;
- typedef std::tuple<int, std::unique_ptr<B>> T1;
- T0 t0(2.5, std::unique_ptr<D>(new D(3)));
+ typedef std::pair<long, std::unique_ptr<D>> T0;
+ typedef std::tuple<long long, std::unique_ptr<B>> T1;
+ T0 t0(2, std::unique_ptr<D>(new D(3)));
T1 t1;
t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp
index c59416181..1d0c7b49a 100644
--- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp
@@ -27,8 +27,8 @@
int main()
{
{
- typedef std::pair<double, int> T0;
- typedef std::tuple<int, double> T1;
+ typedef std::pair<long, int> T0;
+ typedef std::tuple<long long, double> T1;
T0 t0(2, 3);
T1 t1(std::allocator_arg, A1<int>(5), t0);
assert(std::get<0>(t1) == 2);
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp
index 36d9f3287..153cd2b3d 100644
--- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp
@@ -37,9 +37,9 @@ struct Implicit {
int main()
{
{
- typedef std::tuple<double> T0;
- typedef std::tuple<int> T1;
- T0 t0(2.5);
+ typedef std::tuple<long> T0;
+ typedef std::tuple<long long> T1;
+ T0 t0(2);
T1 t1(std::allocator_arg, A1<int>(), t0);
assert(std::get<0>(t1) == 2);
}
@@ -65,9 +65,9 @@ int main()
assert(std::get<1>(t1) == 3);
}
{
- typedef std::tuple<double, int, int> T0;
- typedef std::tuple<int, alloc_first, alloc_last> T1;
- T0 t0(1.5, 2, 3);
+ typedef std::tuple<long, int, int> T0;
+ typedef std::tuple<long long, alloc_first, alloc_last> T1;
+ T0 t0(1, 2, 3);
alloc_first::allocator_constructed = false;
alloc_last::allocator_constructed = false;
T1 t1(std::allocator_arg, A1<int>(5), t0);
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp
index de847989a..bed161a3d 100644
--- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp
@@ -24,20 +24,20 @@
int main()
{
{
- typedef std::pair<double, char> T0;
- typedef std::tuple<int, short> T1;
- T0 t0(2.5, 'a');
+ typedef std::pair<long, char> T0;
+ typedef std::tuple<long long, short> T1;
+ T0 t0(2, 'a');
T1 t1 = t0;
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == short('a'));
}
#if TEST_STD_VER > 11
{
- typedef std::pair<double, char> P0;
- typedef std::tuple<int, short> T1;
- constexpr P0 p0(2.5, 'a');
+ typedef std::pair<long, char> P0;
+ typedef std::tuple<long long, short> T1;
+ constexpr P0 p0(2, 'a');
constexpr T1 t1 = p0;
- static_assert(std::get<0>(t1) != std::get<0>(p0), "");
+ static_assert(std::get<0>(t1) == std::get<0>(p0), "");
static_assert(std::get<1>(t1) == std::get<1>(p0), "");
static_assert(std::get<0>(t1) == 2, "");
static_assert(std::get<1>(t1) == short('a'), "");
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
index aa4702b0b..4609b0425 100644
--- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
@@ -68,17 +68,17 @@ struct C
int main()
{
{
- typedef std::tuple<double> T0;
- typedef std::tuple<int> T1;
- T0 t0(2.5);
+ typedef std::tuple<long> T0;
+ typedef std::tuple<long long> T1;
+ T0 t0(2);
T1 t1 = t0;
assert(std::get<0>(t1) == 2);
}
#if TEST_STD_VER > 11
{
- typedef std::tuple<double> T0;
+ typedef std::tuple<int> T0;
typedef std::tuple<A> T1;
- constexpr T0 t0(2.5);
+ constexpr T0 t0(2);
constexpr T1 t1 = t0;
static_assert(std::get<0>(t1) == 2, "");
}
@@ -91,17 +91,17 @@ int main()
}
#endif
{
- typedef std::tuple<double, char> T0;
- typedef std::tuple<int, int> T1;
- T0 t0(2.5, 'a');
+ typedef std::tuple<long, char> T0;
+ typedef std::tuple<long long, int> T1;
+ T0 t0(2, 'a');
T1 t1 = t0;
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
}
{
- typedef std::tuple<double, char, D> T0;
- typedef std::tuple<int, int, B> T1;
- T0 t0(2.5, 'a', D(3));
+ typedef std::tuple<long, char, D> T0;
+ typedef std::tuple<long long, int, B> T1;
+ T0 t0(2, 'a', D(3));
T1 t1 = t0;
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
@@ -109,9 +109,9 @@ int main()
}
{
D d(3);
- typedef std::tuple<double, char, D&> T0;
- typedef std::tuple<int, int, B&> T1;
- T0 t0(2.5, 'a', d);
+ typedef std::tuple<long, char, D&> T0;
+ typedef std::tuple<long long, int, B&> T1;
+ T0 t0(2, 'a', d);
T1 t1 = t0;
d.id_ = 2;
assert(std::get<0>(t1) == 2);
@@ -119,9 +119,9 @@ int main()
assert(std::get<2>(t1).id_ == 2);
}
{
- typedef std::tuple<double, char, int> T0;
- typedef std::tuple<int, int, B> T1;
- T0 t0(2.5, 'a', 3);
+ typedef std::tuple<long, char, int> T0;
+ typedef std::tuple<long long, int, B> T1;
+ T0 t0(2, 'a', 3);
T1 t1(t0);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp
index 8423f5d01..2af86fdd0 100644
--- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp
@@ -48,24 +48,24 @@ struct D
int main()
{
{
- typedef std::tuple<double> T0;
- typedef std::tuple<int> T1;
- T0 t0(2.5);
+ typedef std::tuple<long> T0;
+ typedef std::tuple<long long> T1;
+ T0 t0(2);
T1 t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
}
{
- typedef std::tuple<double, char> T0;
- typedef std::tuple<int, int> T1;
- T0 t0(2.5, 'a');
+ typedef std::tuple<long, char> T0;
+ typedef std::tuple<long long, int> T1;
+ T0 t0(2, 'a');
T1 t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
}
{
- typedef std::tuple<double, char, D> T0;
- typedef std::tuple<int, int, B> T1;
- T0 t0(2.5, 'a', D(3));
+ typedef std::tuple<long, char, D> T0;
+ typedef std::tuple<long long, int, B> T1;
+ T0 t0(2, 'a', D(3));
T1 t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
@@ -73,9 +73,9 @@ int main()
}
{
D d(3);
- typedef std::tuple<double, char, D&> T0;
- typedef std::tuple<int, int, B&> T1;
- T0 t0(2.5, 'a', d);
+ typedef std::tuple<long, char, D&> T0;
+ typedef std::tuple<long long, int, B&> T1;
+ T0 t0(2, 'a', d);
T1 t1 = std::move(t0);
d.id_ = 2;
assert(std::get<0>(t1) == 2);
@@ -83,9 +83,9 @@ int main()
assert(std::get<2>(t1).id_ == 2);
}
{
- typedef std::tuple<double, char, std::unique_ptr<D>> T0;
- typedef std::tuple<int, int, std::unique_ptr<B>> T1;
- T0 t0(2.5, 'a', std::unique_ptr<D>(new D(3)));
+ typedef std::tuple<long, char, std::unique_ptr<D>> T0;
+ typedef std::tuple<long long, int, std::unique_ptr<B>> T1;
+ T0 t0(2, 'a', std::unique_ptr<D>(new D(3)));
T1 t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp
index 2dfbaff6c..13558f3fb 100644
--- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp
+++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp
@@ -38,9 +38,9 @@ struct D
int main()
{
{
- typedef std::pair<double, std::unique_ptr<D>> T0;
- typedef std::tuple<int, std::unique_ptr<B>> T1;
- T0 t0(2.5, std::unique_ptr<D>(new D(3)));
+ typedef std::pair<long, std::unique_ptr<D>> T0;
+ typedef std::tuple<long long, std::unique_ptr<B>> T1;
+ T0 t0(2, std::unique_ptr<D>(new D(3)));
T1 t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1)->id_ == 3);