Arcane  v3.16.0.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
TestTraceMng.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 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/String.h"
10#include "arccore/base/ReferenceCounter.h"
11#include "arccore/base/FatalErrorException.h"
12#include "arccore/trace/ITraceMng.h"
13#include "arccore/trace/TraceAccessor.h"
14#include "arccore/trace/StandaloneTraceMessage.h"
15
16#include <memory>
17#include <sstream>
18
19using namespace Arccore;
20
21TEST(TraceMng, FatalMessage)
22{
23 ReferenceCounter<ITraceMng> tm(arccoreCreateDefaultTraceMng());
24 TraceAccessor tr(tm.get());
25 // Vérfie que FatalErrorException a bien le bon message.
26 String message = "TestFatalError in utils";
27 String new_message;
28 bool is_ok = false;
29 try{
30 tr.fatal() << message;
31 }
32 catch(const FatalErrorException& ex)
33 {
34 new_message = ex.message();
35 is_ok = true;
36 }
37 ASSERT_TRUE(is_ok) << "Exception not caught";
38
39 ASSERT_TRUE(new_message==message) <<
40 String::format("Bad message(wanted='{0}' current='{1}'",message,new_message);
41}
42
43TEST(TraceMng, FatalMessage2)
44{
45 ReferenceCounter<ITraceMng> tm(arccoreCreateDefaultTraceMng());
46 TraceAccessor tr(tm.get());
47 String message = "TestFatalErrorMessage in utils";
48 String new_message;
49 bool is_ok = false;
50 try{
51 tr.fatalMessage(StandaloneTraceMessage{} << message);
52 }
53 catch(const FatalErrorException& ex)
54 {
55 new_message = ex.message();
56 is_ok = true;
57 }
58 ASSERT_TRUE(is_ok) << "Exception not caught";
59
60 ASSERT_TRUE(new_message==message) <<
61 String::format("Bad message(wanted='{0}' current='{1}'",message,new_message);
62}
#define ASSERT_TRUE(condition)
Vérifie que condition est vrai.
Definition Assertion.h:126
const String & message() const
Message de l'exception.
Exception lorsqu'une erreur fatale est survenue.
Encapsulation d'un pointeur avec compteur de référence.
Chaîne de caractères unicode.
Espace de nom de Arccore.