cereal 1.1.2
Add test block Closes Homebrew/homebrew#41848. Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
parent
31aae0596c
commit
e40ee581cd
1 changed files with 59 additions and 2 deletions
|
@ -1,8 +1,8 @@
|
|||
class Cereal < Formula
|
||||
desc "C++11 library for serialization"
|
||||
homepage "https://uscilab.github.io/cereal/"
|
||||
url "https://github.com/USCiLab/cereal/archive/v1.1.0.tar.gz"
|
||||
sha1 "a7036f3fdb43315b0b6aa6c112c5878c03f1aa9e"
|
||||
url "https://github.com/USCiLab/cereal/archive/v1.1.2.tar.gz"
|
||||
sha256 "45607d0de1d29e84d03bf8eecf221eb2912005b63f02314fbade9fbabfd37b8d"
|
||||
|
||||
head "https://github.com/USCiLab/cereal.git", :branch => "develop"
|
||||
|
||||
|
@ -17,7 +17,10 @@ class Cereal < Formula
|
|||
|
||||
depends_on "cmake" => :build if build.with? "tests"
|
||||
|
||||
needs :cxx11
|
||||
|
||||
def install
|
||||
ENV.cxx11
|
||||
if build.with? "tests"
|
||||
system "cmake", ".", *std_cmake_args
|
||||
system "make"
|
||||
|
@ -25,4 +28,58 @@ class Cereal < Formula
|
|||
end
|
||||
include.install "include/cereal"
|
||||
end
|
||||
|
||||
test do
|
||||
(testpath/"test.cpp").write <<-EOS.undent
|
||||
#include <cereal/types/unordered_map.hpp>
|
||||
#include <cereal/types/memory.hpp>
|
||||
#include <cereal/archives/binary.hpp>
|
||||
#include <fstream>
|
||||
|
||||
struct MyRecord
|
||||
{
|
||||
uint8_t x, y;
|
||||
float z;
|
||||
|
||||
template <class Archive>
|
||||
void serialize( Archive & ar )
|
||||
{
|
||||
ar( x, y, z );
|
||||
}
|
||||
};
|
||||
|
||||
struct SomeData
|
||||
{
|
||||
int32_t id;
|
||||
std::shared_ptr<std::unordered_map<uint32_t, MyRecord>> data;
|
||||
|
||||
template <class Archive>
|
||||
void save( Archive & ar ) const
|
||||
{
|
||||
ar( data );
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
void load( Archive & ar )
|
||||
{
|
||||
static int32_t idGen = 0;
|
||||
id = idGen++;
|
||||
ar( data );
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ofstream os("out.cereal", std::ios::binary);
|
||||
cereal::BinaryOutputArchive archive( os );
|
||||
|
||||
SomeData myData;
|
||||
archive( myData );
|
||||
|
||||
return 0;
|
||||
}
|
||||
EOS
|
||||
system ENV.cc, "-std=c++11", "-stdlib=libc++", "-lc++", "-o", "test", "test.cpp"
|
||||
system "./test"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue