Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
TestException.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7#include <gtest/gtest.h>
8
9#include "arccore/base/IndexOutOfRangeException.h"
10
11#include <string>
12
13/*---------------------------------------------------------------------------*/
14/*---------------------------------------------------------------------------*/
15
16using namespace Arccore;
17
18/*---------------------------------------------------------------------------*/
19/*---------------------------------------------------------------------------*/
20namespace
21{
22
23void _doCheckRange(Int64 i,Int64 min_inclusive,Int64 max_exclusive)
24{
25 arccoreCheckRange(i,min_inclusive,max_exclusive);
26}
27void _doCheckRange(Int64 i,Int64 max_exclusive)
28{
29 arccoreCheckAt(i,max_exclusive);
30}
31
32}
33TEST(Exception,Range)
34{
35 EXPECT_THROW(_doCheckRange(0,0,0),IndexOutOfRangeException);
36 EXPECT_THROW(_doCheckRange(-2,-2,-2),IndexOutOfRangeException);
37 EXPECT_THROW(_doCheckRange(-3,-1,5),IndexOutOfRangeException);
38 EXPECT_THROW(_doCheckRange(15,-2,10),IndexOutOfRangeException);
39 EXPECT_THROW(_doCheckRange(15,4,15),IndexOutOfRangeException);
40 EXPECT_NO_THROW(_doCheckRange(4,4,15));
41 EXPECT_NO_THROW(_doCheckRange(-4,-4,5));
42 EXPECT_NO_THROW(_doCheckRange(15,-3,20));
43
44 EXPECT_THROW(_doCheckRange(15,15),IndexOutOfRangeException);
45 EXPECT_THROW(_doCheckRange(-3,15),IndexOutOfRangeException);
46 EXPECT_THROW(_doCheckRange(-3,0),IndexOutOfRangeException);
47 EXPECT_THROW(_doCheckRange(0,0),IndexOutOfRangeException);
48 EXPECT_NO_THROW(_doCheckRange(15,17));
49
50 ARCCORE_CHECK_RANGE(3,-2,19);
51}
52
53/*---------------------------------------------------------------------------*/
54/*---------------------------------------------------------------------------*/
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Classe de base d'une exception.
Exception lorsqu'une valeur n'est pas dans un intervalle donné.
Espace de nom de Arccore.
Definition ArcaneTypes.h:24
ARCCORE_HOST_DEVICE void arccoreCheckRange(Int64 i, Int64 min_value_inclusive, Int64 max_value_exclusive)
Vérifie que min_value_inclusive <= i < max_value_exclusive.
ARCCORE_HOST_DEVICE void arccoreCheckAt(Int64 i, Int64 max_size)
Vérifie un éventuel débordement de tableau.