summaryrefslogtreecommitdiff
path: root/test/test_protocol.cxx
blob: 86c4a720671bc5cd9e2cf4c5b72e01c5d0dbbf2d (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
27
#include "config.h"
#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);
}