test
xml
test_memory.cpp
Go to the documentation of this file.
1
// Unit tests for parsing memory sizes
2
// Author: Adrien Barral
3
4
#include <catch_ros/catch.hpp>
5
6
#include "../../src/launch/bytes_parser.h"
7
8
#include <tuple>
9
10
using namespace
rosmon::launch
;
11
12
TEST_CASE
(
"parse memory size"
,
"[memory]"
)
13
{
14
const
std::vector<std::pair<std::string, uint64_t>> EXAMPLES{
15
{
"1 B"
, 1},
16
{
"100"
, 100},
17
{
"1 MB"
, 1000000ULL},
18
{
"1MB"
, 1000000ULL},
19
{
"1.6 GB"
, 1600000000ULL},
20
{
"1 gB"
, 1000000000ULL},
21
{
"3250 KiB"
, 3250*1ull<<10},
22
{
"40 MiB"
, 40*1ull<<20},
23
{
"1 GiB"
, 1ull<<30},
24
{
"0.5 TiB"
, (1ull<<40)/2}
25
};
26
27
for
(
const
auto
& example : EXAMPLES)
28
{
29
uint64_t memory;
30
bool
ok
;
31
std::tie(memory,
ok
) =
parseMemory
(example.first);
32
33
CAPTURE(example.first);
34
CHECK(
ok
);
35
CHECK(memory == example.second);
36
}
37
}
ok
ROSCPP_DECL bool ok()
rosmon::launch
Definition:
bytes_parser.cpp:15
rosmon::launch::parseMemory
std::tuple< uint64_t, bool > parseMemory(const std::string &memory)
Definition:
bytes_parser.cpp:18
TEST_CASE
TEST_CASE("parse memory size", "[memory]")
Definition:
test_memory.cpp:12
rosmon_core
Author(s): Max Schwarz
autogenerated on Wed Feb 21 2024 04:01:14