MCPcopy Create free account
hub / github.com/CleverRaven/Cataclysm-DDA / check_sun_plot

Function check_sun_plot

tests/sun_test.cpp:558–591  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

556}
557
558static 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
593TEST_CASE( "movement_of_sun_through_day", "[sun]" )
594{

Callers 1

sun_test.cppFile · 0.85

Calls 6

string_splitFunction · 0.85
pop_backMethod · 0.80
sizeMethod · 0.45
countMethod · 0.45
strMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected