| 556 | } |
| 557 | |
| 558 | static void check_sun_plot( const std::vector<PointSet> &points, const std::string &reference ) |
| 559 | { |
| 560 | static constexpr std::array<char, 3> symbols = { { '#', '*', '-' } }; |
| 561 | REQUIRE( points.size() <= symbols.size() ); |
| 562 | |
| 563 | std::ostringstream os; |
| 564 | os << "Altitude\n"; |
| 565 | |
| 566 | for( int rough_altitude = 30; rough_altitude >= 0; --rough_altitude ) { |
| 567 | for( int rough_azimuth = 0; rough_azimuth <= 90; ++rough_azimuth ) { |
| 568 | std::pair<int, int> p{ rough_azimuth, rough_altitude }; |
| 569 | char c = ' '; |
| 570 | for( size_t i = 0; i < points.size(); ++i ) { |
| 571 | if( points[i].count( p ) ) { |
| 572 | c = symbols[i]; |
| 573 | break; |
| 574 | } |
| 575 | } |
| 576 | os << c; |
| 577 | } |
| 578 | os << '\n'; |
| 579 | } |
| 580 | os << std::setw( 92 ) << "Azimuth\n"; |
| 581 | std::string result = os.str(); |
| 582 | CHECK( result == reference ); |
| 583 | // When the test fails, print out something to copy-paste as a new |
| 584 | // reference output: |
| 585 | if( result != reference ) { |
| 586 | result.pop_back(); |
| 587 | for( const std::string &line : string_split( result, '\n' ) ) { |
| 588 | printf( R"("%s\n")" "\n", line.c_str() ); |
| 589 | } |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | TEST_CASE( "movement_of_sun_through_day", "[sun]" ) |
| 594 | { |
no test coverage detected