MyraMath
checksum


Source: tests/io/Checksum.cpp

1 // ========================================================================= //
2 // This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
3 // and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
4 // ========================================================================= //
5 
11 // Serialization backend that just saves to std::vector<char>.
13 #include <myramath/io/Checksum.h>
14 
15 // Reporting.
16 #include <tests/myratest.h>
17 
18 using namespace myra;
19 
20 ADD_TEST("checksum","[io]")
21  {
22  // Try matched checksum(), shouldn't throw.
23  VectorStream inout1;
24  inout1 << checksum("Hello");
25  inout1 >> checksum("Hello");
26  // Try mismatched checksum(), should throw.
27  VectorStream inout2;
28  inout2 << checksum("Hello");
29  REQUIRE_EXCEPTION( inout1 >> checksum("NotHello"); );
30  }
31 
32 
Wraps a std::vector<char>, presents it as both an InputStream and OutputStream. Useful for hygienic u...
Definition: VectorStream.h:22
Definition: syntax.dox:1
A stream that serialize/deserializes to std::vector<char> buffer.
Functions to help implement checksums while serializing into OutputStream&#39;s and deserializing from In...


Results: [PASS]


Go back to Summary of /test programs.