| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 ASSERT_EQ(2, ranges->nearest(3, 0)); | 311 ASSERT_EQ(2, ranges->nearest(3, 0)); |
| 312 ASSERT_EQ(5, ranges->nearest(4, 0)); | 312 ASSERT_EQ(5, ranges->nearest(4, 0)); |
| 313 ASSERT_EQ(5, ranges->nearest(5, 0)); | 313 ASSERT_EQ(5, ranges->nearest(5, 0)); |
| 314 ASSERT_EQ(7, ranges->nearest(8, 0)); | 314 ASSERT_EQ(7, ranges->nearest(8, 0)); |
| 315 | 315 |
| 316 ranges->add(9, 11); | 316 ranges->add(9, 11); |
| 317 ASSERT_EQ(7, ranges->nearest(8, 6)); | 317 ASSERT_EQ(7, ranges->nearest(8, 6)); |
| 318 ASSERT_EQ(7, ranges->nearest(8, 8)); | 318 ASSERT_EQ(7, ranges->nearest(8, 8)); |
| 319 ASSERT_EQ(9, ranges->nearest(8, 10)); | 319 ASSERT_EQ(9, ranges->nearest(8, 10)); |
| 320 } | 320 } |
| 321 |
| 322 TEST(TimeRanges, NearestRange) |
| 323 { |
| 324 RefPtrWillBeRawPtr<TimeRanges> ranges = TimeRanges::create(); |
| 325 ranges->add(0, 2); |
| 326 ranges->add(5, 7); |
| 327 |
| 328 ASSERT_EQ(0u, ranges->nearestRange(0)); |
| 329 ASSERT_EQ(0u, ranges->nearestRange(1)); |
| 330 ASSERT_EQ(0u, ranges->nearestRange(2)); |
| 331 ASSERT_EQ(0u, ranges->nearestRange(3)); |
| 332 ASSERT_EQ(1u, ranges->nearestRange(4)); |
| 333 ASSERT_EQ(1u, ranges->nearestRange(5)); |
| 334 ASSERT_EQ(1u, ranges->nearestRange(8)); |
| 335 |
| 336 ranges->add(9, 11); |
| 337 ASSERT_EQ(2u, ranges->nearestRange(8)); |
| 338 } |
| OLD | NEW |