2014-09-04 15:15:58 +02:00
|
|
|
#include "protocol/ArgParser.hxx"
|
2015-12-18 09:50:48 +01:00
|
|
|
#include "protocol/Ack.hxx"
|
2018-09-02 07:45:45 +02:00
|
|
|
#include "protocol/RangeArg.hxx"
|
2018-08-20 16:19:17 +02:00
|
|
|
#include "util/Compiler.h"
|
2014-09-04 15:15:58 +02:00
|
|
|
|
2018-10-16 19:01:13 +02:00
|
|
|
#include <gtest/gtest.h>
|
2014-09-04 15:15:58 +02:00
|
|
|
|
2014-09-24 23:03:28 +02:00
|
|
|
#include <stdlib.h>
|
2014-09-24 21:40:18 +02:00
|
|
|
|
2018-10-16 19:01:13 +02:00
|
|
|
TEST(ArgParser, Range)
|
2014-09-04 15:15:58 +02:00
|
|
|
{
|
2015-12-18 09:50:48 +01:00
|
|
|
RangeArg range = ParseCommandArgRange("1");
|
2018-10-16 19:01:13 +02:00
|
|
|
EXPECT_EQ(1u, range.start);
|
|
|
|
EXPECT_EQ(2u, range.end);
|
2014-09-04 15:15:58 +02:00
|
|
|
|
2015-12-18 09:50:48 +01:00
|
|
|
range = ParseCommandArgRange("1:5");
|
2018-10-16 19:01:13 +02:00
|
|
|
EXPECT_EQ(1u, range.start);
|
|
|
|
EXPECT_EQ(5u, range.end);
|
2014-09-04 15:15:58 +02:00
|
|
|
|
2015-12-18 09:50:48 +01:00
|
|
|
range = ParseCommandArgRange("1:");
|
2018-10-16 19:01:13 +02:00
|
|
|
EXPECT_EQ(1u, range.start);
|
|
|
|
EXPECT_GE(range.end, 999999u);
|
2014-09-04 15:15:58 +02:00
|
|
|
|
2018-10-16 19:01:13 +02:00
|
|
|
EXPECT_THROW(range = ParseCommandArgRange("-2"),
|
|
|
|
ProtocolError);
|
2014-09-04 15:15:58 +02:00
|
|
|
}
|