GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: test/zserio/SizeConvertUtilTest.cpp Lines: 12 12 100.0 %
Date: 2023-12-13 14:51:09 Branches: 40 234 17.1 %

Line Branch Exec Source
1
#include <cstddef>
2
#include <limits>
3
4
#include "zserio/SizeConvertUtil.h"
5
#include "zserio/CppRuntimeException.h"
6
#include "zserio/RuntimeArch.h"
7
8
#include "gtest/gtest.h"
9
10
namespace zserio
11
{
12
13


802
TEST(SizeConvertUtilTest, convertSizeToUInt32)
14
{
15








1
    EXPECT_NO_THROW(convertSizeToUInt32(0));
16








1
    EXPECT_NO_THROW(convertSizeToUInt32(std::numeric_limits<uint32_t>::max()));
17
#ifdef ZSERIO_RUNTIME_64BIT
18
1
    const size_t valueAboveUpperBound = static_cast<size_t>(std::numeric_limits<uint32_t>::max()) + 1;
19









2
    EXPECT_THROW(convertSizeToUInt32(valueAboveUpperBound), CppRuntimeException);
20









2
    EXPECT_THROW(convertSizeToUInt32(std::numeric_limits<size_t>::max()), CppRuntimeException);
21
#endif
22
1
}
23
24


802
TEST(SizeConvertUtilTest, convertUInt64ToSize)
25
{
26








1
    EXPECT_NO_THROW(convertUInt64ToSize(0));
27
#ifdef ZSERIO_RUNTIME_64BIT
28








1
    EXPECT_NO_THROW(convertUInt64ToSize(std::numeric_limits<uint64_t>::max()));
29
#else
30
    const uint64_t valueAboveUpperBound = static_cast<uint64_t>(std::numeric_limits<size_t>::max()) + 1;
31
    EXPECT_THROW(convertUInt64ToSize(valueAboveUpperBound), CppRuntimeException);
32
    EXPECT_THROW(convertUInt64ToSize(std::numeric_limits<uint64_t>::max()), CppRuntimeException);
33
#endif
34
1
}
35
36

2394
} // namespace zserio