Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2014-2015, Regents of the University of California |
| 4 | * |
| 5 | * This file is part of ndn-group-encrypt (Group-based Encryption Protocol for NDN). |
| 6 | * See AUTHORS.md for complete list of ndn-group-encrypt authors and contributors. |
| 7 | * |
| 8 | * ndn-group-encrypt is free software: you can redistribute it and/or modify it under the terms |
| 9 | * of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * ndn-group-encrypt is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * PURPOSE. See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * ndn-group-encrypt, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * @author Zhiyi Zhang <dreamerbarrychang@gmail.com> |
| 20 | */ |
| 21 | |
| 22 | #include "schedule.hpp" |
| 23 | #include "boost-test.hpp" |
| 24 | |
| 25 | namespace ndn { |
| 26 | namespace gep { |
| 27 | namespace tests { |
| 28 | |
| 29 | using namespace boost::posix_time; |
| 30 | |
| 31 | BOOST_AUTO_TEST_SUITE(TestSchedule) |
| 32 | |
Zhiyi Zhang | 2f9efa6 | 2015-11-23 19:02:28 +0800 | [diff] [blame] | 33 | BOOST_AUTO_TEST_CASE(CalIntervalWithBlackAndWhite) |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 34 | { |
| 35 | Schedule schedule; |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 36 | RepetitiveInterval interval1(from_iso_string("20150825T000000"), |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 37 | from_iso_string("20150827T000000"), |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 38 | 5, 10, 2, RepetitiveInterval::RepeatUnit::DAY); |
| 39 | RepetitiveInterval interval2(from_iso_string("20150825T000000"), |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 40 | from_iso_string("20150827T000000"), |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 41 | 6, 8, 1, RepetitiveInterval::RepeatUnit::DAY); |
| 42 | RepetitiveInterval interval3(from_iso_string("20150827T000000"), |
| 43 | from_iso_string("20150827T000000"), |
| 44 | 7, 8); |
| 45 | RepetitiveInterval interval4(from_iso_string("20150825T000000"), |
| 46 | from_iso_string("20150825T000000"), |
| 47 | 4, 7); |
| 48 | |
| 49 | schedule.addWhiteInterval(interval1); |
| 50 | schedule.addWhiteInterval(interval2); |
| 51 | schedule.addWhiteInterval(interval4); |
| 52 | schedule.addBlackInterval(interval3); |
| 53 | |
| 54 | Interval resultInterval; |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 55 | bool isPositive; |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 56 | |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 57 | // tp1 --> positive 8.25 4-10 |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 58 | TimeStamp tp1 = from_iso_string("20150825T063000"); |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 59 | std::tie(isPositive, resultInterval) = schedule.getCoveringInterval(tp1); |
| 60 | BOOST_CHECK_EQUAL(isPositive, true); |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 61 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getStartTime()), "20150825T040000"); |
| 62 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getEndTime()), "20150825T100000"); |
| 63 | |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 64 | // tp2 --> positive 8.26 6-8 |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 65 | TimeStamp tp2 = from_iso_string("20150826T073000"); |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 66 | std::tie(isPositive, resultInterval) = schedule.getCoveringInterval(tp2); |
| 67 | BOOST_CHECK_EQUAL(isPositive, true); |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 68 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getStartTime()), "20150826T060000"); |
| 69 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getEndTime()), "20150826T080000"); |
| 70 | |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 71 | // tp3 --> positive 8.27 5-7 |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 72 | TimeStamp tp3 = from_iso_string("20150827T053000"); |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 73 | std::tie(isPositive, resultInterval) = schedule.getCoveringInterval(tp3); |
| 74 | BOOST_CHECK_EQUAL(isPositive, true); |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 75 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getStartTime()), "20150827T050000"); |
| 76 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getEndTime()), "20150827T070000"); |
| 77 | |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 78 | // tp4 --> positive 8.27 5-7 |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 79 | TimeStamp tp4 = from_iso_string("20150827T063000"); |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 80 | std::tie(isPositive, resultInterval) = schedule.getCoveringInterval(tp4); |
| 81 | BOOST_CHECK_EQUAL(isPositive, true); |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 82 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getStartTime()), "20150827T050000"); |
| 83 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getEndTime()), "20150827T070000"); |
| 84 | |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 85 | // tp5 --> negative 8.27 7-8 |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 86 | TimeStamp tp5 = from_iso_string("20150827T073000"); |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 87 | std::tie(isPositive, resultInterval) = schedule.getCoveringInterval(tp5); |
| 88 | BOOST_CHECK_EQUAL(isPositive, false); |
| 89 | BOOST_CHECK_EQUAL(resultInterval.isEmpty(), false); |
| 90 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getStartTime()), "20150827T070000"); |
| 91 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getEndTime()), "20150827T080000"); |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 92 | |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 93 | // tp6 --> negative 8.25 10-24 |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 94 | TimeStamp tp6 = from_iso_string("20150825T113000"); |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 95 | std::tie(isPositive, resultInterval) = schedule.getCoveringInterval(tp6); |
| 96 | BOOST_CHECK_EQUAL(isPositive, false); |
| 97 | BOOST_CHECK_EQUAL(resultInterval.isEmpty(), false); |
| 98 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getStartTime()), "20150825T100000"); |
| 99 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getEndTime()), "20150826T000000"); |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Zhiyi Zhang | 2f9efa6 | 2015-11-23 19:02:28 +0800 | [diff] [blame] | 102 | BOOST_AUTO_TEST_CASE(CalIntervalWithoutBlack) |
| 103 | { |
| 104 | Schedule schedule; |
| 105 | RepetitiveInterval interval1(from_iso_string("20150825T000000"), |
| 106 | from_iso_string("20150827T000000"), |
| 107 | 5, 10, 2, RepetitiveInterval::RepeatUnit::DAY); |
| 108 | RepetitiveInterval interval2(from_iso_string("20150825T000000"), |
| 109 | from_iso_string("20150827T000000"), |
| 110 | 6, 8, 1, RepetitiveInterval::RepeatUnit::DAY); |
| 111 | RepetitiveInterval interval3(from_iso_string("20150825T000000"), |
| 112 | from_iso_string("20150825T000000"), |
| 113 | 4, 7); |
| 114 | |
| 115 | schedule.addWhiteInterval(interval1); |
| 116 | schedule.addWhiteInterval(interval2); |
| 117 | schedule.addWhiteInterval(interval3); |
| 118 | |
| 119 | Interval resultInterval; |
| 120 | bool isPositive; |
| 121 | |
| 122 | // tp1 --> positive 8.25 4-10 |
| 123 | TimeStamp tp1 = from_iso_string("20150825T063000"); |
| 124 | std::tie(isPositive, resultInterval) = schedule.getCoveringInterval(tp1); |
| 125 | BOOST_CHECK_EQUAL(isPositive, true); |
| 126 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getStartTime()), "20150825T040000"); |
| 127 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getEndTime()), "20150825T100000"); |
| 128 | |
| 129 | // tp2 --> positive 8.26 6-8 |
| 130 | TimeStamp tp2 = from_iso_string("20150826T073000"); |
| 131 | std::tie(isPositive, resultInterval) = schedule.getCoveringInterval(tp2); |
| 132 | BOOST_CHECK_EQUAL(isPositive, true); |
| 133 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getStartTime()), "20150826T060000"); |
| 134 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getEndTime()), "20150826T080000"); |
| 135 | |
| 136 | // tp3 --> positive 8.27 5-10 |
| 137 | TimeStamp tp3 = from_iso_string("20150827T053000"); |
| 138 | std::tie(isPositive, resultInterval) = schedule.getCoveringInterval(tp3); |
| 139 | BOOST_CHECK_EQUAL(isPositive, true); |
| 140 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getStartTime()), "20150827T050000"); |
| 141 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getEndTime()), "20150827T100000"); |
| 142 | |
| 143 | // tp4 --> negative 8.25 10-24 |
| 144 | TimeStamp tp4 = from_iso_string("20150825T113000"); |
| 145 | std::tie(isPositive, resultInterval) = schedule.getCoveringInterval(tp4); |
| 146 | BOOST_CHECK_EQUAL(isPositive, false); |
| 147 | BOOST_CHECK_EQUAL(resultInterval.isEmpty(), false); |
| 148 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getStartTime()), "20150825T100000"); |
| 149 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getEndTime()), "20150826T000000"); |
| 150 | |
| 151 | // tp5 --> negative 8.25 0-4 |
| 152 | TimeStamp tp5 = from_iso_string("20150825T013000"); |
| 153 | std::tie(isPositive, resultInterval) = schedule.getCoveringInterval(tp5); |
| 154 | BOOST_CHECK_EQUAL(isPositive, false); |
| 155 | BOOST_CHECK_EQUAL(resultInterval.isEmpty(), false); |
| 156 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getStartTime()), "20150825T000000"); |
| 157 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getEndTime()), "20150825T040000"); |
| 158 | } |
| 159 | |
| 160 | BOOST_AUTO_TEST_CASE(CalIntervalWithoutWhite) |
| 161 | { |
| 162 | Schedule schedule; |
| 163 | RepetitiveInterval interval1(from_iso_string("20150825T000000"), |
| 164 | from_iso_string("20150827T000000"), |
| 165 | 5, 10, 2, RepetitiveInterval::RepeatUnit::DAY); |
| 166 | RepetitiveInterval interval2(from_iso_string("20150825T000000"), |
| 167 | from_iso_string("20150827T000000"), |
| 168 | 6, 8, 1, RepetitiveInterval::RepeatUnit::DAY); |
| 169 | |
| 170 | schedule.addBlackInterval(interval1); |
| 171 | schedule.addBlackInterval(interval2); |
| 172 | |
| 173 | Interval resultInterval; |
| 174 | bool isPositive; |
| 175 | |
| 176 | // tp1 --> negative 8.25 4-10 |
| 177 | TimeStamp tp1 = from_iso_string("20150825T063000"); |
| 178 | std::tie(isPositive, resultInterval) = schedule.getCoveringInterval(tp1); |
| 179 | BOOST_CHECK_EQUAL(isPositive, false); |
| 180 | BOOST_CHECK_EQUAL(resultInterval.isEmpty(), false); |
| 181 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getStartTime()), "20150825T050000"); |
| 182 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getEndTime()), "20150825T100000"); |
| 183 | |
| 184 | // tp2 --> negative 8.25 0-4 |
| 185 | TimeStamp tp2 = from_iso_string("20150825T013000"); |
| 186 | std::tie(isPositive, resultInterval) = schedule.getCoveringInterval(tp2); |
| 187 | BOOST_CHECK_EQUAL(isPositive, false); |
| 188 | BOOST_CHECK_EQUAL(resultInterval.isEmpty(), false); |
| 189 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getStartTime()), "20150825T000000"); |
| 190 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getEndTime()), "20150826T000000"); |
| 191 | } |
| 192 | |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 193 | const uint8_t SCHEDULE[] = { |
| 194 | 0x8f, 0xc4,// Schedule |
| 195 | 0x8d, 0x90,// WhiteIntervalList |
| 196 | ///// |
| 197 | 0x8c, 0x2e, // RepetitiveInterval |
| 198 | 0x86, 0x0f, |
| 199 | 0x32, 0x30, 0x31, 0x35, 0x30, 0x38, 0x32, 0x35, 0x54, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, |
| 200 | 0x87, 0x0f, |
Yingdi Yu | d263c8a | 2016-03-09 16:53:19 -0800 | [diff] [blame] | 201 | 0x32, 0x30, 0x31, 0x35, 0x30, 0x38, 0x32, 0x35, 0x54, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 202 | 0x88, 0x01, |
Yingdi Yu | d263c8a | 2016-03-09 16:53:19 -0800 | [diff] [blame] | 203 | 0x04, |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 204 | 0x89, 0x01, |
Yingdi Yu | d263c8a | 2016-03-09 16:53:19 -0800 | [diff] [blame] | 205 | 0x07, |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 206 | 0x8a, 0x01, |
Yingdi Yu | d263c8a | 2016-03-09 16:53:19 -0800 | [diff] [blame] | 207 | 0x00, |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 208 | 0x8b, 0x01, |
Yingdi Yu | d263c8a | 2016-03-09 16:53:19 -0800 | [diff] [blame] | 209 | 0x00, |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 210 | ///// |
| 211 | 0x8c, 0x2e, // RepetitiveInterval |
| 212 | 0x86, 0x0f, |
| 213 | 0x32, 0x30, 0x31, 0x35, 0x30, 0x38, 0x32, 0x35, 0x54, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, |
| 214 | 0x87, 0x0f, |
| 215 | 0x32, 0x30, 0x31, 0x35, 0x30, 0x38, 0x32, 0x38, 0x54, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, |
| 216 | 0x88, 0x01, |
Yingdi Yu | a717b88 | 2016-03-09 17:56:42 -0800 | [diff] [blame] | 217 | 0x05, |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 218 | 0x89, 0x01, |
Yingdi Yu | a717b88 | 2016-03-09 17:56:42 -0800 | [diff] [blame] | 219 | 0x0a, |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 220 | 0x8a, 0x01, |
Yingdi Yu | a717b88 | 2016-03-09 17:56:42 -0800 | [diff] [blame] | 221 | 0x02, |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 222 | 0x8b, 0x01, |
| 223 | 0x01, |
| 224 | ///// |
| 225 | 0x8c, 0x2e, // RepetitiveInterval |
| 226 | 0x86, 0x0f, |
| 227 | 0x32, 0x30, 0x31, 0x35, 0x30, 0x38, 0x32, 0x35, 0x54, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, |
| 228 | 0x87, 0x0f, |
Yingdi Yu | d263c8a | 2016-03-09 16:53:19 -0800 | [diff] [blame] | 229 | 0x32, 0x30, 0x31, 0x35, 0x30, 0x38, 0x32, 0x38, 0x54, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 230 | 0x88, 0x01, |
Yingdi Yu | d263c8a | 2016-03-09 16:53:19 -0800 | [diff] [blame] | 231 | 0x06, |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 232 | 0x89, 0x01, |
Yingdi Yu | d263c8a | 2016-03-09 16:53:19 -0800 | [diff] [blame] | 233 | 0x08, |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 234 | 0x8a, 0x01, |
Yingdi Yu | d263c8a | 2016-03-09 16:53:19 -0800 | [diff] [blame] | 235 | 0x01, |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 236 | 0x8b, 0x01, |
Yingdi Yu | d263c8a | 2016-03-09 16:53:19 -0800 | [diff] [blame] | 237 | 0x01, |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 238 | ///// |
| 239 | 0x8e, 0x30, // BlackIntervalList |
| 240 | ///// |
| 241 | 0x8c, 0x2e, // RepetitiveInterval |
| 242 | 0x86, 0x0f, |
| 243 | 0x32, 0x30, 0x31, 0x35, 0x30, 0x38, 0x32, 0x37, 0x54, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, |
| 244 | 0x87, 0x0f, |
| 245 | 0x32, 0x30, 0x31, 0x35, 0x30, 0x38, 0x32, 0x37, 0x54, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, |
| 246 | 0x88, 0x01, |
| 247 | 0x07, |
| 248 | 0x89, 0x01, |
| 249 | 0x08, |
| 250 | 0x8a, 0x01, |
| 251 | 0x00, |
| 252 | 0x8b, 0x01, |
| 253 | 0x00 |
| 254 | }; |
| 255 | |
| 256 | BOOST_AUTO_TEST_CASE(EncodeAndDecode) |
| 257 | { |
| 258 | Schedule schedule; |
| 259 | |
| 260 | RepetitiveInterval interval1(from_iso_string("20150825T000000"), |
| 261 | from_iso_string("20150828T000000"), |
| 262 | 5, 10, 2, RepetitiveInterval::RepeatUnit::DAY); |
| 263 | RepetitiveInterval interval2(from_iso_string("20150825T000000"), |
| 264 | from_iso_string("20150828T000000"), |
| 265 | 6, 8, 1, RepetitiveInterval::RepeatUnit::DAY); |
| 266 | RepetitiveInterval interval3(from_iso_string("20150827T000000"), |
| 267 | from_iso_string("20150827T000000"), |
| 268 | 7, 8); |
| 269 | RepetitiveInterval interval4(from_iso_string("20150825T000000"), |
| 270 | from_iso_string("20150825T000000"), |
| 271 | 4, 7); |
| 272 | |
| 273 | schedule.addWhiteInterval(interval1); |
| 274 | schedule.addWhiteInterval(interval2); |
| 275 | schedule.addWhiteInterval(interval4); |
| 276 | schedule.addBlackInterval(interval3); |
| 277 | |
| 278 | Block block = schedule.wireEncode(); |
| 279 | Block block2(SCHEDULE, sizeof(SCHEDULE)); |
| 280 | BOOST_CHECK(block == block2); |
| 281 | |
| 282 | Schedule schedule2(block); |
| 283 | Interval resultInterval; |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 284 | bool isPositive; |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 285 | |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 286 | // tp1 --> positive 8.25 4-10 |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 287 | TimeStamp tp1 = from_iso_string("20150825T063000"); |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 288 | std::tie(isPositive, resultInterval) = schedule.getCoveringInterval(tp1); |
| 289 | BOOST_CHECK_EQUAL(isPositive, true); |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 290 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getStartTime()), "20150825T040000"); |
| 291 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getEndTime()), "20150825T100000"); |
| 292 | |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 293 | // tp2 --> positive 8.26 6-8 |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 294 | TimeStamp tp2 = from_iso_string("20150826T073000"); |
Zhiyi Zhang | 7cc09fc | 2015-09-01 13:40:32 -0700 | [diff] [blame] | 295 | std::tie(isPositive, resultInterval) = schedule.getCoveringInterval(tp2); |
| 296 | BOOST_CHECK_EQUAL(isPositive, true); |
Zhiyi Zhang | cea58d5 | 2015-08-26 10:19:56 -0700 | [diff] [blame] | 297 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getStartTime()), "20150826T060000"); |
| 298 | BOOST_CHECK_EQUAL(to_iso_string(resultInterval.getEndTime()), "20150826T080000"); |
| 299 | } |
| 300 | |
| 301 | BOOST_AUTO_TEST_SUITE_END() |
| 302 | |
| 303 | } // namespace tests |
| 304 | } // namespace gep |
| 305 | } // namespace ndn |