Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CoMISo
Base
Commits
fb7a78b8
Commit
fb7a78b8
authored
Mar 19, 2020
by
Martin Marinov
Browse files
Add Test::Checksum::IssueNumber to refactor common checksum code
parent
a7db159d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Test/CMakeLists.txt
View file @
fb7a78b8
...
...
@@ -3,6 +3,7 @@ set(my_headers
${
CMAKE_CURRENT_SOURCE_DIR
}
/ChecksumCondition.hh
${
CMAKE_CURRENT_SOURCE_DIR
}
/ChecksumDebugEvent.hh
${
CMAKE_CURRENT_SOURCE_DIR
}
/ChecksumFile.hh
${
CMAKE_CURRENT_SOURCE_DIR
}
/ChecksumIssueNumber.hh
${
CMAKE_CURRENT_SOURCE_DIR
}
/ChecksumNumberT.hh
${
CMAKE_CURRENT_SOURCE_DIR
}
/types.hh
${
CMAKE_CURRENT_SOURCE_DIR
}
/TestResult.hh
...
...
@@ -15,5 +16,6 @@ set(my_sources
${
CMAKE_CURRENT_SOURCE_DIR
}
/ChecksumCondition.cc
${
CMAKE_CURRENT_SOURCE_DIR
}
/ChecksumDebugEvent.cc
${
CMAKE_CURRENT_SOURCE_DIR
}
/ChecksumFile.cc
${
CMAKE_CURRENT_SOURCE_DIR
}
/ChecksumIssueNumber.cc
PARENT_SCOPE
)
Test/ChecksumIssueNumber.cc
0 → 100644
View file @
fb7a78b8
// (C) Copyright 2020 by Autodesk, Inc.
#ifdef TEST_ON
#include
"ChecksumIssueNumber.hh"
#include
"TestResult.hh"
#include
<sstream>
namespace
Test
{
namespace
Checksum
{
void
IssueNumber
::
record
(
const
size_t
_issue_nmbr
,
const
Result
_bad_rslt
)
{
Object
::
record
(
_issue_nmbr
==
0
?
Result
::
OK
:
_bad_rslt
,
_issue_nmbr
);
}
Difference
IssueNumber
::
compare_data
(
const
String
&
_old
,
const
String
&
_new
)
const
{
std
::
istringstream
strm_old
(
_old
),
strm_new
(
_new
);
size_t
val_old
,
val_new
;
strm_old
>>
val_old
;
strm_new
>>
val_new
;
if
(
val_new
<
val_old
)
return
Difference
::
IMPROVED
;
else
if
(
val_new
>
val_old
)
return
Difference
::
REGRESSED
;
else
return
Difference
::
EQUAL
;
}
}
// namespace Checksum
}
// namespace Test
#endif // TEST_ON
Test/ChecksumIssueNumber.hh
0 → 100644
View file @
fb7a78b8
// (C) Copyright 2020 by Autodesk, Inc.
#ifndef BASE_CHECKSUM_ISSUE_NUMBER_HH_INCLUDED
#define BASE_CHECKSUM_ISSUE_NUMBER_HH_INCLUDED
#include
<Base/Test/Checksum.hh>
#if defined(TEST_ON)
namespace
Test
{
namespace
Checksum
{
//! Checksum that records and compares a number of issues in a test
class
IssueNumber
:
public
Object
{
protected:
//! Constructor
IssueNumber
(
const
char
*
const
_name
,
const
Level
_lvl
=
L_ALL
)
:
Object
(
_name
,
_lvl
)
{
}
//! Record an error (or warning) if the issue number > 0
void
record
(
const
size_t
_issue_nmbr
,
const
Result
_bad_rslt
=
Result
::
ERROR
);
//! Implements a smart comparison for this type of test checksum
Difference
compare_data
(
const
String
&
_old
,
const
String
&
_new
)
const
final
;
};
}
// namespace Checksum
}
// namespace Test
#endif // defined(TEST_ON)
#endif//BASE_CHECKSUM_ISSUE_NUMBER_HH_INCLUDED
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment