preserves/implementations/cpp/main.cpp

30 lines
777 B
C++
Raw Normal View History

2023-06-12 21:16:47 +00:00
#include "preserves.hpp"
2023-06-20 22:45:04 +00:00
#include <fstream>
2023-06-19 21:47:10 +00:00
#include "googletest/gtest/gtest.h"
2023-06-12 21:16:47 +00:00
2023-06-19 21:47:10 +00:00
using namespace std;
using namespace Preserves;
TEST(Value, Basics) {
auto vs = Value<>::from(vector<Value<>>{
Value<>::from(1),
2023-06-20 22:45:04 +00:00
Value<>::from(2.0),
Value<>::from("three"),
2023-06-19 21:47:10 +00:00
});
ASSERT_EQ(3U, vs.size());
ASSERT_EQ(1U, vs[0].to_unsigned());
2023-06-20 22:45:04 +00:00
ASSERT_EQ(1.0, vs[0].to_double());
ASSERT_EQ(2.0, vs[1].to_double());
ASSERT_EQ("three", vs[2].to_string());
ASSERT_EQ(ValueKind::Sequence, vs.value_kind());
ASSERT_EQ(ValueKind::String, vs[2].value_kind());
2023-06-19 21:47:10 +00:00
}
2023-06-20 22:45:04 +00:00
TEST(BinaryReader, ReadSamples) {
ifstream f("../../tests/samples.bin", ios::binary);
BinaryReader<> r(f, &GenericEmbedded::wrap);
auto v = r.next();
ASSERT_TRUE(v);
}