1 /*{{{
2     Copyright © 2014-2015 Matthias Kretz <kretz@kde.org>
3 
4     Permission to use, copy, modify, and distribute this software
5     and its documentation for any purpose and without fee is hereby
6     granted, provided that the above copyright notice appear in all
7     copies and that both that the copyright notice and this
8     permission notice and warranty disclaimer appear in supporting
9     documentation, and that the name of the author not be used in
10     advertising or publicity pertaining to distribution of the
11     software without specific, written prior permission.
12 
13     The author disclaim all warranties with regard to this
14     software, including all implied warranties of merchantability
15     and fitness.  In no event shall the author be liable for any
16     special, indirect or consequential damages or any damages
17     whatsoever resulting from loss of use, data or profits, whether
18     in an action of contract, negligence or other tortious action,
19     arising out of or in connection with the use or performance of
20     this software.
21 
22 }}}*/
23 
24 #include "unittest.h"
25 
26 #if defined Vc_GCC && Vc_GCC >= 0x60000
27 #pragma GCC diagnostic ignored "-Wignored-attributes"
28 #endif
29 
30 #define ALL_TYPES concat<AllVectors, SimdArrays<32>>
31 
TEST_TYPES(V,check_EntryType,ALL_TYPES)32 TEST_TYPES(V, check_EntryType, ALL_TYPES)
33 {
34     V v = V();
35     auto scalar = v.sum();
36     static_assert(std::is_same<typename V::EntryType, decltype(scalar)>::value, "");
37     static_assert(std::is_same<typename V::value_type, decltype(scalar)>::value, "");
38 }
39 
TEST_TYPES(V,check_VectorType,AllVectors)40 TEST_TYPES(V, check_VectorType, AllVectors)
41 {
42     V v = V();
43     auto internalData = v.data();
44     static_assert(std::is_same<typename V::VectorType, decltype(internalData)>::value, "");
45     static_assert(std::is_same<typename V::vector_type, decltype(internalData)>::value, "");
46 }
47 
TEST_TYPES(V,check_MaskType,ALL_TYPES)48 TEST_TYPES(V, check_MaskType, ALL_TYPES)
49 {
50     V v = V();
51     auto mask = v == v;
52     static_assert(std::is_same<typename V::MaskType, decltype(mask)>::value, "");
53     static_assert(std::is_same<typename V::mask_type, decltype(mask)>::value, "");
54 }
55 
TEST_TYPES(V,check_IndexType,ALL_TYPES)56 TEST_TYPES(V, check_IndexType, ALL_TYPES)
57 {
58     using IndexType = typename V::IndexType;
59     static_assert(Vc::Traits::isSimdArray<IndexType>::value,
60                   "IndexType is not a SimdArray instance");
61     static_assert(IndexType::Size >= V::Size,
62                   "IndexType does not have the expected minimum size");
63     static_assert(std::is_same<typename IndexType::value_type, int>::value,
64                   "IndexType does not have the expected value_type");
65 }
66 
67 static_assert(!Vc::is_simd_vector<Vc::int64_v>::value, "");
68 
TEST_TYPES(V,checkIntegerType,Vc::int64_v,Vc::uint64_v,Vc::int32_v,Vc::uint32_v,Vc::int16_v,Vc::uint16_v,Vc::int8_v,Vc::uint8_v)69 TEST_TYPES(V, checkIntegerType, Vc::int64_v, Vc::uint64_v, Vc::int32_v, Vc::uint32_v,
70            Vc::int16_v, Vc::uint16_v, Vc::int8_v, Vc::uint8_v)
71 {
72     V v;
73     MEMCOMPARE(v, v);
74 }
75