LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
TestCaseError.cpp
Go to the documentation of this file.
1// Copyright 2002-2013 CEA LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6/***************************************************************************
7 * Copyright (C) 2004 by Benoit Mathieu *
8 * mathieub@zoe.cea.fr *
9 * *
10 ***************************************************************************/
11#include "TestCaseError.hpp"
12
13namespace Lima
14{
15namespace Common
16{
17namespace TGV
18{
19
20
22 const std::string& reason,
23 const std::string& pipeline) :
24 m_type(NoError), m_reason(""), m_conditional(false)
25{
26 std::ostringstream out;
27 out << "TestCase " << tc.id << " type : " << tc.type << " succeeded ! " << std::endl;
28 out << " explanation : " << tc.explanation << std::endl;
29 out << "in pipeline : " << pipeline << std::endl;
30 out << reason << std::endl;
31 m_reason = out.str();
32}
33
35 ErrorTypes type,
36 const std::string& reason,
37 const std::string& pipeline,
38 const TestCase::TestUnit& tu):
39 m_type(type), m_reason(reason), m_conditional(tu.conditional)
40{
41 std::ostringstream out;
42 if (type == NoError)
43 {
44 out << "TestCase " << tc.id << " succeeded ! " << std::endl;
45 out << reason;
46 out << " explanation : " << tc.explanation << std::endl;
47 out << "in TestUnit " << tu.id << " on trace " << tu.trace << std::endl;
48 out << " comment : " << tu.comment << std::endl;
49 out << " left : " << tu.left << std::endl;
50 out << " operator : " << tu.op << std::endl;
51 out << " right : " << tu.right << std::endl;
52 out << " conditional : " << tu.conditional << std::endl;
53 out << "operator '" << tu.op << "' is unknown !" << std::endl;
54 }
55 else if (type == TestCaseFailed)
56 {
57 out << " test unit : " << tu.id << std::endl;
58 out << " pipeline : " << pipeline << std::endl;
59 out << " reason : " << reason << std::endl;
60 out << " type : " << tc.type << ", id : " << tc.id << std::endl;
61 for( SimpleValCallParams::const_iterator paramIt = tc.simpleValCallParams.begin() ;
62 paramIt != tc.simpleValCallParams.end() ; paramIt++ ) {
63 out << " " << (*paramIt).first << " = " << (*paramIt).second<< std::endl;
64 }
65 for( MultiValCallParams::const_iterator paramIt = tc.multiValCallParams.begin() ;
66 paramIt != tc.multiValCallParams.end() ; paramIt++ ) {
67 out << " " << (*paramIt).first << " = ";
68 const std::list<std::string>& list = (*paramIt).second;
69 for( std::list<std::string>::const_iterator valIt = list.begin() ;
70 valIt != list.end() ; valIt++ ) {
71 out << *valIt << ",";
72 }
73 out << std::endl;
74 }
75 for( MapValCallParams::const_iterator paramIt = tc.mapValCallParams.begin() ;
76 paramIt != tc.mapValCallParams.end() ; paramIt++ ) {
77 const std::map<std::string,std::string>& map = (*paramIt).second;
78 out << " " << (*paramIt).first << " = ";
79 for( std::map<std::string,std::string>::const_iterator valueIt = map.begin() ;
80 valueIt != map.end() ; valueIt++ ) {
81 out << " attr='" << (*valueIt).first << "' val='" << (*valueIt).second << "'";
82 }
83 out << std::endl;
84 }
85 }
86 else if (type == InvalidOperator)
87 {
88 out << "TestCase " << tc.id << " is invalid ! " << std::endl;
89 out << reason;
90 out << " explanation : " << tc.explanation << std::endl;
91 out << "in TestUnit " << tu.id << " on trace " << tu.trace << std::endl;
92 out << " comment : " << tu.comment << std::endl;
93 out << " left : " << tu.left << std::endl;
94 out << " operator : " << tu.op << std::endl;
95 out << " right : " << tu.right << std::endl;
96 out << " conditional : " << tu.conditional << std::endl;
97 out << "operator '" << tu.op << "' is unknown !" << std::endl;
98 }
99 else if (type == InvalidKey)
100 {
101 out << "TestCase " << tc.id << " failed ! " << std::endl;
102 out << reason;
103 out << " explanation : " << tc.explanation << std::endl;
104 out << "in pipeline : " << pipeline << std::endl;
105 out << "in TestUnit " << tu.id << " on trace " << tu.trace << std::endl;
106 out << " comment : " << tu.comment << std::endl;
107 out << " left : " << tu.left << std::endl;
108 out << " operator : " << tu.op << std::endl;
109 out << " right : " << tu.right << std::endl;
110 out << " conditional : " << tu.conditional << std::endl;
111 }
112 m_reason = out.str();
113}
114
115
116} // TGV
117} // Common
118} // Lima
NAUTITIA.
MultiValCallParams multiValCallParams
Definition TestCase.h:62
SimpleValCallParams simpleValCallParams
Definition TestCase.h:61
MapValCallParams mapValCallParams
Definition TestCase.h:63