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
9c78131d
Unverified
Commit
9c78131d
authored
Feb 17, 2024
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Catch2 version 3 if installed
parent
d94f6f4d
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
138 additions
and
42 deletions
+138
-42
test/CMakeLists.txt
+20
-6
test/format-test.cpp
+2
-1
test/model-test.cpp
+0
-2
test/reconstruction-test.cpp
+0
-2
test/rename-compound-test.cpp
+0
-2
test/spinner-test.cpp
+28
-2
test/sugar-test.cpp
+0
-2
test/test-main.cpp
+6
-3
test/test-main.hpp
+34
-0
test/unit-3d-test.cpp
+0
-2
test/unit-v2-test.cpp
+48
-18
test/validate-pdbx-test.cpp
+0
-2
No files found.
test/CMakeLists.txt
View file @
9c78131d
# We're using the older version 2 of Catch2
FetchContent_Declare
(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.13.9
)
FetchContent_MakeAvailable
(
Catch2
)
find_package
(
Catch2 QUIET
)
if
(
NOT Catch2_FOUND
)
FetchContent_Declare
(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.13.9
)
FetchContent_MakeAvailable
(
Catch2
)
set
(
Catch2_VERSION
"2.13.9"
)
endif
()
list
(
APPEND
...
...
@@ -19,10 +26,17 @@ list(
reconstruction
validate-pdbx
)
add_library
(
test-main OBJECT
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/test-main.cpp"
)
target_link_libraries
(
test-main cifpp::cifpp Catch2::Catch2
)
if
(
${
Catch2_VERSION
}
VERSION_GREATER_EQUAL
"3.0.0"
)
target_compile_definitions
(
test-main PUBLIC CATCH22=0
)
else
()
target_compile_definitions
(
test-main PUBLIC CATCH22=1
)
endif
()
foreach
(
CIFPP_TEST IN LISTS CIFPP_tests
)
set
(
CIFPP_TEST
"
${
CIFPP_TEST
}
-test"
)
set
(
CIFPP_TEST_SOURCE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
CIFPP_TEST
}
.cpp"
)
...
...
test/format-test.cpp
View file @
9c78131d
...
...
@@ -24,7 +24,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <catch2/catch.hpp>
#include "test-main.hpp"
#include <stdexcept>
...
...
test/model-test.cpp
View file @
9c78131d
...
...
@@ -26,8 +26,6 @@
#include "test-main.hpp"
#include <catch2/catch.hpp>
#include <stdexcept>
#include <cif++.hpp>
...
...
test/reconstruction-test.cpp
View file @
9c78131d
...
...
@@ -28,8 +28,6 @@
#include <cif++.hpp>
#include <catch2/catch.hpp>
#include <iostream>
#include <fstream>
...
...
test/rename-compound-test.cpp
View file @
9c78131d
...
...
@@ -28,8 +28,6 @@
#include <cif++.hpp>
#include <catch2/catch.hpp>
#include <iostream>
#include <fstream>
...
...
test/spinner-test.cpp
View file @
9c78131d
#include "cif++/utilities.hpp"
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2024 NKI/AVL, Netherlands Cancer Institute
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test-main.hpp"
#include
<catch2/catch.hpp>
#include
"cif++/utilities.hpp"
#include <random>
#include <thread>
...
...
test/sugar-test.cpp
View file @
9c78131d
...
...
@@ -26,8 +26,6 @@
#include "test-main.hpp"
#include <catch2/catch.hpp>
#include <stdexcept>
#include <cif++.hpp>
...
...
test/test-main.cpp
View file @
9c78131d
...
...
@@ -2,9 +2,6 @@
#include <cif++.hpp>
#define CATCH_CONFIG_RUNNER
#include <catch2/catch.hpp>
std
::
filesystem
::
path
gTestDir
=
std
::
filesystem
::
current_path
();
int
main
(
int
argc
,
char
*
argv
[])
...
...
@@ -12,7 +9,13 @@ int main(int argc, char *argv[])
Catch
::
Session
session
;
// There must be exactly one instance
// Build a new parser on top of Catch2's
#if CATCH22
using
namespace
Catch
::
clara
;
#else
// Build a new parser on top of Catch2's
using
namespace
Catch
::
Clara
;
#endif
auto
cli
=
session
.
cli
()
// Get Catch2's command line parser
|
Opt
(
gTestDir
,
"data-dir"
)
// bind variable to a new option, with a hint string
[
"-D"
][
"--data-dir"
]
// the option names it will respond to
...
...
test/test-main.hpp
View file @
9c78131d
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2024 NKI/AVL, Netherlands Cancer Institute
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#if CATCH22
#include <catch2/catch.hpp>
#else
#include <catch2/catch_all.hpp>
#endif
#include <filesystem>
extern
std
::
filesystem
::
path
gTestDir
;
test/unit-3d-test.cpp
View file @
9c78131d
...
...
@@ -26,8 +26,6 @@
#include "test-main.hpp"
#include <catch2/catch.hpp>
#include <stdexcept>
#include <cif++.hpp>
...
...
test/unit-v2-test.cpp
View file @
9c78131d
...
...
@@ -26,8 +26,6 @@
#include "test-main.hpp"
#include <catch2/catch.hpp>
#include <cif++.hpp>
#include "cif++/dictionary_parser.hpp"
...
...
@@ -746,27 +744,51 @@ _cat_2.desc
std
::
istream
is_data
(
&
data_buffer
);
f
.
load
(
is_data
);
auto
&
cat1
=
f
.
front
()[
"cat_1"
];
auto
&
cat2
=
f
.
front
()[
"cat_2"
];
SECTION
(
"one"
)
{
auto
&
cat1
=
f
.
front
()[
"cat_1"
];
auto
&
cat2
=
f
.
front
()[
"cat_2"
];
REQUIRE
(
cat1
.
size
()
==
3
);
REQUIRE
(
cat2
.
size
()
==
3
);
REQUIRE
(
cat1
.
size
()
==
3
);
REQUIRE
(
cat2
.
size
()
==
3
);
cat1
.
erase
(
cif
::
key
(
"id"
)
==
1
);
cat1
.
erase
(
cif
::
key
(
"id"
)
==
1
);
REQUIRE
(
cat1
.
size
()
==
2
);
REQUIRE
(
cat2
.
size
()
==
1
);
REQUIRE
(
cat1
.
size
()
==
2
);
REQUIRE
(
cat2
.
size
()
==
1
);
// REQUIRE_THROWS_AS(cat2.emplace({
// { "id", 4 },
// { "parent_id", 4 },
// { "desc", "moet fout gaan" }
// }), std::exception);
// REQUIRE_THROWS_AS(cat2.emplace({
// { "id", 4 },
// { "parent_id", 4 },
// { "desc", "moet fout gaan" }
// }), std::exception);
REQUIRE_THROWS_AS
(
cat2
.
emplace
({
{
"id"
,
"vijf"
},
// <- invalid value
{
"parent_id"
,
2
},
{
"desc"
,
"moet fout gaan"
}
}),
std
::
exception
);
REQUIRE_THROWS_AS
(
cat2
.
emplace
({
{
"id"
,
"vijf"
},
// <- invalid value
{
"parent_id"
,
2
},
{
"desc"
,
"moet fout gaan"
}
}),
std
::
exception
);
}
// SECTION("two")
// {
// auto &cat1 = f.front()["cat_1"];
// auto &cat2 = f.front()["cat_2"];
// cat1.update_value(cif::all(), "id", [](std::string_view v) -> std::string
// {
// int vi;
// auto [ec, ptr] = std::from_chars(v.data(), v.data() + v.length(), vi);
// return std::to_string(vi + 1);
// });
// REQUIRE(cat1.find1<std::string>(cif::key("id") == 2, "name") == "Aap");
// REQUIRE(cat1.find1<std::string>(cif::key("id") == 3, "name") == "Noot");
// REQUIRE(cat1.find1<std::string>(cif::key("id") == 4, "name") == "Mies");
// REQUIRE(cat2.find1<int>(cif::key("id") == 1, "parent_id") == 2);
// REQUIRE(cat2.find1<int>(cif::key("id") == 2, "parent_id") == 2);
// REQUIRE(cat2.find1<int>(cif::key("id") == 3, "parent_id") == 3);
// }
}
// --------------------------------------------------------------------
...
...
@@ -3486,4 +3508,11 @@ TEST_CASE("pdb2cif_formula_weight")
fw
=
a
.
front
()[
"entity"
].
find1
<
float
>
(
cif
::
key
(
"id"
)
==
3
,
"formula_weight"
);
CHECK
(
fw
==
18.015
f
);
}
// --------------------------------------------------------------------
TEST_CASE
(
"update_values_with_provider"
)
{
}
\ No newline at end of file
test/validate-pdbx-test.cpp
View file @
9c78131d
...
...
@@ -26,8 +26,6 @@
#include "test-main.hpp"
#include <catch2/catch.hpp>
#include <cif++.hpp>
#include <stdexcept>
...
...
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