Skip to content

Commit

Permalink
more conversions USCiLab#139
Browse files Browse the repository at this point in the history
  • Loading branch information
AzothAmmo committed Nov 1, 2016
1 parent 928cd36 commit 15c7339
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 447 deletions.
4 changes: 4 additions & 0 deletions unittests/chrono.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "chrono.hpp"

TEST_SUITE("chrono");

TEST_CASE("binary_chrono")
{
test_chrono<cereal::BinaryInputArchive, cereal::BinaryOutputArchive>();
Expand All @@ -46,3 +48,5 @@ TEST_CASE("json_chrono")
{
test_chrono<cereal::JSONInputArchive, cereal::JSONOutputArchive>();
}

TEST_SUITE_END();
4 changes: 4 additions & 0 deletions unittests/complex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "complex.hpp"

TEST_SUITE("complex")

TEST_CASE("binary_complex")
{
test_complex<cereal::BinaryInputArchive, cereal::BinaryOutputArchive>();
Expand All @@ -46,3 +48,5 @@ TEST_CASE("json_complex")
{
test_complex<cereal::JSONInputArchive, cereal::JSONOutputArchive>();
}

TEST_SUITE_END();
84 changes: 9 additions & 75 deletions unittests/deque.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,95 +24,29 @@
(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 "common.hpp"
#include <boost/test/unit_test.hpp>
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "deque.hpp"

template <class IArchive, class OArchive>
void test_deque()
{
std::random_device rd;
std::mt19937 gen(rd());

for(int ii=0; ii<100; ++ii)
{
std::deque<int> o_poddeque(100);
for(auto & elem : o_poddeque)
elem = random_value<int>(gen);

std::deque<StructInternalSerialize> o_iserdeque(100);
for(auto & elem : o_iserdeque)
elem = StructInternalSerialize( random_value<int>(gen), random_value<int>(gen) );

std::deque<StructInternalSplit> o_ispldeque(100);
for(auto & elem : o_ispldeque)
elem = StructInternalSplit( random_value<int>(gen), random_value<int>(gen) );

std::deque<StructExternalSerialize> o_eserdeque(100);
for(auto & elem : o_eserdeque)
elem = StructExternalSerialize( random_value<int>(gen), random_value<int>(gen) );

std::deque<StructExternalSplit> o_espldeque(100);
for(auto & elem : o_espldeque)
elem = StructExternalSplit( random_value<int>(gen), random_value<int>(gen) );

std::ostringstream os;
{
OArchive oar(os);

oar(o_poddeque);
oar(o_iserdeque);
oar(o_ispldeque);
oar(o_eserdeque);
oar(o_espldeque);
}
TEST_SUITE("deque");

std::deque<int> i_poddeque;
std::deque<StructInternalSerialize> i_iserdeque;
std::deque<StructInternalSplit> i_ispldeque;
std::deque<StructExternalSerialize> i_eserdeque;
std::deque<StructExternalSplit> i_espldeque;

std::istringstream is(os.str());
{
IArchive iar(is);

iar(i_poddeque);
iar(i_iserdeque);
iar(i_ispldeque);
iar(i_eserdeque);
iar(i_espldeque);
}

BOOST_CHECK_EQUAL(i_poddeque.size(), o_poddeque.size());
BOOST_CHECK_EQUAL(i_iserdeque.size(), o_iserdeque.size());
BOOST_CHECK_EQUAL(i_ispldeque.size(), o_ispldeque.size());
BOOST_CHECK_EQUAL(i_eserdeque.size(), o_eserdeque.size());
BOOST_CHECK_EQUAL(i_espldeque.size(), o_espldeque.size());

BOOST_CHECK_EQUAL_COLLECTIONS(i_poddeque.begin(), i_poddeque.end(), o_poddeque.begin(), o_poddeque.end());
BOOST_CHECK_EQUAL_COLLECTIONS(i_iserdeque.begin(), i_iserdeque.end(), o_iserdeque.begin(), o_iserdeque.end());
BOOST_CHECK_EQUAL_COLLECTIONS(i_ispldeque.begin(), i_ispldeque.end(), o_ispldeque.begin(), o_ispldeque.end());
BOOST_CHECK_EQUAL_COLLECTIONS(i_eserdeque.begin(), i_eserdeque.end(), o_eserdeque.begin(), o_eserdeque.end());
BOOST_CHECK_EQUAL_COLLECTIONS(i_espldeque.begin(), i_espldeque.end(), o_espldeque.begin(), o_espldeque.end());
}
}

BOOST_AUTO_TEST_CASE( binary_dequeue )
TEST_CASE("binary_dequeue")
{
test_deque<cereal::BinaryInputArchive, cereal::BinaryOutputArchive>();
}

BOOST_AUTO_TEST_CASE( portable_binary_dequeue )
TEST_CASE("portable_binary_dequeue")
{
test_deque<cereal::PortableBinaryInputArchive, cereal::PortableBinaryOutputArchive>();
}

BOOST_AUTO_TEST_CASE( xml_dequeue )
TEST_CASE("xml_dequeue")
{
test_deque<cereal::XMLInputArchive, cereal::XMLOutputArchive>();
}

BOOST_AUTO_TEST_CASE( json_dequeue )
TEST_CASE("json_dequeue")
{
test_deque<cereal::JSONInputArchive, cereal::JSONOutputArchive>();
}

TEST_SUITE_END();
78 changes: 9 additions & 69 deletions unittests/forward_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,89 +24,29 @@
(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 "common.hpp"
#include <boost/test/unit_test.hpp>
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "forward_list.hpp"

template <class IArchive, class OArchive>
void test_forward_list()
{
std::random_device rd;
std::mt19937 gen(rd());

for(int ii=0; ii<100; ++ii)
{
std::forward_list<int> o_podforward_list(100);
for(auto & elem : o_podforward_list)
elem = random_value<int>(gen);

std::forward_list<StructInternalSerialize> o_iserforward_list(100);
for(auto & elem : o_iserforward_list)
elem = StructInternalSerialize( random_value<int>(gen), random_value<int>(gen) );

std::forward_list<StructInternalSplit> o_isplforward_list(100);
for(auto & elem : o_isplforward_list)
elem = StructInternalSplit( random_value<int>(gen), random_value<int>(gen) );

std::forward_list<StructExternalSerialize> o_eserforward_list(100);
for(auto & elem : o_eserforward_list)
elem = StructExternalSerialize( random_value<int>(gen), random_value<int>(gen) );

std::forward_list<StructExternalSplit> o_esplforward_list(100);
for(auto & elem : o_esplforward_list)
elem = StructExternalSplit( random_value<int>(gen), random_value<int>(gen) );

std::ostringstream os;
{
OArchive oar(os);
TEST_SUITE("forward_list");

oar(o_podforward_list);
oar(o_iserforward_list);
oar(o_isplforward_list);
oar(o_eserforward_list);
oar(o_esplforward_list);
}

std::forward_list<int> i_podforward_list;
std::forward_list<StructInternalSerialize> i_iserforward_list;
std::forward_list<StructInternalSplit> i_isplforward_list;
std::forward_list<StructExternalSerialize> i_eserforward_list;
std::forward_list<StructExternalSplit> i_esplforward_list;

std::istringstream is(os.str());
{
IArchive iar(is);

iar(i_podforward_list);
iar(i_iserforward_list);
iar(i_isplforward_list);
iar(i_eserforward_list);
iar(i_esplforward_list);
}

BOOST_CHECK_EQUAL_COLLECTIONS(i_podforward_list.begin(), i_podforward_list.end(), o_podforward_list.begin(), o_podforward_list.end());
BOOST_CHECK_EQUAL_COLLECTIONS(i_iserforward_list.begin(), i_iserforward_list.end(), o_iserforward_list.begin(), o_iserforward_list.end());
BOOST_CHECK_EQUAL_COLLECTIONS(i_isplforward_list.begin(), i_isplforward_list.end(), o_isplforward_list.begin(), o_isplforward_list.end());
BOOST_CHECK_EQUAL_COLLECTIONS(i_eserforward_list.begin(), i_eserforward_list.end(), o_eserforward_list.begin(), o_eserforward_list.end());
BOOST_CHECK_EQUAL_COLLECTIONS(i_esplforward_list.begin(), i_esplforward_list.end(), o_esplforward_list.begin(), o_esplforward_list.end());
}
}

BOOST_AUTO_TEST_CASE( binary_forward_list )
TEST_CASE("binary_forward_list")
{
test_forward_list<cereal::BinaryInputArchive, cereal::BinaryOutputArchive>();
}

BOOST_AUTO_TEST_CASE( portable_binary_forward_list )
TEST_CASE("portable_binary_forward_list")
{
test_forward_list<cereal::PortableBinaryInputArchive, cereal::PortableBinaryOutputArchive>();
}

BOOST_AUTO_TEST_CASE( xml_forward_list )
TEST_CASE("xml_forward_list")
{
test_forward_list<cereal::XMLInputArchive, cereal::XMLOutputArchive>();
}

BOOST_AUTO_TEST_CASE( json_forward_list )
TEST_CASE("json_forward_list")
{
test_forward_list<cereal::JSONInputArchive, cereal::JSONOutputArchive>();
}

TEST_SUITE_END();
77 changes: 8 additions & 69 deletions unittests/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,90 +24,29 @@
(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 "common.hpp"
#include <boost/test/unit_test.hpp>
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "list.hpp"

template <class IArchive, class OArchive>
void test_list()
{
std::random_device rd;
std::mt19937 gen(rd());

for(int ii=0; ii<100; ++ii)
{
std::list<int> o_podlist(100);
for(auto & elem : o_podlist)
elem = random_value<int>(gen);

std::list<StructInternalSerialize> o_iserlist(100);
for(auto & elem : o_iserlist)
elem = StructInternalSerialize( random_value<int>(gen), random_value<int>(gen) );

std::list<StructInternalSplit> o_ispllist(100);
for(auto & elem : o_ispllist)
elem = StructInternalSplit( random_value<int>(gen), random_value<int>(gen) );

std::list<StructExternalSerialize> o_eserlist(100);
for(auto & elem : o_eserlist)
elem = StructExternalSerialize( random_value<int>(gen), random_value<int>(gen) );

std::list<StructExternalSplit> o_espllist(100);
for(auto & elem : o_espllist)
elem = StructExternalSplit( random_value<int>(gen), random_value<int>(gen) );

std::ostringstream os;
{
OArchive oar(os);

oar(o_podlist);
oar(o_iserlist);
oar(o_ispllist);
oar(o_eserlist);
oar(o_espllist);
}

std::list<int> i_podlist;
std::list<StructInternalSerialize> i_iserlist;
std::list<StructInternalSplit> i_ispllist;
std::list<StructExternalSerialize> i_eserlist;
std::list<StructExternalSplit> i_espllist;

std::istringstream is(os.str());
{
IArchive iar(is);

iar(i_podlist);
iar(i_iserlist);
iar(i_ispllist);
iar(i_eserlist);
iar(i_espllist);
}

BOOST_CHECK_EQUAL_COLLECTIONS(i_podlist.begin(), i_podlist.end(), o_podlist.begin(), o_podlist.end());
BOOST_CHECK_EQUAL_COLLECTIONS(i_iserlist.begin(), i_iserlist.end(), o_iserlist.begin(), o_iserlist.end());
BOOST_CHECK_EQUAL_COLLECTIONS(i_ispllist.begin(), i_ispllist.end(), o_ispllist.begin(), o_ispllist.end());
BOOST_CHECK_EQUAL_COLLECTIONS(i_eserlist.begin(), i_eserlist.end(), o_eserlist.begin(), o_eserlist.end());
BOOST_CHECK_EQUAL_COLLECTIONS(i_espllist.begin(), i_espllist.end(), o_espllist.begin(), o_espllist.end());
}
}
TEST_SUITE("list");

BOOST_AUTO_TEST_CASE( binary_list )
TEST_CASE("binary_list")
{
test_list<cereal::BinaryInputArchive, cereal::BinaryOutputArchive>();
}

BOOST_AUTO_TEST_CASE( portable_binary_list )
TEST_CASE("portable_binary_list")
{
test_list<cereal::PortableBinaryInputArchive, cereal::PortableBinaryOutputArchive>();
}

BOOST_AUTO_TEST_CASE( xml_list )
TEST_CASE("xml_list")
{
test_list<cereal::XMLInputArchive, cereal::XMLOutputArchive>();
}

BOOST_AUTO_TEST_CASE( json_list )
TEST_CASE("json_list")
{
test_list<cereal::JSONInputArchive, cereal::JSONOutputArchive>();
}

TEST_SUITE_END();
Loading

0 comments on commit 15c7339

Please sign in to comment.