Chromium Code Reviews| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 rangesB->add(6, 9); | 291 rangesB->add(6, 9); |
| 292 | 292 |
| 293 ASSERT_RANGE("{ [0,2) [4,7) [8,10) }", rangesA); | 293 ASSERT_RANGE("{ [0,2) [4,7) [8,10) }", rangesA); |
| 294 ASSERT_RANGE("{ [1,5) [6,9) }", rangesB); | 294 ASSERT_RANGE("{ [1,5) [6,9) }", rangesB); |
| 295 | 295 |
| 296 rangesA->intersectWith(rangesB.get()); | 296 rangesA->intersectWith(rangesB.get()); |
| 297 | 297 |
| 298 ASSERT_RANGE("{ [1,2) [4,5) [6,7) [8,9) }", rangesA); | 298 ASSERT_RANGE("{ [1,2) [4,5) [6,7) [8,9) }", rangesA); |
| 299 ASSERT_RANGE("{ [1,5) [6,9) }", rangesB); | 299 ASSERT_RANGE("{ [1,5) [6,9) }", rangesB); |
| 300 } | 300 } |
| 301 | |
| 302 TEST(TimeRanges, Nearest) | |
| 303 { | |
| 304 RefPtrWillBeRawPtr<TimeRanges> ranges = TimeRanges::create(); | |
| 305 ranges->add(0, 2); | |
| 306 ranges->add(5, 7); | |
| 307 | |
| 308 ASSERT_EQ(0, ranges->nearest(0)); | |
| 309 ASSERT_EQ(1, ranges->nearest(1)); | |
| 310 ASSERT_EQ(2, ranges->nearest(2)); | |
| 311 ASSERT_EQ(2, ranges->nearest(3)); | |
|
philipj_slow
2014/09/10 12:51:18
Can you also test the case where the point is exac
DaleCurtis
2014/09/10 17:45:19
Damn, you caught me! :) I was trying to avoid any
| |
| 312 ASSERT_EQ(5, ranges->nearest(4)); | |
| 313 ASSERT_EQ(5, ranges->nearest(5)); | |
| 314 ASSERT_EQ(7, ranges->nearest(8)); | |
| 315 } | |
| OLD | NEW |