Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
d2d322ba
Commit
d2d322ba
authored
Sep 28, 2020
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unit test
parent
96a26eae
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
14 deletions
+37
-14
src/Cif++.cpp
+19
-11
src/PDB2Cif.cpp
+1
-2
test/unit-test.cpp
+17
-1
No files found.
src/Cif++.cpp
View file @
d2d322ba
...
...
@@ -238,6 +238,9 @@ ItemReference& ItemReference::operator=(const std::string& value)
if
(
mConst
)
throw
std
::
logic_error
(
"Attempt to write to a constant row"
);
if
(
mRow
.
mData
==
nullptr
)
throw
std
::
logic_error
(
"Attempt to write to an uninitialized row"
);
mRow
.
assign
(
mName
,
value
,
false
);
return
*
this
;
}
...
...
@@ -1473,7 +1476,8 @@ template<class Iter>
std
::
tuple
<
Row
,
bool
>
Category
::
emplace
(
Iter
b
,
Iter
e
)
{
// First, make sure all mandatory fields are supplied
std
::
tuple
<
Row
,
bool
>
result
=
std
::
make_tuple
(
Row
(),
true
);
Row
result
;
bool
isNew
=
true
;
if
(
mCatValidator
!=
nullptr
and
b
!=
e
)
{
...
...
@@ -1516,15 +1520,24 @@ std::tuple<Row,bool> Category::emplace(Iter b, Iter e)
{
if
(
VERBOSE
>
1
)
std
::
cerr
<<
"Not inserting new record in "
<<
mName
<<
" (duplicate Key)"
<<
std
::
endl
;
result
=
std
::
make_tuple
(
Row
(
test
),
false
);
result
=
test
;
isNew
=
false
;
}
}
}
if
(
std
::
get
<
1
>
(
result
)
)
if
(
isNew
)
{
auto
nr
=
new
ItemRow
{
nullptr
,
this
,
nullptr
};
Row
r
(
nr
);
for
(
auto
v
=
b
;
v
!=
e
;
++
v
)
r
.
assign
(
*
v
,
true
);
// if (isOrphan(r))
// throw std::runtime_error("Cannot insert row in category " + mName + " since it would be an orphan");
if
(
mHead
==
nullptr
)
{
assert
(
mTail
==
nullptr
);
...
...
@@ -1538,18 +1551,13 @@ std::tuple<Row,bool> Category::emplace(Iter b, Iter e)
mTail
=
nr
;
}
Row
r
(
nr
);
for
(
auto
v
=
b
;
v
!=
e
;
++
v
)
r
.
assign
(
*
v
,
true
);
std
::
get
<
0
>
(
result
)
=
r
;
result
=
r
;
if
(
mIndex
!=
nullptr
)
mIndex
->
insert
(
nr
);
}
return
result
;
return
{
result
,
isNew
}
;
}
std
::
tuple
<
Row
,
bool
>
Category
::
emplace
(
Row
r
)
...
...
src/PDB2Cif.cpp
View file @
d2d322ba
...
...
@@ -2608,8 +2608,7 @@ void PDBFileParser::ParseRemarks()
}
catch
(
const
std
::
exception
&
ex
)
{
std
::
cerr
<<
"Error parsing REMARK "
<<
remarkNr
<<
std
::
endl
;
throw
;
std
::
throw_with_nested
(
std
::
runtime_error
(
"Error parsing REMARK "
+
std
::
to_string
(
remarkNr
)));
}
}
...
...
test/unit-test.cpp
View file @
d2d322ba
...
...
@@ -27,6 +27,8 @@
#define BOOST_TEST_MODULE LibCifPP_Test
#include <boost/test/included/unit_test.hpp>
#include <stdexcept>
// #include "cif++/DistanceMap.hpp"
#include "cif++/Cif++.hpp"
...
...
@@ -202,7 +204,7 @@ save__cat_2.id
_item.mandatory_code yes
_item_aliases.dictionary cif_core.dic
_item_aliases.version 2.0.1
_item_type.code
code
_item_type.code
int
save_
save__cat_2.parent_id
...
...
@@ -279,4 +281,17 @@ _cat_2.desc
BOOST_CHECK
(
cat1
.
size
()
==
2
);
BOOST_CHECK
(
cat2
.
size
()
==
1
);
// BOOST_CHECK_THROW(cat2.emplace({
// { "id", 4 },
// { "parent_id", 4 },
// { "desc", "moet fout gaan" }
// }), std::exception);
BOOST_CHECK_THROW
(
cat2
.
emplace
({
{
"id"
,
"vijf"
},
// <- invalid value
{
"parent_id"
,
2
},
{
"desc"
,
"moet fout gaan"
}
}),
std
::
exception
);
}
\ No newline at end of file
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