Best Python code snippet using hypothesis
test.py
Source:test.py
1#!/usr/bin/python32import unittest3from points_and_segments import naive_count_segments, fast_count_segments4class CommonCountSegmentsTestCase(unittest.TestCase):5 def test_with_empty_segments_and_points(self):6 starts = []7 ends = []8 points = []9 self.assertEqual([], self.method_under_test(starts, ends, points))10 def test_with_empty_segments(self):11 starts = []12 ends = []13 points = [ 1, 2, 3 ]14 self.assertEqual([ 0, 0, 0 ],15 self.method_under_test(starts, ends, points))16 def test_with_empty_points(self):17 starts = [ 1, 2, 3 ]18 ends = [ 4, 5, 6 ]19 points = []20 self.assertEqual([],21 self.method_under_test(starts, ends, points))22 def test_with_one_segment_of_duplicate_negative_points1(self):23 starts = [ -1 ]24 ends = [ -1 ]25 points = [ -3 ]26 self.assertEqual([ 0 ],27 self.method_under_test(starts, ends, points))28 def test_with_one_segment_of_duplicate_negative_points2(self):29 starts = [ -1 ]30 ends = [ -1 ]31 points = [ -2 ]32 self.assertEqual([ 0 ],33 self.method_under_test(starts, ends, points))34 def test_with_one_segment_of_duplicate_negative_points3(self):35 starts = [ -1 ]36 ends = [ -1 ]37 points = [ -1 ]38 self.assertEqual([ 1 ],39 self.method_under_test(starts, ends, points))40 def test_with_one_segment_of_duplicate_negative_points4(self):41 starts = [ -1 ]42 ends = [ -1 ]43 points = [ 0 ]44 self.assertEqual([ 0 ],45 self.method_under_test(starts, ends, points))46 def test_with_one_segment_of_duplicate_negative_points5(self):47 starts = [ -1 ]48 ends = [ -1 ]49 points = [ -3, -2, -1, 0 ]50 self.assertEqual([ 0, 0, 1, 0 ],51 self.method_under_test(starts, ends, points))52 def test_with_one_segment_of_duplicate_points1(self):53 starts = [ 1 ]54 ends = [ 1 ]55 points = [ -1 ]56 self.assertEqual([ 0 ],57 self.method_under_test(starts, ends, points))58 def test_with_one_segment_of_duplicate_points2(self):59 starts = [ 1 ]60 ends = [ 1 ]61 points = [ 0 ]62 self.assertEqual([ 0 ],63 self.method_under_test(starts, ends, points))64 def test_with_one_segment_of_duplicate_points3(self):65 starts = [ 1 ]66 ends = [ 1 ]67 points = [ 1 ]68 self.assertEqual([ 1 ],69 self.method_under_test(starts, ends, points))70 def test_with_one_segment_of_duplicate_points4(self):71 starts = [ 1 ]72 ends = [ 1 ]73 points = [ 2 ]74 self.assertEqual([ 0 ],75 self.method_under_test(starts, ends, points))76 def test_with_one_segment_of_duplicate_points5(self):77 starts = [ 1 ]78 ends = [ 1 ]79 points = [ -1, 0, 1, 2 ]80 self.assertEqual([ 0, 0, 1, 0 ],81 self.method_under_test(starts, ends, points))82 def test_with_one_negative_segment1(self):83 starts = [ -4 ]84 ends = [ -1 ]85 points = [ -5 ]86 self.assertEqual([ 0 ],87 self.method_under_test(starts, ends, points))88 def test_with_one_negative_segment2(self):89 starts = [ -4 ]90 ends = [ -1 ]91 points = [ -4 ]92 self.assertEqual([ 1 ],93 self.method_under_test(starts, ends, points))94 def test_with_one_negative_segment3(self):95 starts = [ -4 ]96 ends = [ -1 ]97 points = [ -3 ]98 self.assertEqual([ 1 ],99 self.method_under_test(starts, ends, points))100 def test_with_one_negative_segment4(self):101 starts = [ -4 ]102 ends = [ -1 ]103 points = [ -2 ]104 self.assertEqual([ 1 ],105 self.method_under_test(starts, ends, points))106 def test_with_one_negative_segment5(self):107 starts = [ -4 ]108 ends = [ -1 ]109 points = [ -1 ]110 self.assertEqual([ 1 ],111 self.method_under_test(starts, ends, points))112 def test_with_one_negative_segment6(self):113 starts = [ -4 ]114 ends = [ -1 ]115 points = [ 0 ]116 self.assertEqual([ 0 ],117 self.method_under_test(starts, ends, points))118 def test_with_one_negative_segment7(self):119 starts = [ -4 ]120 ends = [ -1 ]121 points = [ -5, -4, -3, -2, -1, 0 ]122 self.assertEqual([ 0, 1, 1, 1, 1, 0 ],123 self.method_under_test(starts, ends, points))124 def test_with_one_negative_and_positive_segment1(self):125 starts = [ -4 ]126 ends = [ 4 ]127 points = [ -5 ]128 self.assertEqual([ 0 ],129 self.method_under_test(starts, ends, points))130 def test_with_one_negative_and_positive_segment2(self):131 starts = [ -4 ]132 ends = [ 4 ]133 points = [ -4 ]134 self.assertEqual([ 1 ],135 self.method_under_test(starts, ends, points))136 def test_with_one_negative_and_positive_segment3(self):137 starts = [ -4 ]138 ends = [ 4 ]139 points = [ -3 ]140 self.assertEqual([ 1 ],141 self.method_under_test(starts, ends, points))142 def test_with_one_negative_and_positive_segment4(self):143 starts = [ -4 ]144 ends = [ 4 ]145 points = [ -2 ]146 self.assertEqual([ 1 ],147 self.method_under_test(starts, ends, points))148 def test_with_one_negative_and_positive_segment5(self):149 starts = [ -4 ]150 ends = [ 4 ]151 points = [ -1 ]152 self.assertEqual([ 1 ],153 self.method_under_test(starts, ends, points))154 def test_with_one_negative_and_positive_segment6(self):155 starts = [ -4 ]156 ends = [ 4 ]157 points = [ 0 ]158 self.assertEqual([ 1 ],159 self.method_under_test(starts, ends, points))160 def test_with_one_negative_and_positive_segment7(self):161 starts = [ -4 ]162 ends = [ 4 ]163 points = [ 1 ]164 self.assertEqual([ 1 ],165 self.method_under_test(starts, ends, points))166 def test_with_one_negative_and_positive_segment8(self):167 starts = [ -4 ]168 ends = [ 4 ]169 points = [ 2 ]170 self.assertEqual([ 1 ],171 self.method_under_test(starts, ends, points))172 def test_with_one_negative_and_positive_segment9(self):173 starts = [ -4 ]174 ends = [ 4 ]175 points = [ 3 ]176 self.assertEqual([ 1 ],177 self.method_under_test(starts, ends, points))178 def test_with_one_negative_and_positive_segment10(self):179 starts = [ -4 ]180 ends = [ 4 ]181 points = [ 4 ]182 self.assertEqual([ 1 ],183 self.method_under_test(starts, ends, points))184 def test_with_one_negative_and_positive_segment11(self):185 starts = [ -4 ]186 ends = [ 4 ]187 points = [ -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 ]188 self.assertEqual([ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ],189 self.method_under_test(starts, ends, points))190 def test_with_one_segment1(self):191 starts = [ 1 ]192 ends = [ 4 ]193 points = [ -1 ]194 self.assertEqual([ 0 ],195 self.method_under_test(starts, ends, points))196 def test_with_one_segment2(self):197 starts = [ 1 ]198 ends = [ 4 ]199 points = [ 1 ]200 self.assertEqual([ 1 ],201 self.method_under_test(starts, ends, points))202 def test_with_one_segment3(self):203 starts = [ 1 ]204 ends = [ 4 ]205 points = [ 2 ]206 self.assertEqual([ 1 ],207 self.method_under_test(starts, ends, points))208 def test_with_one_segment4(self):209 starts = [ 1 ]210 ends = [ 4 ]211 points = [ 3 ]212 self.assertEqual([ 1 ],213 self.method_under_test(starts, ends, points))214 def test_with_one_segment5(self):215 starts = [ 1 ]216 ends = [ 4 ]217 points = [ 4 ]218 self.assertEqual([ 1 ],219 self.method_under_test(starts, ends, points))220 def test_with_one_segment6(self):221 starts = [ 1 ]222 ends = [ 4 ]223 points = [ 5 ]224 self.assertEqual([ 0 ],225 self.method_under_test(starts, ends, points))226 def test_with_one_segment7(self):227 starts = [ 1 ]228 ends = [ 4 ]229 points = [ -1, 0, 1, 2, 3, 4, 5 ]230 self.assertEqual([ 0, 0, 1, 1, 1, 1, 0 ],231 self.method_under_test(starts, ends, points))232 def test_with_two_segments_and_overlap_of_zero_units1(self):233 starts = [ 1, 5 ]234 ends = [ 3, 6 ]235 points = [ -1 ]236 self.assertEqual([ 0 ],237 self.method_under_test(starts, ends, points))238 def test_with_two_segments_and_overlap_of_zero_units2(self):239 starts = [ 1, 5 ]240 ends = [ 3, 6 ]241 points = [ 0 ]242 self.assertEqual([ 0 ],243 self.method_under_test(starts, ends, points))244 def test_with_two_segments_and_overlap_of_zero_units3(self):245 starts = [ 1, 5 ]246 ends = [ 3, 6 ]247 points = [ 1 ]248 self.assertEqual([ 1 ],249 self.method_under_test(starts, ends, points))250 def test_with_two_segments_and_overlap_of_zero_units4(self):251 starts = [ 1, 5 ]252 ends = [ 3, 6 ]253 points = [ 2 ]254 self.assertEqual([ 1 ],255 self.method_under_test(starts, ends, points))256 def test_with_two_segments_and_overlap_of_zero_units5(self):257 starts = [ 1, 5 ]258 ends = [ 3, 6 ]259 points = [ 3 ]260 self.assertEqual([ 1 ],261 self.method_under_test(starts, ends, points))262 def test_with_two_segments_and_overlap_of_zero_units6(self):263 starts = [ 1, 5 ]264 ends = [ 3, 6 ]265 points = [ 4 ]266 self.assertEqual([ 0 ],267 self.method_under_test(starts, ends, points))268 def test_with_two_segments_and_overlap_of_zero_units7(self):269 starts = [ 1, 5 ]270 ends = [ 3, 6 ]271 points = [ 5 ]272 self.assertEqual([ 1 ],273 self.method_under_test(starts, ends, points))274 def test_with_two_segments_and_overlap_of_zero_units8(self):275 starts = [ 1, 5 ]276 ends = [ 3, 6 ]277 points = [ 6 ]278 self.assertEqual([ 1 ],279 self.method_under_test(starts, ends, points))280 def test_with_two_segments_and_overlap_of_zero_units9(self):281 starts = [ 1, 5 ]282 ends = [ 3, 6 ]283 points = [ 7 ]284 self.assertEqual([ 0 ],285 self.method_under_test(starts, ends, points))286 def test_with_two_segments_and_overlap_of_zero_units10(self):287 starts = [ 1, 5 ]288 ends = [ 3, 6 ]289 points = [ -1, 0, 1, 2, 3, 4, 5, 6, 7 ]290 self.assertEqual([ 0, 0, 1, 1, 1, 0, 1, 1, 0 ],291 self.method_under_test(starts, ends, points))292 def test_with_two_segments_and_overlap_as_point1(self):293 starts = [ 1, 3 ]294 ends = [ 3, 6 ]295 points = [ -1 ]296 self.assertEqual([ 0 ],297 self.method_under_test(starts, ends, points))298 def test_with_two_segments_and_overlap_as_point2(self):299 starts = [ 1, 3 ]300 ends = [ 3, 6 ]301 points = [ 0 ]302 self.assertEqual([ 0 ],303 self.method_under_test(starts, ends, points))304 def test_with_two_segments_and_overlap_as_point3(self):305 starts = [ 1, 3 ]306 ends = [ 3, 6 ]307 points = [ 1 ]308 self.assertEqual([ 1 ],309 self.method_under_test(starts, ends, points))310 def test_with_two_segments_and_overlap_as_point4(self):311 starts = [ 1, 3 ]312 ends = [ 3, 6 ]313 points = [ 2 ]314 self.assertEqual([ 1 ],315 self.method_under_test(starts, ends, points))316 def test_with_two_segments_and_overlap_as_point5(self):317 starts = [ 1, 3 ]318 ends = [ 3, 6 ]319 points = [ 3 ]320 self.assertEqual([ 2 ],321 self.method_under_test(starts, ends, points))322 def test_with_two_segments_and_overlap_as_point6(self):323 starts = [ 1, 3 ]324 ends = [ 3, 6 ]325 points = [ 4 ]326 self.assertEqual([ 1 ],327 self.method_under_test(starts, ends, points))328 def test_with_two_segments_and_overlap_as_point7(self):329 starts = [ 1, 3 ]330 ends = [ 3, 6 ]331 points = [ 5 ]332 self.assertEqual([ 1 ],333 self.method_under_test(starts, ends, points))334 def test_with_two_segments_and_overlap_as_point8(self):335 starts = [ 1, 3 ]336 ends = [ 3, 6 ]337 points = [ 6 ]338 self.assertEqual([ 1 ],339 self.method_under_test(starts, ends, points))340 def test_with_two_segments_and_overlap_as_point9(self):341 starts = [ 1, 3 ]342 ends = [ 3, 6 ]343 points = [ 7 ]344 self.assertEqual([ 0 ],345 self.method_under_test(starts, ends, points))346 def test_with_two_segments_and_overlap_as_point10(self):347 starts = [ 1, 3 ]348 ends = [ 3, 6 ]349 points = [ -1, 0, 1, 2, 3, 4, 5, 6, 7 ]350 self.assertEqual([ 0, 0, 1, 1, 2, 1, 1, 1, 0 ],351 self.method_under_test(starts, ends, points))352 def test_with_two_segments_and_overlap_of_one_units1(self):353 starts = [ 1, 3 ]354 ends = [ 4, 6 ]355 points = [ -1 ]356 self.assertEqual([ 0 ],357 self.method_under_test(starts, ends, points))358 def test_with_two_segments_and_overlap_of_one_units2(self):359 starts = [ 1, 3 ]360 ends = [ 4, 6 ]361 points = [ 0 ]362 self.assertEqual([ 0 ],363 self.method_under_test(starts, ends, points))364 def test_with_two_segments_and_overlap_of_one_units3(self):365 starts = [ 1, 3 ]366 ends = [ 4, 6 ]367 points = [ 1 ]368 self.assertEqual([ 1 ],369 self.method_under_test(starts, ends, points))370 def test_with_two_segments_and_overlap_of_one_units4(self):371 starts = [ 1, 3 ]372 ends = [ 4, 6 ]373 points = [ 2 ]374 self.assertEqual([ 1 ],375 self.method_under_test(starts, ends, points))376 def test_with_two_segments_and_overlap_of_one_units5(self):377 starts = [ 1, 3 ]378 ends = [ 4, 6 ]379 points = [ 3 ]380 self.assertEqual([ 2 ],381 self.method_under_test(starts, ends, points))382 def test_with_two_segments_and_overlap_of_one_units6(self):383 starts = [ 1, 3 ]384 ends = [ 4, 6 ]385 points = [ 4 ]386 self.assertEqual([ 2 ],387 self.method_under_test(starts, ends, points))388 def test_with_two_segments_and_overlap_of_one_units7(self):389 starts = [ 1, 3 ]390 ends = [ 4, 6 ]391 points = [ 5 ]392 self.assertEqual([ 1 ],393 self.method_under_test(starts, ends, points))394 def test_with_two_segments_and_overlap_of_one_units8(self):395 starts = [ 1, 3 ]396 ends = [ 4, 6 ]397 points = [ 6 ]398 self.assertEqual([ 1 ],399 self.method_under_test(starts, ends, points))400 def test_with_two_segments_and_overlap_of_one_units9(self):401 starts = [ 1, 3 ]402 ends = [ 4, 6 ]403 points = [ 7 ]404 self.assertEqual([ 0 ],405 self.method_under_test(starts, ends, points))406 def test_with_two_segments_and_overlap_of_one_units10(self):407 starts = [ 1, 3 ]408 ends = [ 4, 6 ]409 points = [ -1, 0, 1, 2, 3, 4, 5, 6, 7 ]410 self.assertEqual([ 0, 0, 1, 1, 2, 2, 1, 1, 0 ],411 self.method_under_test(starts, ends, points))412 def test_with_two_segments_and_overlap_of_two_units1(self):413 starts = [ 1, 2 ]414 ends = [ 4, 6 ]415 points = [ -1 ]416 self.assertEqual([ 0 ],417 self.method_under_test(starts, ends, points))418 def test_with_two_segments_and_overlap_of_two_units2(self):419 starts = [ 1, 2 ]420 ends = [ 4, 6 ]421 points = [ 0 ]422 self.assertEqual([ 0 ],423 self.method_under_test(starts, ends, points))424 def test_with_two_segments_and_overlap_of_two_units3(self):425 starts = [ 1, 2 ]426 ends = [ 4, 6 ]427 points = [ 1 ]428 self.assertEqual([ 1 ],429 self.method_under_test(starts, ends, points))430 def test_with_two_segments_and_overlap_of_two_units4(self):431 starts = [ 1, 2 ]432 ends = [ 4, 6 ]433 points = [ 2 ]434 self.assertEqual([ 2 ],435 self.method_under_test(starts, ends, points))436 def test_with_two_segments_and_overlap_of_two_units5(self):437 starts = [ 1, 2 ]438 ends = [ 4, 6 ]439 points = [ 3 ]440 self.assertEqual([ 2 ],441 self.method_under_test(starts, ends, points))442 def test_with_two_segments_and_overlap_of_two_units6(self):443 starts = [ 1, 2 ]444 ends = [ 4, 6 ]445 points = [ 4 ]446 self.assertEqual([ 2 ],447 self.method_under_test(starts, ends, points))448 def test_with_two_segments_and_overlap_of_two_units7(self):449 starts = [ 1, 2 ]450 ends = [ 4, 6 ]451 points = [ 5 ]452 self.assertEqual([ 1 ],453 self.method_under_test(starts, ends, points))454 def test_with_two_segments_and_overlap_of_two_units8(self):455 starts = [ 1, 2 ]456 ends = [ 4, 6 ]457 points = [ 6 ]458 self.assertEqual([ 1 ],459 self.method_under_test(starts, ends, points))460 def test_with_two_segments_and_overlap_of_two_units9(self):461 starts = [ 1, 2 ]462 ends = [ 4, 6 ]463 points = [ 7 ]464 self.assertEqual([ 0 ],465 self.method_under_test(starts, ends, points))466 def test_with_two_segments_and_overlap_of_two_units10(self):467 starts = [ 1, 2 ]468 ends = [ 4, 6 ]469 points = [ -1, 0, 1, 2, 3, 4, 5, 6, 7 ]470 self.assertEqual([ 0, 0, 1, 2, 2, 2, 1, 1, 0 ],471 self.method_under_test(starts, ends, points))472 def test_with_two_segments_and_overlap_of_three_units1(self):473 starts = [ 1, 2 ]474 ends = [ 5, 6 ]475 points = [ -1 ]476 self.assertEqual([ 0 ],477 self.method_under_test(starts, ends, points))478 def test_with_two_segments_and_overlap_of_three_units2(self):479 starts = [ 1, 2 ]480 ends = [ 5, 6 ]481 points = [ 0 ]482 self.assertEqual([ 0 ],483 self.method_under_test(starts, ends, points))484 def test_with_two_segments_and_overlap_of_three_units3(self):485 starts = [ 1, 2 ]486 ends = [ 5, 6 ]487 points = [ 1 ]488 self.assertEqual([ 1 ],489 self.method_under_test(starts, ends, points))490 def test_with_two_segments_and_overlap_of_three_units4(self):491 starts = [ 1, 2 ]492 ends = [ 5, 6 ]493 points = [ 2 ]494 self.assertEqual([ 2 ],495 self.method_under_test(starts, ends, points))496 def test_with_two_segments_and_overlap_of_three_units5(self):497 starts = [ 1, 2 ]498 ends = [ 5, 6 ]499 points = [ 3 ]500 self.assertEqual([ 2 ],501 self.method_under_test(starts, ends, points))502 def test_with_two_segments_and_overlap_of_three_units6(self):503 starts = [ 1, 2 ]504 ends = [ 5, 6 ]505 points = [ 4 ]506 self.assertEqual([ 2 ],507 self.method_under_test(starts, ends, points))508 def test_with_two_segments_and_overlap_of_three_units7(self):509 starts = [ 1, 2 ]510 ends = [ 5, 6 ]511 points = [ 5 ]512 self.assertEqual([ 2 ],513 self.method_under_test(starts, ends, points))514 def test_with_two_segments_and_overlap_of_three_units8(self):515 starts = [ 1, 2 ]516 ends = [ 5, 6 ]517 points = [ 6 ]518 self.assertEqual([ 1 ],519 self.method_under_test(starts, ends, points))520 def test_with_two_segments_and_overlap_of_three_units9(self):521 starts = [ 1, 2 ]522 ends = [ 5, 6 ]523 points = [ 7 ]524 self.assertEqual([ 0 ],525 self.method_under_test(starts, ends, points))526 def test_with_two_segments_and_overlap_of_three_units10(self):527 starts = [ 1, 2 ]528 ends = [ 5, 6 ]529 points = [ -1, 0, 1, 2, 3, 4, 5, 6, 7 ]530 self.assertEqual([ 0, 0, 1, 2, 2, 2, 2, 1, 0 ],531 self.method_under_test(starts, ends, points))532 def test_with_two_segments_and_overlap_of_four_units1(self):533 starts = [ 1, 1 ]534 ends = [ 5, 6 ]535 points = [ -1 ]536 self.assertEqual([ 0 ],537 self.method_under_test(starts, ends, points))538 def test_with_two_segments_and_overlap_of_four_units2(self):539 starts = [ 1, 1 ]540 ends = [ 5, 6 ]541 points = [ 0 ]542 self.assertEqual([ 0 ],543 self.method_under_test(starts, ends, points))544 def test_with_two_segments_and_overlap_of_four_units3(self):545 starts = [ 1, 1 ]546 ends = [ 5, 6 ]547 points = [ 1 ]548 self.assertEqual([ 2 ],549 self.method_under_test(starts, ends, points))550 def test_with_two_segments_and_overlap_of_four_units4(self):551 starts = [ 1, 1 ]552 ends = [ 5, 6 ]553 points = [ 2 ]554 self.assertEqual([ 2 ],555 self.method_under_test(starts, ends, points))556 def test_with_two_segments_and_overlap_of_four_units5(self):557 starts = [ 1, 1 ]558 ends = [ 5, 6 ]559 points = [ 3 ]560 self.assertEqual([ 2 ],561 self.method_under_test(starts, ends, points))562 def test_with_two_segments_and_overlap_of_four_units6(self):563 starts = [ 1, 1 ]564 ends = [ 5, 6 ]565 points = [ 4 ]566 self.assertEqual([ 2 ],567 self.method_under_test(starts, ends, points))568 def test_with_two_segments_and_overlap_of_four_units7(self):569 starts = [ 1, 1 ]570 ends = [ 5, 6 ]571 points = [ 5 ]572 self.assertEqual([ 2 ],573 self.method_under_test(starts, ends, points))574 def test_with_two_segments_and_overlap_of_four_units8(self):575 starts = [ 1, 1 ]576 ends = [ 5, 6 ]577 points = [ 6 ]578 self.assertEqual([ 1 ],579 self.method_under_test(starts, ends, points))580 def test_with_two_segments_and_overlap_of_four_units9(self):581 starts = [ 1, 1 ]582 ends = [ 5, 6 ]583 points = [ 7 ]584 self.assertEqual([ 0 ],585 self.method_under_test(starts, ends, points))586 def test_with_two_segments_and_overlap_of_four_units10(self):587 starts = [ 1, 1 ]588 ends = [ 5, 6 ]589 points = [ -1, 0, 1, 2, 3, 4, 5, 6, 7 ]590 self.assertEqual([ 0, 0, 2, 2, 2, 2, 2, 1, 0 ],591 self.method_under_test(starts, ends, points))592 def test_with_two_segments_and_overlap_of_five_units1(self):593 starts = [ 1, 1 ]594 ends = [ 6, 6 ]595 points = [ -1 ]596 self.assertEqual([ 0 ],597 self.method_under_test(starts, ends, points))598 def test_with_two_segments_and_overlap_of_five_units2(self):599 starts = [ 1, 1 ]600 ends = [ 6, 6 ]601 points = [ 0 ]602 self.assertEqual([ 0 ],603 self.method_under_test(starts, ends, points))604 def test_with_two_segments_and_overlap_of_five_units3(self):605 starts = [ 1, 1 ]606 ends = [ 6, 6 ]607 points = [ 1 ]608 self.assertEqual([ 2 ],609 self.method_under_test(starts, ends, points))610 def test_with_two_segments_and_overlap_of_five_units4(self):611 starts = [ 1, 1 ]612 ends = [ 6, 6 ]613 points = [ 2 ]614 self.assertEqual([ 2 ],615 self.method_under_test(starts, ends, points))616 def test_with_two_segments_and_overlap_of_five_units5(self):617 starts = [ 1, 1 ]618 ends = [ 6, 6 ]619 points = [ 3 ]620 self.assertEqual([ 2 ],621 self.method_under_test(starts, ends, points))622 def test_with_two_segments_and_overlap_of_five_units6(self):623 starts = [ 1, 1 ]624 ends = [ 6, 6 ]625 points = [ 4 ]626 self.assertEqual([ 2 ],627 self.method_under_test(starts, ends, points))628 def test_with_two_segments_and_overlap_of_five_units7(self):629 starts = [ 1, 1 ]630 ends = [ 6, 6 ]631 points = [ 5 ]632 self.assertEqual([ 2 ],633 self.method_under_test(starts, ends, points))634 def test_with_two_segments_and_overlap_of_five_units8(self):635 starts = [ 1, 1 ]636 ends = [ 6, 6 ]637 points = [ 6 ]638 self.assertEqual([ 2 ],639 self.method_under_test(starts, ends, points))640 def test_with_two_segments_and_overlap_of_five_units9(self):641 starts = [ 1, 1 ]642 ends = [ 6, 6 ]643 points = [ 7 ]644 self.assertEqual([ 0 ],645 self.method_under_test(starts, ends, points))646 def test_with_two_segments_and_overlap_of_five_units10(self):647 starts = [ 1, 1 ]648 ends = [ 6, 6 ]649 points = [ -1, 0, 1, 2, 3, 4, 5, 6, 7 ]650 self.assertEqual([ 0, 0, 2, 2, 2, 2, 2, 2, 0 ],651 self.method_under_test(starts, ends, points))652 def test_with_three_segments_and_no_overlaps(self):653 starts = [ 1, 5, 9 ]654 ends = [ 3, 7, 11 ]655 points = [ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]656 self.assertEqual([ 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0 ],657 self.method_under_test(starts, ends, points))658 def test_with_three_segments_and_overlap_of_1_and_2_as_point(self):659 starts = [ 1, 3, 9 ]660 ends = [ 3, 7, 11 ]661 points = [ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]662 self.assertEqual([ 0, 0, 1, 1, 2, 1, 1, 1, 1, 0, 1, 1, 1, 0 ],663 self.method_under_test(starts, ends, points))664 def test_with_three_segments_and_overlap_of_1_and_2_as_segment(self):665 starts = [ 1, 2, 9 ]666 ends = [ 3, 7, 11 ]667 points = [ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]668 self.assertEqual([ 0, 0, 1, 2, 2, 1, 1, 1, 1, 0, 1, 1, 1, 0 ],669 self.method_under_test(starts, ends, points))670 def test_with_three_segments_and_overlap_of_2_and_3_as_point(self):671 starts = [ 1, 5, 7 ]672 ends = [ 3, 7, 11 ]673 points = [ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]674 self.assertEqual([ 0, 0, 1, 1, 1, 0, 1, 1, 2, 1, 1, 1, 1, 0 ],675 self.method_under_test(starts, ends, points))676 def test_with_three_segments_and_overlap_of_2_and_3_as_segment(self):677 starts = [ 1, 5, 6 ]678 ends = [ 3, 7, 11 ]679 points = [ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]680 self.assertEqual([ 0, 0, 1, 1, 1, 0, 1, 2, 2, 1, 1, 1, 1, 0 ],681 self.method_under_test(starts, ends, points))682 def test_with_three_segments_and_overlap_of_all_as_segments(self):683 starts = [ 1, 2, 6 ]684 ends = [ 3, 7, 11 ]685 points = [ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]686 self.assertEqual([ 0, 0, 1, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 0 ],687 self.method_under_test(starts, ends, points))688 def test_with_three_mixed_segments_and_no_overlaps(self):689 starts = [ -6, -2, 4 ]690 ends = [ -4, 2, 5 ]691 points = [ -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6 ]692 self.assertEqual([ 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0 ],693 self.method_under_test(starts, ends, points))694 def test_with_several_segments1(self):695 starts = [ 0, 7 ]696 ends = [ 5, 10 ]697 points = [ 1, 6, 11 ]698 self.assertEqual([ 1, 0, 0 ],699 self.method_under_test(starts, ends, points))700 def test_with_several_segments2(self):701 starts = [ -10 ]702 ends = [ 10 ]703 points = [ -100, 100, 0 ]704 self.assertEqual([ 0, 0, 1 ],705 self.method_under_test(starts, ends, points))706 def test_with_several_segments3(self):707 starts = [ 0, -3, 7 ]708 ends = [ 5, 2, 10 ]709 points = [ 1, 6 ]710 self.assertEqual([ 2, 0 ],711 self.method_under_test(starts, ends, points))712 def test_with_several_equal_segments1(self):713 starts = [ 0, 0, 0 ]714 ends = [ 0, 0, 0 ]715 points = [ -1, 0, 1 ]716 self.assertEqual([ 0, 3, 0 ],717 self.method_under_test(starts, ends, points))718 def test_with_several_equal_segments2(self):719 starts = [ 0, 0, 0 ]720 ends = [ 1, 1, 1 ]721 points = [ -1, 0, 1, 2 ]722 self.assertEqual([ 0, 3, 3, 0 ],723 self.method_under_test(starts, ends, points))724 def test_with_huge_segments1(self):725 """726 points: -69733398, -43390377, 46584909, -65149461, 79215411727 counts: 0, 0, 2, 0, 1728 starts: -28471239, -16651407, 26250551, 57356881, 90751725729 ends: -26580504, 95357651, 60037659, 70031990, 99598374730 """731 starts = [ 57356881, -28471239, 26250551, 90751725, -16651407 ]732 ends = [ 70031990, -26580504, 60037659, 99598374, 95357651 ]733 points = [ -69733398, -43390377, 46584909, -65149461, 79215411 ]734 self.assertEqual([ 0, 0, 2, 0, 1 ],735 self.method_under_test(starts, ends, points))736 def test_with_huge_segments2(self):737 starts = [ -82958095, -58513291, 16561991, -62195800, 69595351,738 -80465621, 67095560, 23525271, -15092577, -19366470 ]739 ends = [ -17876970, -56418445, 68393418, 1051277, 87501648,740 22270475, 72191430, 65728968, 2805348, 42444358 ]741 points = [ -68606013, 89174492, -74434082, -39578571, 57935890,742 -38499652, -11644735, 38455997, 20516305, 86791973 ]743 self.assertEqual([ 2, 0, 2, 3, 2, 3, 4, 3, 3, 1 ],744 self.method_under_test(starts, ends, points))745 def test_with_several_mixed_segments1(self):746 starts = [ -10, 3, 3, 8, 9 ]747 ends = [ 5, 9, 9, 10, 10 ]748 points = [ -4, 6, -8, -9 ]749 self.assertEqual([ 1, 2, 1, 1 ],750 self.method_under_test(starts, ends, points))751 def test_with_several_mixed_segments2(self):752 starts = [ -10, 3, 3, 8, 9 ]753 ends = [ 5, 9, 9, 10, 10 ]754 points = [ 3 ]755 self.assertEqual([ 3 ],756 self.method_under_test(starts, ends, points))757 def test_with_several_mixed_segments3(self):758 starts = [ -10, 3, 3, 8, 9 ]759 ends = [ 5, 9, 9, 10, 10 ]760 points = [ -4, 6, -8, 3, -9 ]761 self.assertEqual([ 1, 2, 1, 3, 1 ],762 self.method_under_test(starts, ends, points))763class NaiveCountSegmentsTestCase(CommonCountSegmentsTestCase):764 def setUp(self):765 self.method_under_test = naive_count_segments766 def tearDown(self):767 pass768class FastCountSegmentsTestCase(CommonCountSegmentsTestCase):769 def setUp(self):770 self.method_under_test = fast_count_segments771 def tearDown(self):772 pass773if __name__ == '__main__':774 class_names = \775 [776 NaiveCountSegmentsTestCase,777 FastCountSegmentsTestCase,778 ]779 suite = unittest.TestSuite()780 for c in class_names:781 suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(c))...
test_slow.py
Source:test_slow.py
...129 ends = []130 sort_segments(starts, ends)131 self.assertEqual([], starts)132 self.assertEqual([], ends)133 def test_with_duplicate_starts(self):134 starts = [ 5, 5, 5, 5, 5 ]135 ends = [ 3, 6, 2, 1, 7 ]136 sort_segments(starts, ends)137 self.assertEqual([ 5, 5, 5, 5, 5 ], starts)138 self.assertEqual([ 1, 2, 3, 6, 7 ], ends)139 def test_with_duplicate_ends(self):140 starts = [ 5, 4, 3, 2, 1 ]141 ends = [ 5, 5, 5, 5, 5 ]142 sort_segments(starts, ends)143 self.assertEqual([ 1, 2, 3, 4, 5 ], starts)144 self.assertEqual([ 5, 5, 5, 5, 5 ], ends)145 def test_with_duplicate_starts_and_ends(self):146 starts = [ 6, 6, 6, 6, 6 ]147 ends = [ 5, 5, 5, 5, 5 ]...
pythonBasics1Test.py
Source:pythonBasics1Test.py
1import pythonBasics12# main() is already set up to call the functions 3# we want to test with a few different inputs,4# printing 'OK' when each function is correct.5# the simple provided test() function used in main() to print6# what each function returns vs. what it's supposed to return.7def test(got, expected):8 if got == expected:9 prefix = ' OK '10 else:11 prefix = ' X '12 print ('%s got: %s expected: %s' % (prefix, repr(got), repr(expected)))13 14# Calls the functions in pythonBasics1 with interesting inputs.15def main():16 # set which functions to test17 check_starts_with = True18 check_starts_with_vowel = True19 check_max_min_sum = True20 if check_starts_with:21 print('starts_with')22 test(pythonBasics1.starts_with('vest','v'), True)23 test(pythonBasics1.starts_with('crypt','c'), True)24 test(pythonBasics1.starts_with('#python','#'), True)25 test(pythonBasics1.starts_with('hello','H'), False)26 test(pythonBasics1.starts_with('',' '), False)27 test(pythonBasics1.starts_with('1',''), False)28 test(pythonBasics1.starts_with('',''), True)29 test(pythonBasics1.starts_with(' ',' '), True)30 31 if check_starts_with_vowel:32 print()33 print('starts_with_vowel')34 test(pythonBasics1.starts_with_vowel('vest'), False)35 test(pythonBasics1.starts_with_vowel('east'), True)36 test(pythonBasics1.starts_with_vowel('Eat'), True)37 test(pythonBasics1.starts_with_vowel('Ice'), True)38 test(pythonBasics1.starts_with_vowel('in'), True)39 test(pythonBasics1.starts_with_vowel('at'), True)40 test(pythonBasics1.starts_with_vowel('All'), True)41 test(pythonBasics1.starts_with_vowel('on'), True)42 test(pythonBasics1.starts_with_vowel('Out'), True)43 test(pythonBasics1.starts_with_vowel('unlock'), True)44 test(pythonBasics1.starts_with_vowel('Unique'), True)45 test(pythonBasics1.starts_with_vowel(''), False)46 47 if check_max_min_sum:48 print()49 print('max_min_sum')50 test(pythonBasics1.max_min_sum([1,2,3,4,5]),6)51 test(pythonBasics1.max_min_sum([3,2,5,4,6]),8)52 test(pythonBasics1.max_min_sum([-1,0,-3,-99,-2]),-99)53 test(pythonBasics1.max_min_sum([6]),6)54 test(pythonBasics1.max_min_sum([]),0)55if __name__ == '__main__':...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!