| 407 | // ---------------------------------------------------------------------------------------- |
| 408 | |
| 409 | void test_border_enumerator() |
| 410 | { |
| 411 | |
| 412 | |
| 413 | |
| 414 | border_enumerator be; |
| 415 | DLIB_TEST(be.at_start() == true); |
| 416 | DLIB_TEST(be.size() == 0); |
| 417 | DLIB_TEST(be.current_element_valid() == false); |
| 418 | DLIB_TEST(be.move_next() == false); |
| 419 | DLIB_TEST(be.at_start() == false); |
| 420 | DLIB_TEST(be.current_element_valid() == false); |
| 421 | DLIB_TEST(be.move_next() == false); |
| 422 | DLIB_TEST(be.at_start() == false); |
| 423 | DLIB_TEST(be.current_element_valid() == false); |
| 424 | DLIB_TEST(be.size() == 0); |
| 425 | |
| 426 | be = border_enumerator(rectangle(4,4,4,4),1); |
| 427 | DLIB_TEST(be.at_start() == true); |
| 428 | DLIB_TEST(be.size() == 1); |
| 429 | be = border_enumerator(rectangle(4,4,4,4),3); |
| 430 | DLIB_TEST(be.at_start() == true); |
| 431 | DLIB_TEST(be.size() == 1); |
| 432 | be = border_enumerator(rectangle(4,4,4,4),0); |
| 433 | DLIB_TEST(be.at_start() == true); |
| 434 | DLIB_TEST(be.size() == 0); |
| 435 | be = border_enumerator(rectangle(4,4,5,5),0); |
| 436 | DLIB_TEST(be.at_start() == true); |
| 437 | DLIB_TEST(be.size() == 0); |
| 438 | be = border_enumerator(rectangle(4,4,5,5),1); |
| 439 | DLIB_TEST(be.at_start() == true); |
| 440 | DLIB_TEST(be.size() == 4); |
| 441 | be = border_enumerator(rectangle(4,4,5,5),2); |
| 442 | DLIB_TEST(be.size() == 4); |
| 443 | be = border_enumerator(rectangle(4,4,6,6),1); |
| 444 | DLIB_TEST(be.size() == 8); |
| 445 | be = border_enumerator(rectangle(4,4,6,6),2); |
| 446 | DLIB_TEST(be.size() == 9); |
| 447 | be = border_enumerator(rectangle(4,4,6,6),3); |
| 448 | DLIB_TEST(be.size() == 9); |
| 449 | DLIB_TEST(be.at_start() == true); |
| 450 | |
| 451 | array2d<unsigned char> img, img2; |
| 452 | for (int size = 1; size < 10; ++size) |
| 453 | { |
| 454 | for (int bs = 0; bs < 4; ++bs) |
| 455 | { |
| 456 | img.set_size(size,size); |
| 457 | img2.set_size(size,size); |
| 458 | |
| 459 | assign_all_pixels(img, 1); |
| 460 | assign_all_pixels(img2, 1); |
| 461 | |
| 462 | zero_border_pixels(img2, bs,bs); |
| 463 | |
| 464 | be = border_enumerator(get_rect(img),bs); |
| 465 | DLIB_TEST(be.at_start() == true); |
| 466 | DLIB_TEST(be.current_element_valid() == false); |
no test coverage detected