From 2f4f250399feb9dcc1767f23d4341eeeeda184d1 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Wed, 4 Oct 2017 10:29:09 +0200 Subject: [PATCH] Add test for operator== and operator!= for ArrayView --- tests/base/array_view_12.cc | 80 +++++++++++++++++++++++++++++++++ tests/base/array_view_12.output | 33 ++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 tests/base/array_view_12.cc create mode 100644 tests/base/array_view_12.output diff --git a/tests/base/array_view_12.cc b/tests/base/array_view_12.cc new file mode 100644 index 0000000000..50a192fafe --- /dev/null +++ b/tests/base/array_view_12.cc @@ -0,0 +1,80 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + +// test for class ArrayView + +#include "../tests.h" + +#include + + +void test () +{ + std::vector arr1 = {0,1,2,3,4,5,6,7,8,9}; + ArrayView view1 (arr1); + ArrayView view1_const (arr1); + + std::vector arr2 = {0,1,2,3,4}; + ArrayView view2 (arr2); + ArrayView view2_const (arr2); + + deallog << std::boolalpha; + + deallog << "view1==view1: " << (view1==view1) << '\n'; + deallog << "view1!=view1: " << (view1!=view1) << '\n'; + deallog << "view1==view1_const: " << (view1==view1_const) << '\n'; + deallog << "view1!=view1_const: " << (view1!=view1_const) << '\n'; + deallog << "view1==view2: " << (view1==view2) << '\n'; + deallog << "view1!=view2: " << (view1!=view2) << '\n'; + deallog << "view1==view2_const: " << (view1==view2_const) << '\n'; + deallog << "view1!=view2_const: " << (view1!=view2_const) << std::endl; + + deallog << "view1_const==view1: " << (view1_const==view1) << '\n'; + deallog << "view1_const!=view1: " << (view1_const!=view1) << '\n'; + deallog << "view1_const==view1_const: " << (view1_const==view1_const) << '\n'; + deallog << "view1_const!=view1_const: " << (view1_const!=view1_const) << '\n'; + deallog << "view1_const==view2: " << (view1_const==view2) << '\n'; + deallog << "view1_const!=view2: " << (view1_const!=view2) << '\n'; + deallog << "view1_const==view2_const: " << (view1_const==view2_const) << '\n'; + deallog << "view1_const!=view2_const: " << (view1_const!=view2_const) << std::endl; + + deallog << "view2==view1: " << (view2==view1) << '\n'; + deallog << "view2!=view1: " << (view2!=view1) << '\n'; + deallog << "view2==view1_const: " << (view2==view1_const) << '\n'; + deallog << "view2!=view1_const: " << (view2!=view1_const) << '\n'; + deallog << "view2==view2: " << (view2==view2) << '\n'; + deallog << "view2!=view2: " << (view2!=view2) << '\n'; + deallog << "view2==view2_const: " << (view2==view2_const) << '\n'; + deallog << "view2!=view2_const: " << (view2!=view2_const) << std::endl; + + deallog << "view2_const==view1: " << (view2_const==view1) << '\n'; + deallog << "view2_const!=view1: " << (view2_const!=view1) << '\n'; + deallog << "view2_const==view1_const: " << (view2_const==view1_const) << '\n'; + deallog << "view2_const!=view1_const: " << (view2_const!=view1_const) << '\n'; + deallog << "view2_const==view2: " << (view2_const==view2) << '\n'; + deallog << "view2_const!=view2: " << (view2_const!=view2) << '\n'; + deallog << "view2_const==view2_const: " << (view2_const==view2_const) << '\n'; + deallog << "view2_const!=view2_const: " << (view2_const!=view2_const) << std::endl; +} + + + +int main() +{ + initlog(); + + test (); +} diff --git a/tests/base/array_view_12.output b/tests/base/array_view_12.output new file mode 100644 index 0000000000..5f481f62da --- /dev/null +++ b/tests/base/array_view_12.output @@ -0,0 +1,33 @@ + +DEAL::view1==view1: true +view1!=view1: false +view1==view1_const: true +view1!=view1_const: false +view1==view2: false +view1!=view2: true +view1==view2_const: false +view1!=view2_const: true +DEAL::view1_const==view1: true +view1_const!=view1: false +view1_const==view1_const: true +view1_const!=view1_const: false +view1_const==view2: false +view1_const!=view2: true +view1_const==view2_const: false +view1_const!=view2_const: true +DEAL::view2==view1: false +view2!=view1: true +view2==view1_const: false +view2!=view1_const: true +view2==view2: true +view2!=view2: false +view2==view2_const: true +view2!=view2_const: false +DEAL::view2_const==view1: false +view2_const!=view1: true +view2_const==view1_const: false +view2_const!=view1_const: true +view2_const==view2: true +view2_const!=view2: false +view2_const==view2_const: true +view2_const!=view2_const: false -- 2.39.5