Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
aaf5a790
Commit
aaf5a790
authored
Oct 06, 2014
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(tests): добавил тесты для calibration.
parent
189567d1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
97 additions
and
6 deletions
+97
-6
Calibration.h
extensions/include/Calibration.h
+5
-5
Makefile.am
extensions/tests/Makefile.am
+1
-1
calibration.cc
extensions/tests/calibration.cc
+64
-0
tests_with_conf.xml
extensions/tests/tests_with_conf.xml
+27
-0
No files found.
extensions/include/Calibration.h
View file @
aaf5a790
...
...
@@ -80,19 +80,19 @@ class Calibration
long
getValue
(
long
raw
,
bool
crop_raw
=
false
);
/*! Возвращает минимальное значение 'x' встретившееся в диаграмме */
inline
long
getMinVal
(){
return
minVal
;
}
inline
long
getMinVal
ue
(){
return
minVal
;
}
/*! Возвращает максимальное значение 'x' втретившееся в диаграмме */
inline
long
getMaxVal
(){
return
maxVal
;
}
inline
long
getMaxVal
ue
(){
return
maxVal
;
}
/*! Возвращает крайнее левое значение 'x' встретившееся в диаграмме (ПОСЛЕ СОРТИРОВКИ ПО ВОЗРАСТАНИЮ 'x'!) */
inline
long
getLeftVal
(){
return
leftVal
;
}
inline
long
getLeftVal
ue
(){
return
leftVal
;
}
/*! Возвращает крайнее правое значение 'x' встретившееся в диаграмме (ПОСЛЕ СОРТИРОВКИ ПО ВОЗРАСТАНИЮ 'x'!) */
inline
long
getRightVal
(){
return
rightVal
;
}
inline
long
getRightVal
ue
(){
return
rightVal
;
}
/*!
Получение сырого значения по калиброванному
\param range=true вернуть крайнее значение в диаграмме
если cal
<leftVal или cal>
rightVal (т.е. выходит за диапазон)
если cal
< leftVal или cal >
rightVal (т.е. выходит за диапазон)
Если range=false, то может быть возвращено значение outOfRange.
*/
...
...
extensions/tests/Makefile.am
View file @
aaf5a790
...
...
@@ -6,7 +6,7 @@ tests_SOURCES = tests.cc calibration.cc digitalfilter.cc
tests_LDADD
=
$(top_builddir)
/lib/libUniSet2.la
$(top_builddir)
/extensions/lib/libUniSet2Extensions.la
tests_CPPFLAGS
=
-I
$(top_builddir)
/include
-I
$(top_builddir)
/extensions/include
-I
$(includedir)
/Catch
tests_with_conf_SOURCES
=
tests_with_conf.cc
tests_with_conf_SOURCES
=
tests_with_conf.cc
calibration.cc
tests_with_conf_LDADD
=
$(top_builddir)
/lib/libUniSet2.la
$(top_builddir)
/extensions/lib/libUniSet2Extensions.la
tests_with_conf_CPPFLAGS
=
-I
$(top_builddir)
/include
-I
$(top_builddir)
/extensions/include
-I
$(includedir)
/Catch
...
...
extensions/tests/calibration.cc
View file @
aaf5a790
#include <catch.hpp>
#include "Configuration.h"
#include "Extensions.h"
#include "Calibration.h"
using
namespace
std
;
using
namespace
UniSetTypes
;
using
namespace
UniSetExtensions
;
TEST_CASE
(
"Calibration"
,
"[calibration]"
)
{
Calibration
*
cal
=
buildCalibrationDiagram
(
"testcal"
);
CHECK
(
cal
!=
0
);
SECTION
(
"getValue"
)
{
REQUIRE
(
cal
->
getValue
(
1500
,
true
)
==
600
);
REQUIRE
(
cal
->
getValue
(
1500
,
false
)
==
Calibration
::
outOfRange
);
REQUIRE
(
cal
->
getValue
(
1000
)
==
600
);
REQUIRE
(
cal
->
getValue
(
933
)
==
466
);
REQUIRE
(
cal
->
getValue
(
800
)
==
300
);
REQUIRE
(
cal
->
getValue
(
700
)
==
250
);
REQUIRE
(
cal
->
getValue
(
600
)
==
200
);
REQUIRE
(
cal
->
getValue
(
650
)
>
200
);
REQUIRE
(
cal
->
getValue
(
650
)
<
250
);
REQUIRE
(
cal
->
getValue
(
200
)
==
60
);
REQUIRE
(
cal
->
getValue
(
50
)
==
20
);
REQUIRE
(
cal
->
getValue
(
10
)
==
0
);
REQUIRE
(
cal
->
getValue
(
5
)
==
0
);
REQUIRE
(
cal
->
getValue
(
0
)
==
0
);
REQUIRE
(
cal
->
getValue
(
-
5
)
==
0
);
REQUIRE
(
cal
->
getValue
(
-
10
)
==
0
);
REQUIRE
(
cal
->
getValue
(
-
50
)
==
-
20
);
REQUIRE
(
cal
->
getValue
(
-
500
)
==
-
80
);
REQUIRE
(
cal
->
getValue
(
-
900
)
==
-
250
);
REQUIRE
(
cal
->
getValue
(
-
1000
)
==
-
300
);
REQUIRE
(
cal
->
getValue
(
-
1050
,
true
)
==
-
300
);
REQUIRE
(
cal
->
getValue
(
-
1050
,
false
)
==
Calibration
::
outOfRange
);
}
SECTION
(
"Other function"
)
{
REQUIRE
(
cal
->
getMinValue
()
==
-
300
);
REQUIRE
(
cal
->
getMaxValue
()
==
600
);
REQUIRE
(
cal
->
getLeftValue
()
==
-
300
);
REQUIRE
(
cal
->
getRightValue
()
==
600
);
REQUIRE
(
cal
->
getRawValue
(
-
80
)
==
-
500
);
REQUIRE
(
cal
->
getRawValue
(
-
500
,
false
)
==
Calibration
::
outOfRange
);
REQUIRE
(
cal
->
getRawValue
(
-
500
,
true
)
==
-
1000
);
REQUIRE
(
cal
->
getRawValue
(
150
)
==
500
);
REQUIRE
(
cal
->
getRawValue
(
700
,
false
)
==
Calibration
::
outOfRange
);
REQUIRE
(
cal
->
getRawValue
(
700
,
true
)
==
1000
);
REQUIRE
(
cal
->
getMinRaw
()
==
-
1000
);
REQUIRE
(
cal
->
getMaxRaw
()
==
1000
);
REQUIRE
(
cal
->
getLeftRaw
()
==
-
1000
);
REQUIRE
(
cal
->
getRightRaw
()
==
1000
);
}
}
#if 0
#include <iostream>
#include "Exceptions.h"
...
...
extensions/tests/tests_with_conf.xml
View file @
aaf5a790
...
...
@@ -86,4 +86,31 @@
<messages
name=
"messages"
idfromfile=
"1"
>
</messages>
<Calibrations
name=
"Calibrations"
>
<diagram
name=
"testcal"
>
<point
x=
"-1000"
y=
"-300"
/>
<point
x=
"-900"
y=
"-250"
/>
<point
x=
"-800"
y=
"-200"
/>
<point
x=
"-700"
y=
"-150"
/>
<point
x=
"-600"
y=
"-100"
/>
<point
x=
"-500"
y=
"-80"
/>
<point
x=
"-200"
y=
"-60"
/>
<point
x=
"-100"
y=
"-60"
/>
<point
x=
"-50"
y=
"-20"
/>
<point
x=
"-10"
y=
"0"
/>
<point
x=
"0"
y=
"0"
/>
<point
x=
"10"
y=
"0"
/>
<point
x=
"50"
y=
"20"
/>
<point
x=
"100"
y=
"60"
/>
<point
x=
"200"
y=
"60"
/>
<point
x=
"300"
y=
"80"
/>
<point
x=
"400"
y=
"100"
/>
<point
x=
"500"
y=
"150"
/>
<point
x=
"600"
y=
"200"
/>
<point
x=
"700"
y=
"250"
/>
<point
x=
"800"
y=
"300"
/>
<point
x=
"900"
y=
"400"
/>
<point
x=
"1000"
y=
"600"
/>
</diagram>
</Calibrations>
</UNISETPLC>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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