Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
7247e945
Commit
7247e945
authored
13 years ago
by
Andreas Schenk
Browse files
Options
Downloads
Patches
Plain Diff
changed image unit tests to use BOOST_CHECK_CLOSE to avoid bogus errors on Fedora 14
parent
f1687631
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/img/base/tests/test_image.cc
+81
-57
81 additions, 57 deletions
modules/img/base/tests/test_image.cc
with
81 additions
and
57 deletions
modules/img/base/tests/test_image.cc
+
81
−
57
View file @
7247e945
...
@@ -97,17 +97,17 @@ void test_Cctor_Assignement()
...
@@ -97,17 +97,17 @@ void test_Cctor_Assignement()
ih1
.
ApplyIP
(
alg
::
Randomize
());
ih1
.
ApplyIP
(
alg
::
Randomize
());
ImageHandle
ih2
(
ih1
);
ImageHandle
ih2
(
ih1
);
BOOST_
REQUIRE
(
ih1
==
ih2
);
BOOST_
CHECK
(
ih1
==
ih2
);
for
(
ExtentIterator
it
(
ih1
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
ih1
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
BOOST_
REQUIRE
(
ih1
.
GetReal
(
it
)
==
ih2
.
GetReal
(
it
));
BOOST_
CHECK
(
ih1
.
GetReal
(
it
)
==
ih2
.
GetReal
(
it
));
}
}
ImageHandle
ih3
=
CreateImage
(
Size
(
10
));
ImageHandle
ih3
=
CreateImage
(
Size
(
10
));
ih3
.
ApplyIP
(
alg
::
Randomize
());
ih3
.
ApplyIP
(
alg
::
Randomize
());
ih3
=
ih1
;
ih3
=
ih1
;
BOOST_
REQUIRE
(
ih1
==
ih3
);
BOOST_
CHECK
(
ih1
==
ih3
);
for
(
ExtentIterator
it
(
ih1
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
ih1
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
BOOST_
REQUIRE
(
ih1
.
GetReal
(
it
)
==
ih3
.
GetReal
(
it
));
BOOST_
CHECK
(
ih1
.
GetReal
(
it
)
==
ih3
.
GetReal
(
it
));
}
}
}
}
...
@@ -176,14 +176,14 @@ void test_Observer()
...
@@ -176,14 +176,14 @@ void test_Observer()
{
{
ImageHandle
ih
=
CreateImage
();
ImageHandle
ih
=
CreateImage
();
BOOST_
REQUIRE
(
ih
.
obs_
);
BOOST_
CHECK
(
ih
.
obs_
);
BOOST_CHECK
(
ih
.
obs_
.
get
()
->
GetListSize
()
==
0
);
BOOST_CHECK
(
ih
.
obs_
.
get
()
->
GetListSize
()
==
0
);
to1
=
new
MyObserver
(
ih
);
to1
=
new
MyObserver
(
ih
);
BOOST_
REQUIRE
(
ih
.
obs_
.
get
()
->
GetListSize
()
==
1
);
BOOST_
CHECK
(
ih
.
obs_
.
get
()
->
GetListSize
()
==
1
);
to2
=
new
MyObserver
(
ih
);
to2
=
new
MyObserver
(
ih
);
BOOST_
REQUIRE
(
ih
.
obs_
.
get
()
->
GetListSize
()
==
2
);
BOOST_
CHECK
(
ih
.
obs_
.
get
()
->
GetListSize
()
==
2
);
BOOST_CHECK
(
to1
->
update_count
==
0
);
BOOST_CHECK
(
to1
->
update_count
==
0
);
BOOST_CHECK
(
to1
->
release_count
==
0
);
BOOST_CHECK
(
to1
->
release_count
==
0
);
...
@@ -197,7 +197,7 @@ void test_Observer()
...
@@ -197,7 +197,7 @@ void test_Observer()
delete
to2
;
delete
to2
;
BOOST_
REQUIRE
(
ih
.
obs_
.
get
()
->
GetListSize
()
==
1
);
BOOST_
CHECK
(
ih
.
obs_
.
get
()
->
GetListSize
()
==
1
);
ImageHandle
ih2
=
ih
;
ImageHandle
ih2
=
ih
;
...
@@ -241,7 +241,7 @@ void test_Interpolation()
...
@@ -241,7 +241,7 @@ void test_Interpolation()
+
(
dx
)
*
(
one
-
dy
)
*
(
dz
)
*
ih3d
.
GetReal
(
Point
(
1
,
0
,
1
))
+
(
dx
)
*
(
one
-
dy
)
*
(
dz
)
*
ih3d
.
GetReal
(
Point
(
1
,
0
,
1
))
+
(
one
-
dx
)
*
(
dy
)
*
(
dz
)
*
ih3d
.
GetReal
(
Point
(
0
,
1
,
1
))
+
(
one
-
dx
)
*
(
dy
)
*
(
dz
)
*
ih3d
.
GetReal
(
Point
(
0
,
1
,
1
))
+
(
dx
)
*
(
dy
)
*
(
dz
)
*
ih3d
.
GetReal
(
Point
(
1
,
1
,
1
));
+
(
dx
)
*
(
dy
)
*
(
dz
)
*
ih3d
.
GetReal
(
Point
(
1
,
1
,
1
));
BOOST_
REQUIRE
(
check_close
(
val3
,
ih3d
.
GetIntpolReal
(
Vec3
(
dx
,
dy
,
dz
)),
1.0e-8
));
BOOST_
CHECK
(
check_close
(
val3
,
ih3d
.
GetIntpolReal
(
Vec3
(
dx
,
dy
,
dz
)),
1.0e-8
));
ImageHandle
ih2d
=
CreateImage
(
Extent
(
Point
(
0
,
0
),
Point
(
1
,
1
)));
ImageHandle
ih2d
=
CreateImage
(
Extent
(
Point
(
0
,
0
),
Point
(
1
,
1
)));
...
@@ -254,7 +254,7 @@ void test_Interpolation()
...
@@ -254,7 +254,7 @@ void test_Interpolation()
+
(
one
-
dx
)
*
(
dy
)
*
ih2d
.
GetReal
(
Point
(
0
,
1
))
+
(
one
-
dx
)
*
(
dy
)
*
ih2d
.
GetReal
(
Point
(
0
,
1
))
+
(
dx
)
*
(
dy
)
*
ih2d
.
GetReal
(
Point
(
1
,
1
));
+
(
dx
)
*
(
dy
)
*
ih2d
.
GetReal
(
Point
(
1
,
1
));
BOOST_
REQUIRE
(
check_close
(
val2
,
ih2d
.
GetIntpolReal
(
Vec2
(
dx
,
dy
)),
1.0e-10
));
BOOST_
CHECK
(
check_close
(
val2
,
ih2d
.
GetIntpolReal
(
Vec2
(
dx
,
dy
)),
1.0e-10
));
ImageHandle
ih1d
=
CreateImage
(
Extent
(
Point
(
0
),
Point
(
1
)));
ImageHandle
ih1d
=
CreateImage
(
Extent
(
Point
(
0
),
Point
(
1
)));
ih3d
.
SetReal
(
Point
(
0
,
0
,
0
),
Real
(
0.000
));
ih3d
.
SetReal
(
Point
(
0
,
0
,
0
),
Real
(
0.000
));
...
@@ -262,7 +262,7 @@ void test_Interpolation()
...
@@ -262,7 +262,7 @@ void test_Interpolation()
Real
val1
=
(
one
-
dx
)
*
ih1d
.
GetReal
(
Point
(
0
,
0
))
Real
val1
=
(
one
-
dx
)
*
ih1d
.
GetReal
(
Point
(
0
,
0
))
+
(
dx
)
*
ih1d
.
GetReal
(
Point
(
1
,
0
));
+
(
dx
)
*
ih1d
.
GetReal
(
Point
(
1
,
0
));
BOOST_
REQUIRE
(
check_close
(
val1
,
ih1d
.
GetIntpolReal
(
dx
),
1.0e-15
));
BOOST_
CHECK
(
check_close
(
val1
,
ih1d
.
GetIntpolReal
(
dx
),
1.0e-15
));
}
}
...
@@ -273,50 +273,56 @@ void test_ScalarOps()
...
@@ -273,50 +273,56 @@ void test_ScalarOps()
ih2
+=
1.0
;
ih2
+=
1.0
;
for
(
ExtentIterator
it
(
ih2
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
ih2
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
BOOST_
REQUIRE
(
ih2
.
GetReal
(
it
)
==
ih1
.
GetReal
(
it
)
+
1.0
);
BOOST_
CHECK
(
ih2
.
GetReal
(
it
)
==
ih1
.
GetReal
(
it
)
+
1.0
);
}
}
ih2
=
ih1
.
Copy
();
ih2
=
ih1
.
Copy
();
ih2
-=
2.5
;
ih2
-=
2.5
;
for
(
ExtentIterator
it
(
ih2
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
ih2
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
BOOST_
REQUIRE
(
ih2
.
GetReal
(
it
)
==
ih1
.
GetReal
(
it
)
-
2.5
);
BOOST_
CHECK
(
ih2
.
GetReal
(
it
)
==
ih1
.
GetReal
(
it
)
-
2.5
);
}
}
ih2
=
ih1
.
Copy
();
ih2
=
ih1
.
Copy
();
ih2
*=
0.9
;
ih2
*=
0.9
;
for
(
ExtentIterator
it
(
ih2
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
ih2
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
BOOST_
REQUIRE
(
std
::
abs
(
ih2
.
GetReal
(
it
)
-
ih1
.
GetReal
(
it
)
*
0.9
)
<
1e-10
);
BOOST_
CHECK
(
std
::
abs
(
ih2
.
GetReal
(
it
)
-
ih1
.
GetReal
(
it
)
*
0.9
)
<
1e-10
);
}
}
ih2
=
ih1
.
Copy
();
ih2
=
ih1
.
Copy
();
ih2
/=
2.1
;
ih2
/=
2.1
;
for
(
ExtentIterator
it
(
ih2
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
ih2
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
BOOST_
REQUIRE
(
std
::
abs
(
ih2
.
GetReal
(
it
)
-
ih1
.
GetReal
(
it
)
/
2.1
)
<
1e-10
);
BOOST_
CHECK
(
std
::
abs
(
ih2
.
GetReal
(
it
)
-
ih1
.
GetReal
(
it
)
/
2.1
)
<
1e-10
);
}
}
}
}
void
test_ImageOps
()
void
test_ImageOps
()
{
{
alg
::
Randomize
rnd
;
Extent
ex1
(
Point
(
-
3
,
-
2
),
Point
(
2
,
2
));
Extent
ex1
(
Point
(
-
3
,
-
2
),
Point
(
2
,
2
));
ImageHandle
h1
=
CreateImage
(
ex1
);
ImageHandle
h1
=
CreateImage
(
ex1
);
h1
.
ApplyIP
(
rnd
);
Real
count
=
1.0
;
for
(
ExtentIterator
it
(
ex1
);
!
it
.
AtEnd
();
++
it
)
{
h1
.
SetReal
(
it
,
count
);
count
+=
1.0
;
}
Extent
ex2
(
Point
(
-
1
,
-
2
),
Point
(
3
,
4
));
Extent
ex2
(
Point
(
-
1
,
-
2
),
Point
(
3
,
4
));
ImageHandle
h2
=
CreateImage
(
ex2
,
COMPLEX
);
ImageHandle
h2
=
CreateImage
(
ex2
,
COMPLEX
);
h2
.
ApplyIP
(
rnd
);
for
(
ExtentIterator
it
(
ex2
);
!
it
.
AtEnd
();
++
it
)
{
h2
.
SetReal
(
it
,
count
);
count
+=
1.0
;
}
// addition
// addition
ImageHandle
h3
=
h1
+
h2
;
ImageHandle
h3
=
h1
+
h2
;
for
(
ExtentIterator
it
(
Extent
(
Point
(
-
4
,
-
3
),
Point
(
4
,
5
)));
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
Extent
(
Point
(
-
4
,
-
3
),
Point
(
4
,
5
)));
!
it
.
AtEnd
();
++
it
)
{
if
(
ex1
.
Contains
(
it
)
&&
ex2
.
Contains
(
it
))
{
if
(
ex1
.
Contains
(
it
)
&&
ex2
.
Contains
(
it
))
{
BOOST_
REQUIRE
(
check_close
(
std
::
fabs
(
h3
.
GetReal
(
it
)
-
(
h1
.
GetReal
(
it
)
+
h2
.
GetReal
(
it
))
)
,
Real
(
0.0
),
1e-6
));
BOOST_
CHECK_SMALL
(
h3
.
GetReal
(
it
)
-
(
h1
.
GetReal
(
it
)
+
h2
.
GetReal
(
it
)),
Real
(
1e-6
));
}
else
if
(
ex1
.
Contains
(
it
))
{
}
else
if
(
ex1
.
Contains
(
it
))
{
BOOST_
REQUIRE
(
h3
.
GetReal
(
it
)
==
h1
.
GetReal
(
it
));
BOOST_
CHECK
(
h3
.
GetReal
(
it
)
==
h1
.
GetReal
(
it
));
}
else
{
}
else
{
BOOST_
REQUIRE
(
h3
.
GetReal
(
it
)
==
0.0
);
BOOST_
CHECK
(
h3
.
GetReal
(
it
)
==
0.0
);
}
}
}
}
...
@@ -324,28 +330,36 @@ void test_ImageOps()
...
@@ -324,28 +330,36 @@ void test_ImageOps()
h3
=
h1
-
h2
;
h3
=
h1
-
h2
;
for
(
ExtentIterator
it
(
Extent
(
Point
(
-
2
,
-
1
),
Point
(
1
,
2
)));
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
Extent
(
Point
(
-
2
,
-
1
),
Point
(
1
,
2
)));
!
it
.
AtEnd
();
++
it
)
{
if
(
ex1
.
Contains
(
it
)
&&
ex2
.
Contains
(
it
))
{
if
(
ex1
.
Contains
(
it
)
&&
ex2
.
Contains
(
it
))
{
BOOST_
REQUIRE
(
check_close
(
std
::
fabs
(
h3
.
GetReal
(
it
)
-
(
h1
.
GetReal
(
it
)
-
h2
.
GetReal
(
it
))
)
,
Real
(
0.0
),
1e-6
));
BOOST_
CHECK_SMALL
(
h3
.
GetReal
(
it
)
-
(
h1
.
GetReal
(
it
)
-
h2
.
GetReal
(
it
)),
Real
(
1e-6
));
}
else
if
(
ex1
.
Contains
(
it
))
{
}
else
if
(
ex1
.
Contains
(
it
))
{
BOOST_
REQUIRE
(
h3
.
GetReal
(
it
)
==
h1
.
GetReal
(
it
));
BOOST_
CHECK
(
h3
.
GetReal
(
it
)
==
h1
.
GetReal
(
it
));
}
else
{
}
else
{
BOOST_
REQUIRE
(
h3
.
GetReal
(
it
)
==
0.0
);
BOOST_
CHECK
(
h3
.
GetReal
(
it
)
==
0.0
);
}
}
}
}
// half frequency tests
// half frequency tests
h1
=
CreateImage
(
Size
(
4
,
5
),
COMPLEX
,
HALF_FREQUENCY
);
h1
=
CreateImage
(
Size
(
4
,
5
),
COMPLEX
,
HALF_FREQUENCY
);
h2
=
CreateImage
(
Size
(
4
,
5
),
COMPLEX
,
HALF_FREQUENCY
);
h2
=
CreateImage
(
Size
(
4
,
5
),
COMPLEX
,
HALF_FREQUENCY
);
h1
.
ApplyIP
(
rnd
);
for
(
ExtentIterator
it
(
h1
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
h2
.
ApplyIP
(
rnd
);
Complex
c
(
count
,
count
+
2
);
h1
.
SetComplex
(
it
,
c
);
count
+=
1.0
;
}
for
(
ExtentIterator
it
(
h2
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
Complex
c
(
count
,
count
+
2
);
h2
.
SetComplex
(
it
,
c
);
count
+=
1.0
;
}
h3
=
h1
+
h2
;
h3
=
h1
+
h2
;
for
(
ExtentIterator
it
(
h1
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
h1
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
BOOST_
REQUIRE
(
std
::
abs
(
h1
.
GetComplex
(
it
)
+
h2
.
GetComplex
(
it
)
-
h3
.
GetComplex
(
it
))
<
1e-10
);
BOOST_
CHECK_SMALL
(
std
::
abs
(
h1
.
GetComplex
(
it
)
+
h2
.
GetComplex
(
it
)
-
h3
.
GetComplex
(
it
))
,
Real
(
1e-10
)
)
;
}
}
h3
=
h1
-
h2
;
h3
=
h1
-
h2
;
for
(
ExtentIterator
it
(
Extent
(
Point
(
-
1
,
0
),
Point
(
2
,
2
)));
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
Extent
(
Point
(
-
1
,
0
),
Point
(
2
,
2
)));
!
it
.
AtEnd
();
++
it
)
{
BOOST_
REQUIRE
(
std
::
abs
(
h1
.
GetComplex
(
it
)
-
h2
.
GetComplex
(
it
)
-
h3
.
GetComplex
(
it
))
<
1e-10
);
BOOST_
CHECK_SMALL
(
std
::
abs
(
h1
.
GetComplex
(
it
)
-
h2
.
GetComplex
(
it
)
-
h3
.
GetComplex
(
it
))
,
Real
(
1e-10
)
)
;
}
}
}
}
...
@@ -408,7 +422,7 @@ void test_DataAlgorithms()
...
@@ -408,7 +422,7 @@ void test_DataAlgorithms()
TestOPAlg
op_alg
;
TestOPAlg
op_alg
;
ImageHandle
ih1
=
CreateImage
(
Size
(
1
));
ImageHandle
ih1
=
CreateImage
(
Size
(
1
));
BOOST_
REQUIRE
(
ih1
.
GetReal
(
Point
(
0
))
==
0.0
);
BOOST_
CHECK
(
ih1
.
GetReal
(
Point
(
0
))
==
0.0
);
// in-place alg applied in-place
// in-place alg applied in-place
ih1
.
ApplyIP
(
ip_alg
);
ih1
.
ApplyIP
(
ip_alg
);
...
@@ -442,28 +456,36 @@ void test_Mult()
...
@@ -442,28 +456,36 @@ void test_Mult()
{
{
ImageHandle
im1
=
CreateImage
(
Extent
(
Point
(
-
2
,
-
1
,
-
3
),
Point
(
1
,
2
,
1
)),
REAL
);
ImageHandle
im1
=
CreateImage
(
Extent
(
Point
(
-
2
,
-
1
,
-
3
),
Point
(
1
,
2
,
1
)),
REAL
);
ImageHandle
im2
=
CreateImage
(
Extent
(
Point
(
-
1
,
-
2
,
-
1
),
Point
(
2
,
1
,
3
)),
COMPLEX
);
ImageHandle
im2
=
CreateImage
(
Extent
(
Point
(
-
1
,
-
2
,
-
1
),
Point
(
2
,
1
,
3
)),
COMPLEX
);
im1
.
ApplyIP
(
alg
::
Randomize
());
Real
count
=
0
;
im2
.
ApplyIP
(
alg
::
Randomize
());
for
(
ExtentIterator
it
(
im1
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
im1
.
SetReal
(
it
,
count
);
count
+=
1.0
;
}
for
(
ExtentIterator
it
(
im2
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
Complex
c
(
count
,
count
+
2
);
im2
.
SetComplex
(
it
,
c
);
count
+=
1.0
;
}
ImageHandle
im12
=
im1
*
im2
;
ImageHandle
im12
=
im1
*
im2
;
BOOST_
REQUIRE
(
im12
.
GetExtent
()
==
im1
.
GetExtent
());
BOOST_
CHECK
(
im12
.
GetExtent
()
==
im1
.
GetExtent
());
for
(
ExtentIterator
it
(
im12
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
im12
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
if
(
im2
.
GetExtent
().
Contains
(
it
))
{
if
(
im1
.
GetExtent
().
Contains
(
it
)
&&
im2
.
GetExtent
().
Contains
(
it
))
{
BOOST_
REQUIRE
(
check_close
(
im12
.
GetReal
(
it
),
im1
.
GetReal
(
it
)
*
im2
.
GetReal
(
it
),
1e-10
));
BOOST_
CHECK_CLOSE
(
im12
.
GetReal
(
it
),
im1
.
GetReal
(
it
)
*
im2
.
GetReal
(
it
),
Real
(
1e-10
));
}
else
{
}
else
{
//BOOST_
REQUIRE
(im
1
2.GetReal(it)==0.0);
//BOOST_
CHECK
(im2
1
.GetReal(it)==0.0);
}
}
}
}
ImageHandle
im21
=
im2
*
im1
;
ImageHandle
im21
=
im2
*
im1
;
BOOST_
REQUIRE
(
im21
.
GetExtent
()
==
im2
.
GetExtent
());
BOOST_
CHECK
(
im21
.
GetExtent
()
==
im2
.
GetExtent
());
for
(
ExtentIterator
it
(
im21
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
im21
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
if
(
im1
.
GetExtent
().
Contains
(
it
)
&&
im2
.
GetExtent
().
Contains
(
it
))
{
if
(
im1
.
GetExtent
().
Contains
(
it
)
&&
im2
.
GetExtent
().
Contains
(
it
))
{
BOOST_
REQUIRE
(
std
::
abs
(
im21
.
GetComplex
(
it
)
-
im2
.
GetComplex
(
it
)
*
im1
.
GetComplex
(
it
))
<
1e-10
);
BOOST_
CHECK_SMALL
(
std
::
abs
(
im21
.
GetComplex
(
it
)
-
im2
.
GetComplex
(
it
)
*
im1
.
GetComplex
(
it
))
,
Real
(
1e-10
)
)
;
}
else
{
}
else
{
//BOOST_
REQUIRE
(im21.GetReal(it)==0.0);
//BOOST_
CHECK
(im21.GetReal(it)==0.0);
}
}
}
}
}
}
...
@@ -476,46 +498,48 @@ void test_AddSub()
...
@@ -476,46 +498,48 @@ void test_AddSub()
im2
.
ApplyIP
(
alg
::
Randomize
());
im2
.
ApplyIP
(
alg
::
Randomize
());
ImageHandle
im12
=
im1
+
im2
;
ImageHandle
im12
=
im1
+
im2
;
BOOST_
REQUIRE
(
im12
.
GetExtent
()
==
im1
.
GetExtent
());
BOOST_
CHECK
(
im12
.
GetExtent
()
==
im1
.
GetExtent
());
for
(
ExtentIterator
it
(
im12
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
im12
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
if
(
im2
.
GetExtent
().
Contains
(
it
))
{
if
(
im2
.
GetExtent
().
Contains
(
it
))
{
BOOST_
REQUIRE
(
check_close
(
im12
.
GetReal
(
it
),
im1
.
GetReal
(
it
)
+
im2
.
GetReal
(
it
),
1e-10
));
BOOST_
CHECK_CLOSE
(
im12
.
GetReal
(
it
),
im1
.
GetReal
(
it
)
+
im2
.
GetReal
(
it
),
Real
(
1e-10
));
}
else
{
}
else
{
BOOST_
REQUIRE
(
im12
.
GetReal
(
it
)
==
im1
.
GetReal
(
it
));
BOOST_
CHECK
(
im12
.
GetReal
(
it
)
==
im1
.
GetReal
(
it
));
}
}
}
}
im12
=
im1
-
im2
;
im12
=
im1
-
im2
;
BOOST_
REQUIRE
(
im12
.
GetExtent
()
==
im1
.
GetExtent
());
BOOST_
CHECK
(
im12
.
GetExtent
()
==
im1
.
GetExtent
());
for
(
ExtentIterator
it
(
im12
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
im12
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
if
(
im2
.
GetExtent
().
Contains
(
it
))
{
if
(
im2
.
GetExtent
().
Contains
(
it
))
{
BOOST_
REQUIRE
(
check_close
(
im12
.
GetReal
(
it
),
im1
.
GetReal
(
it
)
-
im2
.
GetReal
(
it
),
1e-10
));
BOOST_
CHECK_CLOSE
(
im12
.
GetReal
(
it
),
im1
.
GetReal
(
it
)
-
im2
.
GetReal
(
it
),
Real
(
1e-10
));
}
else
{
}
else
{
BOOST_
REQUIRE
(
im12
.
GetReal
(
it
)
==
im1
.
GetReal
(
it
));
BOOST_
CHECK
(
im12
.
GetReal
(
it
)
==
im1
.
GetReal
(
it
));
}
}
}
}
ImageHandle
im21
=
im2
+
im1
;
ImageHandle
im21
=
im2
+
im1
;
BOOST_
REQUIRE
(
im21
.
GetExtent
()
==
im2
.
GetExtent
());
BOOST_
CHECK
(
im21
.
GetExtent
()
==
im2
.
GetExtent
());
for
(
ExtentIterator
it
(
im21
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
im21
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
if
(
im2
.
GetExtent
().
Contains
(
it
))
{
if
(
im2
.
GetExtent
().
Contains
(
it
))
{
BOOST_REQUIRE
(
im21
.
GetComplex
(
it
)
==
im1
.
GetComplex
(
it
)
+
im2
.
GetComplex
(
it
));
BOOST_CHECK_CLOSE
(
real
(
im21
.
GetComplex
(
it
)),
real
(
im1
.
GetComplex
(
it
)
+
im2
.
GetComplex
(
it
)),
Real
(
1e-10
));
BOOST_CHECK_CLOSE
(
imag
(
im21
.
GetComplex
(
it
)),
imag
(
im1
.
GetComplex
(
it
)
+
im2
.
GetComplex
(
it
)),
Real
(
1e-10
));
}
else
{
}
else
{
BOOST_
REQUIR
E
(
im21
.
GetReal
(
it
)
==
im2
.
GetReal
(
it
));
BOOST_
CHECK_CLOS
E
(
im21
.
GetReal
(
it
)
,
im2
.
GetReal
(
it
)
,
Real
(
1e-10
)
);
}
}
}
}
im21
=
im2
-
im1
;
im21
=
im2
-
im1
;
BOOST_
REQUIRE
(
im21
.
GetExtent
()
==
im2
.
GetExtent
());
BOOST_
CHECK
(
im21
.
GetExtent
()
==
im2
.
GetExtent
());
for
(
ExtentIterator
it
(
im21
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
im21
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
if
(
im2
.
GetExtent
().
Contains
(
it
))
{
if
(
im2
.
GetExtent
().
Contains
(
it
))
{
BOOST_REQUIRE
(
im21
.
GetComplex
(
it
)
==
im2
.
GetComplex
(
it
)
-
im1
.
GetComplex
(
it
));
BOOST_CHECK_CLOSE
(
real
(
im21
.
GetComplex
(
it
)),
real
(
im2
.
GetComplex
(
it
)
-
im1
.
GetComplex
(
it
)),
Real
(
1e-10
));
BOOST_CHECK_CLOSE
(
imag
(
im21
.
GetComplex
(
it
)),
imag
(
im2
.
GetComplex
(
it
)
-
im1
.
GetComplex
(
it
)),
Real
(
1e-10
));
}
else
{
}
else
{
BOOST_
REQUIR
E
(
im21
.
GetReal
(
it
)
==
im2
.
GetReal
(
it
));
BOOST_
CHECK_CLOS
E
(
im21
.
GetReal
(
it
)
,
im2
.
GetReal
(
it
)
,
Real
(
1e-10
)
);
}
}
}
}
}
}
...
@@ -532,8 +556,8 @@ void test_Copy()
...
@@ -532,8 +556,8 @@ void test_Copy()
ImageHandle
i3
=
i1
.
Copy
(
false
);
ImageHandle
i3
=
i1
.
Copy
(
false
);
BOOST_CHECK
(
i3
.
GetSpatialOrigin
()
==
Point
(
7
,
3
,
-
2
));
BOOST_CHECK
(
i3
.
GetSpatialOrigin
()
==
Point
(
7
,
3
,
-
2
));
for
(
ExtentIterator
it
(
i1
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
i1
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
BOOST_
REQUIRE
(
i1
.
GetReal
(
it
)
==
i2
.
GetReal
(
it
));
BOOST_
CHECK
(
i1
.
GetReal
(
it
)
==
i2
.
GetReal
(
it
));
BOOST_
REQUIRE
(
i3
.
GetReal
(
it
)
==
0.0
);
BOOST_
CHECK
(
i3
.
GetReal
(
it
)
==
0.0
);
}
}
// complex half frequency
// complex half frequency
i1
=
CreateImage
(
Size
(
6
,
7
),
COMPLEX
,
HALF_FREQUENCY
);
i1
=
CreateImage
(
Size
(
6
,
7
),
COMPLEX
,
HALF_FREQUENCY
);
...
@@ -554,7 +578,7 @@ void test_Extract()
...
@@ -554,7 +578,7 @@ void test_Extract()
BOOST_CHECK
(
i2
.
GetDomain
()
==
SPATIAL
);
BOOST_CHECK
(
i2
.
GetDomain
()
==
SPATIAL
);
BOOST_CHECK
(
i2
.
GetExtent
()
==
Extent
(
Point
(
2
,
3
),
Point
(
7
,
8
)));
BOOST_CHECK
(
i2
.
GetExtent
()
==
Extent
(
Point
(
2
,
3
),
Point
(
7
,
8
)));
for
(
ExtentIterator
it
(
i2
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
i2
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
BOOST_
REQUIRE
(
i2
.
GetReal
(
it
)
==
i1
.
GetReal
(
it
));
BOOST_
CHECK
(
i2
.
GetReal
(
it
)
==
i1
.
GetReal
(
it
));
}
}
i1
=
CreateImage
(
Size
(
13
,
20
),
COMPLEX
,
FREQUENCY
);
i1
=
CreateImage
(
Size
(
13
,
20
),
COMPLEX
,
FREQUENCY
);
...
@@ -565,7 +589,7 @@ void test_Extract()
...
@@ -565,7 +589,7 @@ void test_Extract()
BOOST_CHECK
(
i2
.
GetDomain
()
==
SPATIAL
);
BOOST_CHECK
(
i2
.
GetDomain
()
==
SPATIAL
);
BOOST_CHECK
(
i2
.
GetExtent
()
==
Extent
(
Point
(
2
,
3
),
Point
(
7
,
8
)));
BOOST_CHECK
(
i2
.
GetExtent
()
==
Extent
(
Point
(
2
,
3
),
Point
(
7
,
8
)));
for
(
ExtentIterator
it
(
i2
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
i2
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
BOOST_
REQUIRE
(
i2
.
GetComplex
(
it
)
==
i1
.
GetComplex
(
it
));
BOOST_
CHECK
(
i2
.
GetComplex
(
it
)
==
i1
.
GetComplex
(
it
));
}
}
i1
=
CreateImage
(
Size
(
13
,
30
),
COMPLEX
,
HALF_FREQUENCY
);
i1
=
CreateImage
(
Size
(
13
,
30
),
COMPLEX
,
HALF_FREQUENCY
);
...
@@ -576,7 +600,7 @@ void test_Extract()
...
@@ -576,7 +600,7 @@ void test_Extract()
BOOST_CHECK
(
i2
.
GetDomain
()
==
SPATIAL
);
BOOST_CHECK
(
i2
.
GetDomain
()
==
SPATIAL
);
BOOST_CHECK
(
i2
.
GetExtent
()
==
Extent
(
Point
(
-
2
,
-
3
),
Point
(
7
,
8
)));
BOOST_CHECK
(
i2
.
GetExtent
()
==
Extent
(
Point
(
-
2
,
-
3
),
Point
(
7
,
8
)));
for
(
ExtentIterator
it
(
i2
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
i2
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
BOOST_
REQUIRE
(
i2
.
GetComplex
(
it
)
==
i1
.
GetComplex
(
it
));
BOOST_
CHECK
(
i2
.
GetComplex
(
it
)
==
i1
.
GetComplex
(
it
));
}
}
}
}
...
@@ -592,9 +616,9 @@ void test_Paste()
...
@@ -592,9 +616,9 @@ void test_Paste()
for
(
ExtentIterator
it
(
i3
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
for
(
ExtentIterator
it
(
i3
.
GetExtent
());
!
it
.
AtEnd
();
++
it
)
{
if
(
i2
.
GetExtent
().
Contains
(
it
))
{
if
(
i2
.
GetExtent
().
Contains
(
it
))
{
BOOST_
REQUIRE
(
i3
.
GetReal
(
it
)
==
i2
.
GetReal
(
it
));
BOOST_
CHECK
(
i3
.
GetReal
(
it
)
==
i2
.
GetReal
(
it
));
}
else
{
}
else
{
BOOST_
REQUIRE
(
i3
.
GetReal
(
it
)
==
i1
.
GetReal
(
it
));
BOOST_
CHECK
(
i3
.
GetReal
(
it
)
==
i1
.
GetReal
(
it
));
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment