summaryrefslogtreecommitdiff
path: root/test/test_protocol.cxx
blob: 3455bfa5821a47bb1c2d1c0d362192a77783b1ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "protocol/ArgParser.hxx"
#include "protocol/Ack.hxx"
#include "protocol/RangeArg.hxx"
#include "util/Compiler.h"

#include <gtest/gtest.h>

#include <stdlib.h>

TEST(ArgParser, Range)
{
	RangeArg range = ParseCommandArgRange("1");
	EXPECT_EQ(1u, range.start);
	EXPECT_EQ(2u, range.end);

	range = ParseCommandArgRange("1:5");
	EXPECT_EQ(1u, range.start);
	EXPECT_EQ(5u, range.end);

	range = ParseCommandArgRange("1:");
	EXPECT_EQ(1u, range.start);
	EXPECT_GE(range.end, 999999u);

	EXPECT_THROW(range = ParseCommandArgRange("-2"),
		     ProtocolError);
}