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
4398be6b
Commit
4398be6b
authored
8 years ago
by
Ben Cumming
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #36 from eth-cscs/bug/issue_34
Add save_getline with windows EOL support
parents
7f0a2564
a0b9b703
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/swcio.cpp
+6
-1
6 additions, 1 deletion
src/swcio.cpp
src/swcio.hpp
+1
-0
1 addition, 0 deletions
src/swcio.hpp
tests/test_swcio.cpp
+32
-0
32 additions, 0 deletions
tests/test_swcio.cpp
with
39 additions
and
1 deletion
src/swcio.cpp
+
6
−
1
View file @
4398be6b
...
...
@@ -129,9 +129,14 @@ std::istream &swc_parser::parse_record(std::istream &is, swc_record &record)
while
(
!
is
.
eof
()
&&
!
is
.
bad
())
{
// consume empty and comment lines first
std
::
getline
(
is
,
linebuff_
);
++
lineno_
;
if
(
!
linebuff_
.
empty
()
&&
!
starts_with
(
linebuff_
,
comment_prefix_
))
if
(
!
linebuff_
.
empty
()
&&
!
starts_with
(
linebuff_
,
comment_prefix_
)
&&
!
starts_with
(
linebuff_
,
"
\r
"
))
{
break
;
}
}
if
(
is
.
bad
())
{
...
...
This diff is collapsed.
Click to expand it.
src/swcio.hpp
+
1
−
0
View file @
4398be6b
...
...
@@ -212,6 +212,7 @@ public:
std
::
istream
&
parse_record
(
std
::
istream
&
is
,
swc_record
&
record
);
private
:
// Read the record from a string stream; will be treated like a single line
swc_record
parse_record
(
std
::
istringstream
&
is
);
...
...
This diff is collapsed.
Click to expand it.
tests/test_swcio.cpp
+
32
−
0
View file @
4398be6b
...
...
@@ -521,3 +521,35 @@ TEST(swc_parser, from_file_ball_and_stick)
EXPECT_TRUE
(
nest
::
mc
::
cell_basic_equality
(
local_cell
,
cell
));
}
// check that windows EOL are supported in linux.
// This test is based on the ball_and_stick.swc with windows endings inserted
// manually in a file stream, regression test for issue_34
TEST
(
swc_parser
,
windows_eol
)
{
// Check valid usage
std
::
stringstream
is
;
is
<<
"# ball and stick model with
\r\n
"
;
is
<<
"# - soma with radius 12.6157 2
\r\n
"
;
is
<<
"# - dendrite with length 200 and radius 0.5
\r\n
"
;
is
<<
"
\r\n
"
;
// parser stubles over empty line with \r\n
is
<<
"1 1 0.0 0.0 0.0 6.30785 -1
\r\n
"
;
is
<<
"2 2 6.30785 0.0 0.0 0.5 1
\r\n
"
;
is
<<
"3 2 206.30785 0.0 0.0 0.5 2
\r\n
"
;
is
<<
"
\n
"
;
// read the file into a cell object
auto
cell
=
nest
::
mc
::
io
::
swc_read_cell
(
is
);
// verify that the correct number of nodes was read
EXPECT_EQ
(
cell
.
num_segments
(),
2
);
EXPECT_EQ
(
cell
.
num_compartments
(),
2u
);
// make an equivalent cell via C++ interface
nest
::
mc
::
cell
local_cell
;
local_cell
.
add_soma
(
6.30785
);
local_cell
.
add_cable
(
0
,
nest
::
mc
::
segmentKind
::
dendrite
,
0.5
,
0.5
,
200
);
EXPECT_TRUE
(
nest
::
mc
::
cell_basic_equality
(
local_cell
,
cell
));
}
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