Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arbor
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Analyze
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
arbor-sim
arbor
Commits
4ac05416
Commit
4ac05416
authored
9 years ago
by
Benjamin Cumming
Browse files
Options
Downloads
Patches
Plain Diff
start working on compartment model
parent
85ee79c8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/CMakeLists.txt
+5
-0
5 additions, 0 deletions
tests/CMakeLists.txt
tests/test_point.cpp
+114
-0
114 additions, 0 deletions
tests/test_point.cpp
tests/test_segment.cpp
+32
-0
32 additions, 0 deletions
tests/test_segment.cpp
with
151 additions
and
0 deletions
tests/CMakeLists.txt
+
5
−
0
View file @
4ac05416
...
...
@@ -2,6 +2,9 @@ set(HEADERS
../src/swcio.hpp
../src/tree.hpp
../src/cell_tree.hpp
../src/point.hpp
../src/math.hpp
../src/segment.hpp
)
set
(
TEST_SOURCES
...
...
@@ -11,6 +14,8 @@ set(TEST_SOURCES
# unit tests
test_swcio.cpp
test_tree.cpp
test_point.cpp
test_segment.cpp
# unit test driver
main.cpp
...
...
This diff is collapsed.
Click to expand it.
tests/test_point.cpp
0 → 100644
+
114
−
0
View file @
4ac05416
#include
<limits>
#include
"gtest.h"
#include
"../src/point.hpp"
TEST
(
point
,
construction
)
{
{
// default constructor
point
<
float
>
p
;
// expect NaN, which returns false when comparing for equality
EXPECT_NE
(
p
.
x
,
p
.
x
);
EXPECT_NE
(
p
.
y
,
p
.
y
);
EXPECT_NE
(
p
.
z
,
p
.
z
);
}
{
// initializer list
point
<
float
>
p
=
{
1
,
2
,
3
};
EXPECT_EQ
(
p
.
x
,
1.
);
EXPECT_EQ
(
p
.
y
,
2.
);
EXPECT_EQ
(
p
.
z
,
3.
);
}
{
// explicit call to constructor
point
<
double
>
p1
(
1
,
2
,
3
);
EXPECT_EQ
(
p1
.
x
,
1.
);
EXPECT_EQ
(
p1
.
y
,
2.
);
EXPECT_EQ
(
p1
.
z
,
3.
);
// copy constructor
auto
p2
=
p1
;
EXPECT_EQ
(
p1
.
x
,
p2
.
x
);
EXPECT_EQ
(
p1
.
y
,
p2
.
y
);
EXPECT_EQ
(
p1
.
z
,
p2
.
z
);
}
}
TEST
(
point
,
constexpr
)
{
// perform test using constexpr
constexpr
point
<
double
>
p1
(
1
,
2
,
3
);
constexpr
point
<
double
>
p2
(
1
,
2
,
3
);
constexpr
auto
p
=
p1
+
p2
;
static_assert
(
p
.
x
==
p1
.
x
+
p2
.
x
,
"failed x-component"
);
static_assert
(
p
.
y
==
p1
.
y
+
p2
.
y
,
"failed y-component"
);
static_assert
(
p
.
z
==
p1
.
z
+
p2
.
z
,
"failed z-component"
);
}
TEST
(
point
,
addition
)
{
// perform test using constexpr
point
<
double
>
p1
(
1
,
2
,
3
);
point
<
double
>
p2
(
1
,
2
,
3
);
auto
p
=
p1
+
p2
;
EXPECT_EQ
(
p
.
x
,
2
);
EXPECT_EQ
(
p
.
y
,
4
);
EXPECT_EQ
(
p
.
z
,
6
);
}
TEST
(
point
,
subtraction
)
{
// perform test using constexpr
point
<
double
>
p1
(
1
,
2
,
3
);
point
<
double
>
p2
(
1
,
2
,
3
);
auto
p
=
p1
-
p2
;
EXPECT_EQ
(
p
.
x
,
0
);
EXPECT_EQ
(
p
.
y
,
0
);
EXPECT_EQ
(
p
.
z
,
0
);
}
TEST
(
point
,
scalar_prod
)
{
// perform test using constexpr
point
<
double
>
p1
(
1
,
2
,
3
);
auto
p
=
0.5
*
p1
;
EXPECT_EQ
(
p
.
x
,
0.5
);
EXPECT_EQ
(
p
.
y
,
1.0
);
EXPECT_EQ
(
p
.
z
,
1.5
);
}
TEST
(
point
,
norm
)
{
// don't use constexpr, because the sqrt is not constexpr
point
<
double
>
p1
(
1
,
1
,
1
);
point
<
double
>
p2
(
1
,
2
,
3
);
EXPECT_EQ
(
norm
(
p1
),
sqrt
(
3.
));
EXPECT_EQ
(
norm
(
p2
),
sqrt
(
1.
+
4.
+
9.
));
}
TEST
(
point
,
dot
)
{
// perform test using constexpr
constexpr
point
<
double
>
p1
(
1
,
-
1
,
1
);
constexpr
point
<
double
>
p2
(
1
,
2
,
3
);
static_assert
(
dot
(
p1
,
p2
)
==
2.
,
"unable to perform constexpr dot product"
);
EXPECT_EQ
(
dot
(
p1
,
p2
),
2.
);
}
This diff is collapsed.
Click to expand it.
tests/test_segment.cpp
0 → 100644
+
32
−
0
View file @
4ac05416
#include
<limits>
#include
"gtest.h"
#include
"../src/segment.hpp"
TEST
(
segments
,
sphere
)
{
using
namespace
nestmc
;
{
auto
s
=
make_segment
<
spherical_segment
>
(
1.0
);
EXPECT_EQ
(
s
->
volume
(),
nestmc
::
pi
<
double
>
()
*
4.
/
3.
);
EXPECT_EQ
(
s
->
area
(),
nestmc
::
pi
<
double
>
()
*
4.
);
EXPECT_EQ
(
s
->
kind
(),
nestmc
::
segmentKind
::
soma
);
}
{
auto
s
=
make_segment
<
spherical_segment
>
(
1.0
,
point
<
double
>
(
0.
,
1.
,
2.
));
EXPECT_EQ
(
s
->
volume
(),
nestmc
::
pi
<
double
>
()
*
4.
/
3.
);
EXPECT_EQ
(
s
->
area
(),
nestmc
::
pi
<
double
>
()
*
4.
);
EXPECT_EQ
(
s
->
kind
(),
nestmc
::
segmentKind
::
soma
);
}
}
TEST
(
segments
,
frustrum
)
{
{
}
}
This diff is collapsed.
Click to expand it.
Preview
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!
Save comment
Cancel
Please
register
or
sign in
to comment