Zoltan2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
InputTraitsBad.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Zoltan2: A package of combinatorial algorithms for scientific computing
4 //
5 // Copyright 2012 NTESS and the Zoltan2 contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 //
11 // Test for Zoltan2::InputTraitsBad
12 
13 // This should only be used for this test - verifies bad forms do not compile
14 #define Z2_INVERT_STATIC_ASSERT_FOR_UNIT_TESTING
15 
16 #include <Zoltan2_InputTraits.hpp>
17 
19 
20 #define BEGIN_CHECK if( InputTraits<
21 #define END_CHECK >::name() == "unused string" ) \
22  { std::cout << "Unused - Just make sure it compiles." << std::endl; }
23 
24 template< class A, class B, class C >
25 class SomeBadType {
26 public: SomeBadType() {}
27 };
28 
29 int main(int argc, char *argv[])
30 {
31  // makes a general list of 'bad' types - generally just check these all
32  // would fail - the #define above inverts the status of the static_asserts
33  // that means these should all compile but only in this test and nowhere else
34 
35  // scalar ordinal (first slot) must be float, double, int, or long long
36  // this validates we would fail for any
47 
48  // local ordinal (second slot) must always be signed
49  // this validates that we would fail for any unsigned setting
62 
63  // global ordinal (third slot) must be int, long, long long, ssize_t,
64  // unsigned int, unsigned long, unsigned long long, size_t
71 
72  // we also want to make sure that user typedefs will work just fine
73  // lots of redundancy here to make sure std::is_same is working as we think
74  typedef signed int user_int_t;
75  typedef unsigned int user_unsigned_int_t;
76  typedef float user_float_t;
77  typedef double user_double_t;
78  typedef uint32_t user_uint32_t;
79  typedef uint64_t user_uint64_t;
80  typedef signed long user_long_t;
81  typedef unsigned long user_unsigned_long_t;
82  typedef unsigned long long user_unsigned_long_long_t;
83  typedef size_t user_size_t;
84  typedef SomeBadType<int,int, int> user_some_bad_t;
85 
86  // scalar ordinal (first slot) must be float, double, or int
97 
98  // local ordinal (second slot) must always be signed
110 
111  // global ordinal (third slot) must be int, long, long long, ssize_t,
112  // unsigned int, unsigned long, unsigned long long, size_t
117 
118 
119  // some more checks that should all fail - this doesn't check all
120  // combinations but just tries a bunch of things on different class types
123  BEGIN_CHECK Xpetra::CrsMatrix<double, float, long long> END_CHECK
124  BEGIN_CHECK Xpetra::CrsMatrix<float, long, float> END_CHECK
125  BEGIN_CHECK Xpetra::CrsMatrix<float, double, unsigned long> END_CHECK
126  BEGIN_CHECK Xpetra::CrsMatrix<float, unsigned long, double> END_CHECK
127  BEGIN_CHECK Tpetra::CrsMatrix<SomeBadType<int, int, int>, int, long long> END_CHECK
128  BEGIN_CHECK Xpetra::CrsGraph<int, SomeBadType<int, double, float>> END_CHECK
129  BEGIN_CHECK Xpetra::CrsGraph<SomeBadType<int, long long, int>, unsigned int> END_CHECK
130  BEGIN_CHECK Xpetra::CrsGraph<int, double> END_CHECK
131 
132  // set the PASS keyword
133  std::cout << "Validated bad InputTraits - The test PASSED because it "
134  "compiled with the static_assert checks inverted." << std::endl;
135  return 0;
136 }
137 
#define END_CHECK
A simple class that can be the User template argument for an InputAdapter.
int main(int narg, char **arg)
Definition: coloring1.cpp:164
The traits required of User input classes or structures.
#define BEGIN_CHECK
Traits for application input objects.