Leosac  0.8.0
Open Source Access Control
ScheduleValidator.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2016 Leosac
3 
4  This file is part of Leosac.
5 
6  Leosac is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Affero General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Leosac is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Affero General Public License for more details.
15 
16  You should have received a copy of the GNU Affero General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
21 #include "tools/Schedule.hpp"
22 #include "gtest/gtest.h"
23 
24 using namespace Leosac;
25 using namespace Leosac::Tools;
26 
27 namespace Leosac
28 {
29 namespace Test
30 {
31 
32 TEST(TestScheduleValidator, name_length)
33 {
34  Schedule s;
35  ASSERT_THROW({ s.name("s"); }, ModelException);
36 
37 
38  ASSERT_NO_THROW({
39  s.name("long_enough");
41  });
42 
43  ASSERT_THROW(
44  { s.name("this_is_so_long_this_name_is_clearly_to_long_to_be_valid"); },
46 }
47 
48 TEST(TestGroupValidator, name_invalid_char)
49 {
50  Schedule s;
51  ASSERT_NO_THROW({ s.name("aaaa"); });
52  ASSERT_THROW({ s.name("aaa$"); }, ModelException);
53  ASSERT_THROW({ s.name("aaa!"); }, ModelException);
54  ASSERT_THROW({ s.name("aaa^"); }, ModelException);
55  ASSERT_THROW({ s.name("aaa^"); }, ModelException);
56  ASSERT_THROW({ s.name("aaaƤ"); }, ModelException);
57  ASSERT_THROW({ s.name("aaaĆ©"); }, ModelException);
58  ASSERT_THROW({ s.name("aaa aaa"); }, ModelException);
59 }
60 }
61 }
Leosac::Test::TEST
TEST(TestScheduleValidator, name_length)
Definition: ScheduleValidator.cpp:32
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
ModelException.hpp
ModelException
An exception class for general API error.
Definition: ModelException.hpp:33
Leosac::Tools::Schedule::name
const std::string & name() const override
Retrieve the name of the schedule.
Definition: Schedule.cpp:48
Leosac::Tools::Schedule
A schedule is simply a list of time frame (SingleTimeFrame) with a name.
Definition: Schedule.hpp:41
Schedule.hpp
Leosac::Tools
Definition: DatabaseLogSink.hpp:27
Leosac::Tools::ScheduleValidator::validate
static void validate(const ISchedule &sched)
Definition: Schedule.cpp:106