Spinning Topp Logo BlackTopp Studios
inc
testenumerations.cpp
Go to the documentation of this file.
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _unittestenumerations_cpp
41 #define _unittestenumerations_cpp
42 
43 /// @file
44 /// @brief The implmentation of a few functions used with the enumuration in the unit tests
45 
46 #include "datatypes.h"
47 
48 #include "testenumerations.h"
49 
50 #include <stdexcept>
51 
52 namespace Mezzanine
53 {
54  namespace Testing
55  {
57  {
58  switch(Convertable)
59  {
60  case Success:
61  return SuccessString;
62  case Warning:
63  return WarningString;
64  case Skipped:
65  return SkippedString;
66  case Cancelled:
67  return CancelledString;
68  case Inconclusive:
69  return InconclusiveString;
70  case Failed:
71  return FailedString;
72  case Unknown:
73  return UnknownString;
74  case NotApplicable:
75  return NotApplicableString;
76  default:
77  throw std::invalid_argument("Cannot convert to String from TestResult");
78  }
79  }
80 
82  {
83  if(Text.size()==0)
84  { throw std::invalid_argument("Cannot convert to TestResult from empty String"); }
85 
86  switch(Text.at(0))
87  {
88  case 'S':
89  if ( SuccessString == Text )
90  { return Success; }
91  else if ( SkippedString == Text )
92  { return Skipped; }
93  else
94  { throw std::invalid_argument("Cannot convert to TestResult from text(S) " + Text); }
95  case 'W':
96  if ( WarningString == Text )
97  { return Warning;}
98  else
99  { throw std::invalid_argument("Cannot convert to TestResult from text(W) " + Text); }
100  case 'C':
101  if ( CancelledString == Text )
102  { return Cancelled;}
103  else
104  { throw std::invalid_argument("Cannot convert to TestResult from text(C) " + Text); }
105  case 'I':
106  if ( InconclusiveString == Text )
107  { return Inconclusive;}
108  else
109  { throw std::invalid_argument("Cannot convert to TestResult from text(I) " + Text); }
110  case 'U':
111  if ( UnknownString == Text )
112  { return Unknown;}
113  else
114  { throw std::invalid_argument("Cannot convert to TestResult from text(U) " + Text); }
115  case 'F':
116  if ( FailedString == Text )
117  { return Failed;}
118  else
119  { throw std::invalid_argument("Cannot convert to TestResult from text(F) " + Text); }
120  case 'N':
121  if ( NotApplicableString == Text )
122  { return NotApplicable;}
123  else
124  { throw std::invalid_argument("Cannot convert to TestResult from text(F) " + Text); }
125  default:
126  { throw std::invalid_argument("Cannot convert to TestResult from text() " + Text); }
127  }
128  }
129 
130  }// Testing
131 }// Mezzanine
132 
133 #endif
const Mezzanine::String FailedString("Failed")
Corresponds to TestResult::Failed.
const Mezzanine::String InconclusiveString("Inconclusive")
Corresponds to TestResult::Inconclusive.
const Mezzanine::String NotApplicableString("NotApplicable")
Corresponds to TestResult::NotApplicable.
const Mezzanine::String UnknownString("Unknown")
Corresponds to TestResult::Unknown.
Enumerations and constant values associated with the Unit tests.
Mezzanine::String TestResultToString(TestResult Convertable)
This converts A test result enum value into a String matching the identifier name.
const Mezzanine::String CancelledString("Cancelled")
Corresponds to TestResult::Cancelled.
All the definitions for datatypes as well as some basic conversion functions are defined here...
This is not even a kind of failure, This is used to when referencing a test, so if this winds up comi...
const Mezzanine::String WarningString("Warning")
Corresponds to TestResult::Warning.
Test was simply not ran at the behest of the user.
const Mezzanine::String SkippedString("Skipped")
Corresponds to TestResult::Skipped.
TestResult StringToTestResult(Mezzanine::String Text)
Roughly convert a String to a TestResult.
Since we don't know what happened this is the worst kind of failure.
const Mezzanine::String SuccessString("Success")
Corresponds to TestResult::Success.
Technically the test passed but there is something that is not quite right.
TestResult
Return values from tests.
If a user answers that with "don't know" in a test that involved interaction, The user knows there is...
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
Was canceled by user, so success is unknown, but user knows test was canceled.
Test was ran and appeared to work.
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159