From 02099a01350a41a99ec400e9b29df08a01d88979 Mon Sep 17 00:00:00 2001 From: Paul Baltescu Date: Tue, 4 Jun 2013 23:17:57 +0100 Subject: Serialize data structures. --- extractor/precomputation_test.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'extractor/precomputation_test.cc') diff --git a/extractor/precomputation_test.cc b/extractor/precomputation_test.cc index 363febb7..e81ece5d 100644 --- a/extractor/precomputation_test.cc +++ b/extractor/precomputation_test.cc @@ -1,14 +1,19 @@ #include #include +#include #include +#include +#include + #include "mocks/mock_data_array.h" #include "mocks/mock_suffix_array.h" #include "precomputation.h" using namespace std; using namespace ::testing; +namespace ar = boost::archive; namespace extractor { namespace { @@ -29,15 +34,17 @@ class PrecomputationTest : public Test { GetSuffix(i)).WillRepeatedly(Return(suffixes[i])); } EXPECT_CALL(*suffix_array, BuildLCPArray()).WillRepeatedly(Return(lcp)); + + precomputation = Precomputation(suffix_array, 3, 3, 10, 5, 1, 4, 2); } vector data; shared_ptr data_array; shared_ptr suffix_array; + Precomputation precomputation; }; TEST_F(PrecomputationTest, TestCollocations) { - Precomputation precomputation(suffix_array, 3, 3, 10, 5, 1, 4, 2); Index collocations = precomputation.GetCollocations(); vector key = {2, 3, -1, 2}; @@ -101,6 +108,18 @@ TEST_F(PrecomputationTest, TestCollocations) { EXPECT_EQ(0, collocations.count(key)); } +TEST_F(PrecomputationTest, TestSerialization) { + stringstream stream(ios_base::out | ios_base::in); + ar::text_oarchive output_stream(stream, ar::no_header); + output_stream << precomputation; + + Precomputation precomputation_copy; + ar::text_iarchive input_stream(stream, ar::no_header); + input_stream >> precomputation_copy; + + EXPECT_EQ(precomputation, precomputation_copy); +} + } // namespace } // namespace extractor -- cgit v1.2.3