Skip to content

Commit

Permalink
fix releae build
Browse files Browse the repository at this point in the history
  • Loading branch information
voivoid committed Apr 10, 2017
1 parent f5fbec6 commit d5adfb4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ add_executable(BsonParserTestEncodeDecode test/test-encode-decode.cpp
test/test-input.h)
target_link_libraries(BsonParserTestEncodeDecode PRIVATE BsonParser)

add_test(NAME BsonParserUtils COMMAND BsonParserTestUtils)
add_test(NAME BsonParserUtils COMMAND BsonParserTestParsers)
add_test(NAME BsonParserEncode COMMAND BsonParserTestDecode)
add_test(NAME BsonParserDecode COMMAND BsonParserTestEncode)
add_test(NAME BsonParserEncodeDecode COMMAND BsonParserTestEncodeDecode)
Expand Down
1 change: 1 addition & 0 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ int main(int argc, char** argv)

boost::filesystem::ifstream fstream(filePath, std::ios_base::binary);
assert(fstream);
fstream.unsetf(std::ios::skipws);

Bson::Bytes content;
content.reserve(fileSize);
Expand Down
21 changes: 17 additions & 4 deletions src/parsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <boost/hana/at_key.hpp>
#include <boost/hana/fold_left.hpp>

#define UNUSED __attribute__((unused))

namespace Bson
{
namespace Details
Expand Down Expand Up @@ -111,7 +113,7 @@ CString read(Istream& stream)
template <>
False read(Istream& stream)
{
const auto byte = read<Byte>(stream);
UNUSED const auto byte = read<Byte>(stream);
assert(byte == 0x00);

return {};
Expand All @@ -120,7 +122,7 @@ False read(Istream& stream)
template <>
True read(Istream& stream)
{
const auto byte = read<Byte>(stream);
UNUSED const auto byte = read<Byte>(stream);
assert(byte == 0x01);

return {};
Expand Down Expand Up @@ -157,12 +159,12 @@ List read(Istream& stream)
template <>
Document read(Istream& stream)
{
const Int32 documentSize = Details::read<Int32>(stream);
UNUSED const Int32 documentSize = Details::read<Int32>(stream);
assert(documentSize >= static_cast<Int32>(sizeof(Int32) + sizeof(Byte)));

Document document;
document.getList() = Details::read<List>(stream);
const auto endByte = Details::read<Byte>(stream);
UNUSED const auto endByte = Details::read<Byte>(stream);
assert(endByte == 0);

return document;
Expand Down Expand Up @@ -225,5 +227,16 @@ void write(const Document& document, Ostream& stream, const size_t documentSize)
Details::write(static_cast<Byte>(0), stream);
}

#define BSON_INSTANTIATE_FUNCS(type) \
template type read(Istream& iter); \
template void write(const type value, Ostream& iter);

BSON_INSTANTIATE_FUNCS(Byte);
BSON_INSTANTIATE_FUNCS(Int32);
BSON_INSTANTIATE_FUNCS(Int64);
BSON_INSTANTIATE_FUNCS(Uint64);
BSON_INSTANTIATE_FUNCS(Double);
BSON_INSTANTIATE_FUNCS(Decimal);

} // namespace Details
} // namespace Bson
8 changes: 6 additions & 2 deletions test/test-parsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ bool testStream(const T& val)
template <typename T>
void test(const T& value)
{
assert(testMemory(value));
assert(testStream(value));
bool result = testMemory(value) && testStream(value);

if(!result)
{
throw std::runtime_error("Test failed");
}
}

int main()
Expand Down

0 comments on commit d5adfb4

Please sign in to comment.