#include #include #include "check.h" #include "core/types.h" #include "demo_scene.h" #include "render/frame_buffer.h" using kumo::FrameBuffer; using kumo_test::draw_demo_scene; using kumo_test::kDemoHeight; using kumo_test::kDemoWidth; // The hash of the demo picture. It must be the same on every platform, so a // change here is only right if the picture was changed on purpose. Then run // `kumoko test golden`, look at the picture in build/golden_demo.tga, and take // the new value from the failure message. constexpr uint64_t kExpectedHash = 0x635d63193c43fe8aull; TEST(demo_scene_has_the_expected_hash) { FrameBuffer frame(kDemoWidth, kDemoHeight); draw_demo_scene(frame); // Always saved, so that the picture can be looked at when the hash changes. CHECK(kumo::write_tga(frame, "build/golden_demo.tga")); const uint64_t hash = kumo::hash_pixels(frame); if (hash != kExpectedHash) { char message[96]; std::snprintf(message, sizeof(message), "hash is %016" PRIx64 ", expected %016" PRIx64, hash, kExpectedHash); kumo_test::fail(__FILE__, __LINE__, message); } } TEST(drawing_the_scene_twice_gives_the_same_picture) { FrameBuffer first(kDemoWidth, kDemoHeight); FrameBuffer second(kDemoWidth, kDemoHeight); draw_demo_scene(first); draw_demo_scene(second); CHECK(first.pixels == second.pixels); }