fix: msvc warnings & remove debug logs

This commit is contained in:
light7734 2026-01-09 21:53:37 +03:30
parent 53c99ad987
commit bda9bb3dce
24 changed files with 367 additions and 288 deletions

View file

@ -46,6 +46,8 @@ add_module(
vec3.cppm vec3.cppm
vec4.cppm vec4.cppm
components.cppm components.cppm
DEPENDENCIES
lt_debug
) )
add_module( add_module(

View file

@ -26,13 +26,15 @@ export void bake_shader(
// Don't bother linking to shaderc, just invoke the command with a system call. // Don't bother linking to shaderc, just invoke the command with a system call.
// NOLINTNEXTLINE(concurrency-mt-unsafe) // NOLINTNEXTLINE(concurrency-mt-unsafe)
std::system(std::format( std::system(
std::format(
"glslc --target-env=vulkan1.4 -std=450core -fshader-stage={} {} -o {}", "glslc --target-env=vulkan1.4 -std=450core -fshader-stage={} {} -o {}",
type == vertex ? "vert" : "frag", type == vertex ? "vert" : "frag",
glsl_path, glsl_path,
spv_path spv_path
) )
.c_str()); .c_str()
);
auto stream = std::ifstream(spv_path, std::ios::binary); auto stream = std::ifstream(spv_path, std::ios::binary);
lt::debug::ensure( lt::debug::ensure(
@ -48,7 +50,6 @@ export void bake_shader(
auto bytes = std::vector<std::byte>(size); auto bytes = std::vector<std::byte>(size);
stream.seekg(0, std::ios::beg); stream.seekg(0, std::ios::beg);
stream.read((char *)bytes.data(), size); // NOLINT stream.read((char *)bytes.data(), size); // NOLINT
lt::log::debug("BYTES: {}", bytes.size());
stream.close(); stream.close();
std::filesystem::remove(spv_path); std::filesystem::remove(spv_path);

View file

@ -1,5 +1,6 @@
export module assets.shader; export module assets.shader;
import assets.metadata; import assets.metadata;
import logger;
import debug.assertions; import debug.assertions;
import std; import std;
@ -109,6 +110,7 @@ ShaderAsset::ShaderAsset(const std::filesystem::path &path): m_stream(path)
read(m_asset_metadata.type); read(m_asset_metadata.type);
read(m_asset_metadata.version); read(m_asset_metadata.version);
read(m_metadata.type); read(m_metadata.type);
read(m_code_blob_metadata.tag); read(m_code_blob_metadata.tag);
read(m_code_blob_metadata.offset); read(m_code_blob_metadata.offset);
read(m_code_blob_metadata.compression_type); read(m_code_blob_metadata.compression_type);

View file

@ -1,5 +1,6 @@
import assets.metadata; import assets.metadata;
import assets.shader; import assets.shader;
import logger;
import test.test; import test.test;
import test.expects; import test.expects;
import std; import std;
@ -38,7 +39,7 @@ Suite packing = "shader_pack"_suite = [] {
Case { "" } = [] { Case { "" } = [] {
const auto out_path = tmp_path / "shader_packing"; const auto out_path = tmp_path / "shader_packing";
auto dummy_blob = lt::assets::Blob {}; auto dummy_blob = lt::assets::Blob {};
for (auto idx : std::views::iota(0, 255)) for (auto idx : std::views::iota(0u, 255u))
{ {
dummy_blob.emplace_back(static_cast<std::byte>(idx)); dummy_blob.emplace_back(static_cast<std::byte>(idx));
} }
@ -72,7 +73,7 @@ Suite packing = "shader_pack"_suite = [] {
}; };
expect_true(stream.is_open()); expect_true(stream.is_open());
stream.seekg(0, std::ios::end); stream.seekg(0u, std::ios::end);
const auto file_size = static_cast<std::size_t>(stream.tellg()); const auto file_size = static_cast<std::size_t>(stream.tellg());
expect_eq(file_size, expected_size); expect_eq(file_size, expected_size);
stream.close(); stream.close();
@ -87,9 +88,9 @@ Suite packing = "shader_pack"_suite = [] {
expect_eq(metadata.type, ShaderAsset::Type::vertex); expect_eq(metadata.type, ShaderAsset::Type::vertex);
auto blob = shader_asset.unpack(ShaderAsset::BlobTag::code); auto blob = shader_asset.unpack(ShaderAsset::BlobTag::code);
expect_eq(blob.size(), 255); expect_eq(blob.size(), 255u);
for (auto idx : std::views::iota(0, 255)) for (auto idx : std::views::iota(0u, 255u))
{ {
expect_eq(blob[idx], static_cast<std::byte>(idx)); expect_eq(blob[idx], static_cast<std::byte>(idx));
} }

View file

@ -68,6 +68,7 @@ Suite raii = "raii"_suite = [] {
Case { "many won't freeze/throw" } = [] { Case { "many won't freeze/throw" } = [] {
for (auto idx : std::views::iota(0, 100'000)) for (auto idx : std::views::iota(0, 100'000))
{ {
std::ignore = idx;
std::ignore = Registry {}; std::ignore = Registry {};
} }
}; };
@ -158,6 +159,7 @@ Suite callbacks = "callbacks"_suite = [] {
Case { "on_construct/on_destruct won't get called on unrelated component" } = [] { Case { "on_construct/on_destruct won't get called on unrelated component" } = [] {
auto registry = Registry {}; auto registry = Registry {};
registry.connect_on_construct<Component>([&](Registry &, EntityId) { registry.connect_on_construct<Component>([&](Registry &, EntityId) {
expect_unreachable(); expect_unreachable();
}); });
@ -167,6 +169,7 @@ Suite callbacks = "callbacks"_suite = [] {
for (auto idx : std::views::iota(0, 100'000)) for (auto idx : std::views::iota(0, 100'000))
{ {
std::ignore = idx;
registry.add<Component_B>(registry.create_entity(), {}); registry.add<Component_B>(registry.create_entity(), {});
} }
}; };
@ -188,6 +191,8 @@ Suite callbacks = "callbacks"_suite = [] {
expect_true(on_destruct_called.empty()); expect_true(on_destruct_called.empty());
for (auto idx : std::views::iota(0, 100'000)) for (auto idx : std::views::iota(0, 100'000))
{ {
std::ignore = idx;
auto entity = all_entities.emplace_back(registry.create_entity()); auto entity = all_entities.emplace_back(registry.create_entity());
registry.add<Component>(entity, {}); registry.add<Component>(entity, {});
} }

View file

@ -59,16 +59,11 @@ public:
); );
new_capacity = std::min(new_capacity, max_capacity); new_capacity = std::min(new_capacity, max_capacity);
// log::debug("Increasing sparse vector size:", m_dead_count);
// log::debug("\tdead_count: {}", m_dead_count);
// log::debug("\talive_count: {}", m_alive_count);
// log::debug("\tsparse.size: {} -> {}", m_sparse.size(), new_capacity);
m_sparse.resize(new_capacity, null_identifier); m_sparse.resize(new_capacity, null_identifier);
} }
++m_alive_count; ++m_alive_count;
m_sparse[identifier] = m_dense.size(); m_sparse[identifier] = static_cast<Identifier_T>(m_dense.size());
return m_dense.emplace_back(identifier, std::move(value)); return m_dense.emplace_back(identifier, std::move(value));
} }

View file

@ -12,7 +12,8 @@ using ::lt::test::expect_true;
using ::lt::test::Suite; using ::lt::test::Suite;
using ::lt::test::operator""_suite; using ::lt::test::operator""_suite;
using Set = lt::ecs::SparseSet<int>; using Value_T = int;
using Set = lt::ecs::SparseSet<Value_T>;
constexpr auto capacity = 100; constexpr auto capacity = 100;
Suite raii = "raii"_suite = [] { Suite raii = "raii"_suite = [] {
@ -97,7 +98,7 @@ Suite element_raii = "element_raii"_suite = [] {
for (auto &[identifier, value] : set) for (auto &[identifier, value] : set)
{ {
expect_eq(identifier, value); expect_eq(static_cast<Value_T>(identifier), value);
expect_ne(value, 0); expect_ne(value, 0);
expect_ne(value, 32); expect_ne(value, 32);
expect_ne(value, 69); expect_ne(value, 69);
@ -129,7 +130,7 @@ Suite getters = "getters"_suite = [] {
expect_eq(set.get_capacity(), 10'000); expect_eq(set.get_capacity(), 10'000);
set.insert(set.get_size(), {}); set.insert(static_cast<Value_T>(set.get_size()), {});
expect_ne(set.get_capacity(), 10'000); expect_ne(set.get_capacity(), 10'000);
}; };

View file

@ -158,8 +158,10 @@ void System::on_key_press(const lt::surface::KeyPressedEvent &event)
{ {
if (std::to_underlying(event.get_key()) > m_keys.size()) if (std::to_underlying(event.get_key()) > m_keys.size())
{ {
log::debug("Key code larger than key container size, implement platform-dependant " log::warn(
"key-code-mapping!"); "Key code larger than key container size, implement platform-dependant "
"key-code-mapping!"
);
return; return;
} }
@ -171,8 +173,10 @@ void System::on_key_release(const lt::surface::KeyReleasedEvent &event)
{ {
if (std::to_underlying(event.get_key()) > m_keys.size()) if (std::to_underlying(event.get_key()) > m_keys.size())
{ {
log::debug("Key code larger than key container size, implement platform-dependant " log::warn(
"key-code-mapping!"); "Key code larger than key container size, implement platform-dependant "
"key-code-mapping!"
);
return; return;
} }

View file

@ -79,6 +79,7 @@ Suite raii = "raii"_suite = "raii"_suite = [] {
auto fixture = Fixture {}; auto fixture = Fixture {};
for (auto idx : std::views::iota(0, 10'000)) for (auto idx : std::views::iota(0, 10'000))
{ {
std::ignore = idx;
ignore = System { fixture.registry() }; ignore = System { fixture.registry() };
} }
}; };
@ -115,7 +116,7 @@ Suite registry_events = "registry_events"_suite = [] {
auto registry = fixture.registry(); auto registry = fixture.registry();
auto system = System { registry }; auto system = System { registry };
const auto &entity = fixture.add_input_component(); fixture.add_input_component();
expect_eq(registry->view<InputComponent>().get_size(), 1); expect_eq(registry->view<InputComponent>().get_size(), 1);
}; };
@ -162,7 +163,7 @@ Suite tick = "tick"_suite = [] {
auto action_key = input.add_action( auto action_key = input.add_action(
{ {
.name { "test" }, .name { "test" },
.trigger = { .mapped_keycode = Key::A }, .trigger = { .mapped_keycode = Key::a },
} }
); );
@ -170,7 +171,7 @@ Suite tick = "tick"_suite = [] {
system.tick(tick_info()); system.tick(tick_info());
expect_eq(input.get_action(action_key).state, input::InputAction::State::inactive); expect_eq(input.get_action(action_key).state, input::InputAction::State::inactive);
surface.push_event(surface::KeyPressedEvent(Key::A)); surface.push_event(surface::KeyPressedEvent(Key::a));
system.tick(tick_info()); system.tick(tick_info());
expect_eq(input.get_action(action_key).state, input::InputAction::State::triggered); expect_eq(input.get_action(action_key).state, input::InputAction::State::triggered);
@ -182,28 +183,8 @@ Suite tick = "tick"_suite = [] {
system.tick(tick_info()); system.tick(tick_info());
expect_eq(input.get_action(action_key).state, input::InputAction::State::active); expect_eq(input.get_action(action_key).state, input::InputAction::State::active);
surface.push_event(surface::KeyReleasedEvent(Key::A)); surface.push_event(surface::KeyReleasedEvent(Key::a));
system.tick(tick_info()); system.tick(tick_info());
expect_eq(input.get_action(action_key).state, input::InputAction::State::inactive); expect_eq(input.get_action(action_key).state, input::InputAction::State::inactive);
}; };
Case { "Tick triggers" } = [] {
auto fixture = Fixture {};
auto registry = fixture.registry();
auto system = System { fixture.registry() };
auto surface_entity = fixture.add_surface_component();
auto &surface = registry->get<surface::SurfaceComponent>(surface_entity);
auto input_entity = fixture.add_input_component();
auto &input = registry->get<InputComponent>(input_entity);
auto action_key = input.add_action(
{
.name { "test" },
.trigger = { .mapped_keycode = Key::A },
}
);
};
}; };

View file

@ -4,17 +4,18 @@ import std;
export enum class Key: std::uint16_t { export enum class Key: std::uint16_t {
none = 0, none = 0,
left_mouse_button, left_button,
right_mouse_button, l_button = left_button,
middle_mouse_button,
left_mouse = left_mouse_button, right_button,
right_mouse = right_mouse_button, r_button = right_button,
middle_mouse = middle_mouse_button,
l_mouse = left_mouse_button, middle_button,
r_mouse = right_mouse_button, m_button = middle_button,
m_mouse = middle_mouse_button,
// the buttons on the sidse of some mouses
x_button_1,
x_button_2,
backspace, backspace,
tab, tab,
@ -87,7 +88,6 @@ export enum class Key: std::uint16_t {
digit_8, digit_8,
digit_9, digit_9,
/* letters */
a, a,
b, b,
c, c,
@ -140,7 +140,6 @@ export enum class Key: std::uint16_t {
kp_enter, kp_enter,
kp_equal, kp_equal,
/* function */
f1, f1,
f2, f2,
f3, f3,
@ -164,12 +163,13 @@ export [[nodiscard]] constexpr auto to_string(Key key) -> std::string
{ {
case none: return "<none>"; case none: return "<none>";
/* mouse */ case left_button: return "left_button";
case left_mouse_button: return "left_mouse_button"; case right_button: return "right_button";
case right_mouse_button: return "right_mouse_button"; case middle_button: return "middle_button";
case middle_mouse_button: return "middle_mouse_button";
case x_button_1: return "x_button_1";
case x_button_2: return "x_button_2";
/* editing / control */
case backspace: return "backspace"; case backspace: return "backspace";
case tab: return "tab"; case tab: return "tab";
case capslock: return "capslock"; case capslock: return "capslock";
@ -177,14 +177,12 @@ export [[nodiscard]] constexpr auto to_string(Key key) -> std::string
case space: return "space"; case space: return "space";
case delete_: return "delete"; case delete_: return "delete";
/* modifiers */
case shift: return "shift"; case shift: return "shift";
case control: return "control"; case control: return "control";
case right_control: return "right_control"; case right_control: return "right_control";
case alt: return "alt"; case alt: return "alt";
case right_alt: return "right_alt"; case right_alt: return "right_alt";
/* navigation */
case pageup: return "pageup"; case pageup: return "pageup";
case pagedown: return "pagedown"; case pagedown: return "pagedown";
case home: return "home"; case home: return "home";
@ -195,7 +193,6 @@ export [[nodiscard]] constexpr auto to_string(Key key) -> std::string
case right_arrow: return "right_arrow"; case right_arrow: return "right_arrow";
case down_arrow: return "down_arrow"; case down_arrow: return "down_arrow";
/* system */
case cancel: return "cancel"; case cancel: return "cancel";
case pause: return "pause"; case pause: return "pause";
case select: return "select"; case select: return "select";
@ -205,7 +202,6 @@ export [[nodiscard]] constexpr auto to_string(Key key) -> std::string
case help: return "help"; case help: return "help";
case sleep: return "sleep"; case sleep: return "sleep";
/* digits */
case digit_0: return "0"; case digit_0: return "0";
case digit_1: return "1"; case digit_1: return "1";
case digit_2: return "2"; case digit_2: return "2";
@ -217,7 +213,6 @@ export [[nodiscard]] constexpr auto to_string(Key key) -> std::string
case digit_8: return "8"; case digit_8: return "8";
case digit_9: return "9"; case digit_9: return "9";
/* letters */
case a: return "a"; case a: return "a";
case b: return "b"; case b: return "b";
case c: return "c"; case c: return "c";
@ -245,11 +240,9 @@ export [[nodiscard]] constexpr auto to_string(Key key) -> std::string
case y: return "y"; case y: return "y";
case z: return "z"; case z: return "z";
/* super / meta */
case super: return "super"; case super: return "super";
case right_super: return "right_super"; case right_super: return "right_super";
/* keypad */
case kp_0: return "kp_0"; case kp_0: return "kp_0";
case kp_1: return "kp_1"; case kp_1: return "kp_1";
case kp_2: return "kp_2"; case kp_2: return "kp_2";
@ -268,7 +261,6 @@ export [[nodiscard]] constexpr auto to_string(Key key) -> std::string
case kp_enter: return "kp_enter"; case kp_enter: return "kp_enter";
case kp_equal: return "kp_equal"; case kp_equal: return "kp_equal";
/* function keys */
case f1: return "f1"; case f1: return "f1";
case f2: return "f2"; case f2: return "f2";
case f3: return "f3"; case f3: return "f3";

View file

@ -48,7 +48,7 @@ struct [[maybe_unused]] print
Args &&...arguments Args &&...arguments
) noexcept ) noexcept
{ {
constexpr auto to_string = [](Level level, auto location) { constexpr auto to_string = [](Level level) {
// clang-format off // clang-format off
switch (level) switch (level)
{ {
@ -70,7 +70,7 @@ struct [[maybe_unused]] print
std::println( std::println(
"{} {} ==> {}", "{} {} ==> {}",
to_string(level, location), to_string(level),
std::format("{}:{}", path.filename().string(), location.line()), std::format("{}:{}", path.filename().string(), location.line()),
std::format(format, std::forward<Args>(arguments)...) std::format(format, std::forward<Args>(arguments)...)
); );

View file

@ -74,7 +74,7 @@ struct mat4_impl
return vec4_impl<T> {}; return vec4_impl<T> {};
} }
std::array<Column_T, 4> values; // NOLINT std::array<Column_T, 4u> values;
}; };
export template<typename T> export template<typename T>

View file

@ -1,5 +1,6 @@
export module math.vec4; export module math.vec4;
import math.vec2; import math.vec2;
import debug.assertions;
import math.vec3; import math.vec3;
import std; import std;
@ -8,6 +9,8 @@ namespace lt::math {
export template<typename T = float> export template<typename T = float>
struct vec4_impl struct vec4_impl
{ {
static constexpr auto num_elements = 4u;
constexpr vec4_impl(): x(), y(), z(), w() constexpr vec4_impl(): x(), y(), z(), w()
{ {
} }
@ -40,14 +43,18 @@ struct vec4_impl
}; };
} }
[[nodiscard]] constexpr auto operator[](std::size_t idx) -> T & [[nodiscard]] constexpr auto operator[](std::uint8_t idx) -> T &
{ {
return values[idx]; // TODO(Light): Use contract
debug::ensure(idx <= num_elements, "vec4 out of bound: {}", idx);
return ((T *)this)[idx];
} }
[[nodiscard]] constexpr auto operator[](std::size_t idx) const -> const T & [[nodiscard]] constexpr auto operator[](std::uint8_t idx) const -> const T &
{ {
return values[idx]; // TODO(Light): Use contract
debug::ensure(idx < num_elements, "vec4 out of bound: {}", idx);
return ((T *)this)[idx];
} }
friend auto operator<<(std::ostream &stream, vec4_impl<T> value) -> std::ostream & friend auto operator<<(std::ostream &stream, vec4_impl<T> value) -> std::ostream &
@ -56,11 +63,6 @@ struct vec4_impl
return stream; return stream;
} }
// NOLINTNEXTLINE
union
{
struct
{
T x; T x;
T y; T y;
@ -69,22 +71,6 @@ struct vec4_impl
T w; T w;
}; };
struct
{
T r;
T g;
T b;
T a;
};
struct
{
std::array<T, 4> values;
};
};
};
export using vec4 = vec4_impl<float>; export using vec4 = vec4_impl<float>;

View file

@ -37,7 +37,7 @@ void renderer_callback(
std::ignore = message_type; std::ignore = message_type;
std::ignore = user_data; std::ignore = user_data;
log::debug("RENDERER CALLBACK: {}", std::string { data.message }); log::trace("< Renderer > ==> {}", std::string { data.message });
} }
class MirrorSystem: public lt::app::ISystem class MirrorSystem: public lt::app::ISystem

View file

@ -35,10 +35,10 @@ constexpr auto frames_in_flight = std::uint32_t { 3u };
void noop_messenger_callback( void noop_messenger_callback(
lt::renderer::IDebugger::MessageSeverity severity, lt::renderer::IDebugger::MessageSeverity,
lt::renderer::IDebugger::MessageType type, lt::renderer::IDebugger::MessageType,
const lt::renderer::IDebugger::MessageData &data, const lt::renderer::IDebugger::MessageData &,
std::any &user_data std::any &
) )
{ {
} }

View file

@ -2944,11 +2944,11 @@ void load_library()
"Failed to load vulkan function: vkGetInstanceProcAddr" "Failed to load vulkan function: vkGetInstanceProcAddr"
); );
#elif defined(LIGHT_PLATFORM_WINDOWS) #elif defined(LIGHT_PLATFORM_WINDOWS)
auto library = LoadLibraryA("vulkan-1.dll"); library = LoadLibraryA("vulkan-1.dll");
lt::debug::ensure(library, "Failed to LoadLibraryA the vulkan-1.dll"); lt::debug::ensure(library, "Failed to LoadLibraryA the vulkan-1.dll");
api::get_instance_proc_address = std::bit_cast<PFN_vkGetInstanceProcAddr>( api::get_instance_proc_address = std::bit_cast<PFN_vkGetInstanceProcAddr>(
GetProcAddress(library, "vkGetInstanceProcAddr") GetProcAddress(std::bit_cast<HMODULE>(library), "vkGetInstanceProcAddr")
); );
lt::debug::ensure( lt::debug::ensure(
api::get_instance_proc_address, api::get_instance_proc_address,
@ -3883,7 +3883,7 @@ void Device::reset_fence(VkFence fence) const
void Device::reset_fences(std::span<VkFence> fences) const void Device::reset_fences(std::span<VkFence> fences) const
{ {
vkc(api::reset_fences(m_device, fences.size(), fences.data())); vkc(api::reset_fences(m_device, static_cast<uint32_t>(fences.size()), fences.data()));
} }
auto Device::acquire_image(VkSwapchainKHR swapchain, VkSemaphore semaphore, uint64_t timeout) auto Device::acquire_image(VkSwapchainKHR swapchain, VkSemaphore semaphore, uint64_t timeout)
@ -3917,7 +3917,7 @@ void Device::wait_for_fences(std::span<VkFence> fences) const
{ {
vkc(api::wait_for_fences( vkc(api::wait_for_fences(
m_device, m_device,
fences.size(), static_cast<uint32_t>(fences.size()),
fences.data(), fences.data(),
true, true,
std::numeric_limits<uint64_t>::max() std::numeric_limits<uint64_t>::max()
@ -4274,6 +4274,9 @@ void Queue::present(PresentInfo info) const
Image::Image(Device &device, CreateInfo info): m_device(device.get_vk_handle()), m_image() Image::Image(Device &device, CreateInfo info): m_device(device.get_vk_handle()), m_image()
{ {
// WIP(Light): use image create info's info
std::ignore = info;
auto vk_info = VkImageCreateInfo {}; auto vk_info = VkImageCreateInfo {};
vkc(api::create_image(m_device, &vk_info, nullptr, &m_image)); vkc(api::create_image(m_device, &vk_info, nullptr, &m_image));
} }
@ -4337,6 +4340,9 @@ CommandBuffer::CommandBuffer(VkCommandBuffer buffer): m_buffer(buffer)
void CommandBuffer::begin(BeginInfo info /* = {} */) void CommandBuffer::begin(BeginInfo info /* = {} */)
{ {
// WIP(Light): Use info
std::ignore = info;
auto vk_info = VkCommandBufferBeginInfo { auto vk_info = VkCommandBufferBeginInfo {
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
.pNext = {}, .pNext = {},
@ -4937,11 +4943,12 @@ Pipeline::Pipeline(Device &device, PipelineLayout &layout, CreateInfo info)
auto color_attachment_formats = std::vector<vk::Format> {}; auto color_attachment_formats = std::vector<vk::Format> {};
// WIP(Light): use color attachments
for (auto &color_attachment : info.attachment_state.color_attachments) for (auto &color_attachment : info.attachment_state.color_attachments)
{ {
std::ignore = color_attachment;
} }
auto rendering_info = VkPipelineRenderingCreateInfoKHR { auto rendering_info = VkPipelineRenderingCreateInfoKHR {
.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO,
.colorAttachmentCount = static_cast<uint32_t>(color_attachment_formats.size()), .colorAttachmentCount = static_cast<uint32_t>(color_attachment_formats.size()),

View file

@ -35,9 +35,10 @@ public:
{ {
m_device->vk().wait_idle(); m_device->vk().wait_idle();
} }
catch (std::exception &exp) catch (const std::exception &exp)
{ {
log::error("Failed to wait idle on device in renderer destructor"); log::error("Failed to wait idle on device in renderer destructor:");
log::error("\twhat: {}", exp.what());
} }
} }
@ -193,6 +194,9 @@ Renderer::Renderer(
frame_fence.reset(); frame_fence.reset();
map_buffers(frame_idx); map_buffers(frame_idx);
// WIP(Light): submit the scene!
std::ignore = submit_scene;
// submit_scene(); // submit_scene();
record_cmd(cmd, image_idx); record_cmd(cmd, image_idx);

View file

@ -81,8 +81,6 @@ Swapchain::Swapchain(ISurface *surface, IGpu *gpu, IDevice *device)
, m_gpu(static_cast<Gpu *>(gpu)) , m_gpu(static_cast<Gpu *>(gpu))
, m_device(static_cast<Device *>(device)) , m_device(static_cast<Device *>(device))
{ {
static auto idx = 0u;
auto capabilities = m_gpu->vk().get_surface_capabilities(m_surface->vk()); auto capabilities = m_gpu->vk().get_surface_capabilities(m_surface->vk());
const auto formats = m_gpu->vk().get_surface_formats(m_surface->vk()); const auto formats = m_gpu->vk().get_surface_formats(m_surface->vk());
@ -104,6 +102,7 @@ Swapchain::Swapchain(ISurface *surface, IGpu *gpu, IDevice *device)
capabilities.current_extent.y = 600u; capabilities.current_extent.y = 600u;
} }
static auto swapchain_idx = 0u;
m_swapchain = vk::Swapchain( m_swapchain = vk::Swapchain(
m_device->vk(), m_device->vk(),
m_surface->vk(), m_surface->vk(),
@ -116,7 +115,7 @@ Swapchain::Swapchain(ISurface *surface, IGpu *gpu, IDevice *device)
.queue_family_indices = m_device->get_family_indices(), .queue_family_indices = m_device->get_family_indices(),
.present_mode = vk::Swapchain::PresentMode::mailbox, .present_mode = vk::Swapchain::PresentMode::mailbox,
.pre_transform = capabilities.current_transform, .pre_transform = capabilities.current_transform,
.name = std::format("swapchain {}", idx++), .name = std::format("swapchain {}", swapchain_idx++),
} }
); );
m_resolution = capabilities.current_extent; m_resolution = capabilities.current_extent;

View file

@ -37,7 +37,7 @@ int main()
auto timer = lt::time::Timer {}; auto timer = lt::time::Timer {};
lt::log::trace("Ticking for 3 seconds..."); lt::log::trace("Ticking for 3 seconds...");
while (timer.elapsed_time() < std::chrono::seconds { 3 }) while (timer.elapsed_time() < std::chrono::seconds { 30 })
{ {
system.tick({}); system.tick({});
} }

View file

@ -527,6 +527,125 @@ void System::tick(app::TickInfo tick)
#ifdef LIGHT_PLATFORM_WINDOWS #ifdef LIGHT_PLATFORM_WINDOWS
constexpr auto translate_key(auto code) -> Key
{
using enum Key;
switch (code)
{
case VK_LBUTTON: return left_button;
case VK_RBUTTON: return right_button;
case VK_MBUTTON: return middle_button;
case VK_BACK: return backspace;
case VK_TAB: return tab;
case VK_CAPITAL: return capslock;
case VK_RETURN: return enter;
case VK_SPACE: return space;
case VK_DELETE: return delete_;
case VK_SHIFT: return shift;
case VK_RSHIFT: return right_shift;
case VK_CONTROL: return control;
case VK_RCONTROL: return right_control;
case VK_MENU: return alt;
case VK_RMENU: return right_alt;
case VK_PRIOR: return pageup;
case VK_NEXT: return pagedown;
case VK_END: return end;
case VK_HOME: return home;
case VK_LEFT: return left_arrow;
case VK_RIGHT: return right_arrow;
case VK_DOWN: return down_arrow;
case VK_UP: return up_arrow;
case VK_CANCEL: return cancel;
case VK_PAUSE: return pause;
case VK_SELECT: return select;
case VK_PRINT: return print;
case VK_SNAPSHOT: return snapshot;
case VK_INSERT: return insert;
case VK_HELP: return help;
case VK_SLEEP: return sleep;
case '0': return digit_0;
case '1': return digit_1;
case '2': return digit_2;
case '3': return digit_3;
case '4': return digit_4;
case '5': return digit_5;
case '6': return digit_6;
case '7': return digit_7;
case '8': return digit_8;
case '9': return digit_9;
case 'A': return a;
case 'B': return b;
case 'C': return c;
case 'D': return d;
case 'E': return e;
case 'F': return f;
case 'G': return g;
case 'H': return h;
case 'I': return i;
case 'J': return j;
case 'K': return k;
case 'L': return l;
case 'M': return m;
case 'N': return n;
case 'O': return o;
case 'P': return p;
case 'Q': return q;
case 'R': return r;
case 'S': return s;
case 'T': return t;
case 'U': return u;
case 'V': return v;
case 'W': return w;
case 'X': return x;
case 'Y': return y;
case 'Z': return z;
case VK_LWIN: return super;
case VK_RWIN: return right_super;
case VK_NUMPAD0: return kp_0;
case VK_NUMPAD1: return kp_1;
case VK_NUMPAD2: return kp_2;
case VK_NUMPAD3: return kp_3;
case VK_NUMPAD4: return kp_4;
case VK_NUMPAD5: return kp_5;
case VK_NUMPAD6: return kp_6;
case VK_NUMPAD7: return kp_7;
case VK_NUMPAD8: return kp_8;
case VK_NUMPAD9: return kp_9;
case VK_MULTIPLY: return kp_multiply;
case VK_ADD: return kp_add;
case VK_SUBTRACT: return kp_subtract;
case VK_DECIMAL: return kp_decimal;
case VK_F1: return f1;
case VK_F2: return f2;
case VK_F3: return f3;
case VK_F4: return f4;
case VK_F5: return f5;
case VK_F6: return f6;
case VK_F7: return f7;
case VK_F8: return f8;
case VK_F9: return f9;
case VK_F10: return f10;
case VK_F11: return f11;
case VK_F12: return f12;
default: return unknown;
}
};
template<class... Ts> template<class... Ts>
struct overloads: Ts... struct overloads: Ts...
{ {
@ -535,7 +654,7 @@ struct overloads: Ts...
void ensure_component_sanity(const SurfaceComponent &component); void ensure_component_sanity(const SurfaceComponent &component);
auto CALLBACK native_window_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -> LRESULT; auto CALLBACK window_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -> LRESULT;
System::System(memory::Ref<ecs::Registry> registry): m_registry(std::move(registry)) System::System(memory::Ref<ecs::Registry> registry): m_registry(std::move(registry))
{ {
@ -553,7 +672,7 @@ System::System(memory::Ref<ecs::Registry> registry): m_registry(std::move(regist
); );
auto window_class = WNDCLASS { auto window_class = WNDCLASS {
.lpfnWndProc = native_window_proc, .lpfnWndProc = window_proc,
.hInstance = GetModuleHandle(nullptr), .hInstance = GetModuleHandle(nullptr),
.lpszClassName = constants::class_name, .lpszClassName = constants::class_name,
}; };
@ -602,11 +721,17 @@ void System::on_unregister()
void System::create_surface_component(ecs::EntityId entity, SurfaceComponent::CreateInfo info) void System::create_surface_component(ecs::EntityId entity, SurfaceComponent::CreateInfo info)
try try
{ {
// WIP(Light): use ignored local variables...
auto &component = m_registry->add<SurfaceComponent>(entity, info); auto &component = m_registry->add<SurfaceComponent>(entity, info);
std::ignore = component;
auto &surface = m_registry->get<SurfaceComponent>(entity); auto &surface = m_registry->get<SurfaceComponent>(entity);
ensure_component_sanity(surface);
const auto &resolution = surface.get_resolution(); const auto &resolution = surface.get_resolution();
const auto &position = surface.get_position(); const auto &position = surface.get_position();
ensure_component_sanity(surface); std::ignore = resolution;
std::ignore = position;
surface.m_native_data.window = CreateWindowEx( surface.m_native_data.window = CreateWindowEx(
0, 0,
@ -625,6 +750,9 @@ try
debug::ensure(surface.m_native_data.window, "Failed to create Windows surface component"); debug::ensure(surface.m_native_data.window, "Failed to create Windows surface component");
ShowWindow(surface.m_native_data.window, SW_NORMAL); ShowWindow(surface.m_native_data.window, SW_NORMAL);
// SetWindowLongPtrA(surface.m_native_data.window, 0, this);
// SetWindowLongPtrA(surface.m_native_data.window, 1, entity);
// TODO(Light): refactor "environment" into standalone module // TODO(Light): refactor "environment" into standalone module
// NOLINTNEXTLINE(concurrency-mt-unsafe) // NOLINTNEXTLINE(concurrency-mt-unsafe)
@ -726,15 +854,65 @@ void System::handle_events(SurfaceComponent &surface)
queue.clear(); queue.clear();
auto message = MSG {}; auto message = MSG {};
while (PeekMessage(&message, surface.m_native_data.window, {}, {}, PM_REMOVE)) while (PeekMessage(&message, {}, {}, {}, PM_REMOVE))
{ {
TranslateMessage(&message);
const auto wParam = message.wParam;
switch (message.message) switch (message.message)
{ {
case WM_SETFOCUS: log::debug("Window setfocus"); break;
case WM_KILLFOCUS: log::debug("Window killfocus"); break;
case WM_ACTIVATE:
log::debug("Window activate: {}", static_cast<std::size_t>(LOWORD(wParam)));
break;
case WM_MOUSEWHEEL:
{
const auto delta = GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA;
log::debug("wheel delta: {}", static_cast<std::int64_t>(delta));
break;
}
case WM_LBUTTONDOWN:
log::debug("Left button down: {}", to_string(translate_key(wParam)));
break;
case WM_LBUTTONUP: log::debug("Left button up {}", to_string(translate_key(wParam))); break;
case WM_RBUTTONDOWN:
log::debug("Right button down {}", to_string(translate_key(wParam)));
break;
case WM_RBUTTONUP:
log::debug("Right button up {}", to_string(translate_key(wParam)));
break;
case WM_MBUTTONDOWN:
log::debug("Middle button down {}", to_string(translate_key(wParam)));
break;
case WM_MBUTTONUP:
log::debug("Middle button up {}", to_string(translate_key(wParam)));
break;
case WM_XBUTTONDOWN:
{
const auto key = static_cast<Key>(
std::to_underlying(Key::x_button_1) + GET_XBUTTON_WPARAM(wParam) - 1
);
log::debug("xbutn: {}", std::to_underlying(key));
break;
}
case WM_XBUTTONUP:
{
const auto key = static_cast<Key>(
std::to_underlying(Key::x_button_1) + GET_XBUTTON_WPARAM(wParam) - 1
);
log::debug("xbutn: {}", std::to_underlying(key));
break;
}
case WM_KEYDOWN: log::debug("Keydown: {}", to_string(translate_key(wParam))); break;
case WM_KEYUP: log::debug("Keyup__: {}", to_string(translate_key(wParam))); break;
} }
TranslateMessage(&message);
DispatchMessage(&message); DispatchMessage(&message);
// log::debug("Window message type: {}", std::uint32_t { message.message });
} }
// auto event = XEvent {}; // auto event = XEvent {};
@ -852,6 +1030,10 @@ void System::handle_requests(SurfaceComponent &surface)
void System::modify_title(SurfaceComponent &surface, const ModifyTitleRequest &request) void System::modify_title(SurfaceComponent &surface, const ModifyTitleRequest &request)
{ {
// WIP(Light):
std::ignore = surface;
std::ignore = request;
surface.m_title = request.title; surface.m_title = request.title;
// const auto &[display, window, _] = surface.get_native_data(); // const auto &[display, window, _] = surface.get_native_data();
@ -860,6 +1042,10 @@ void System::modify_title(SurfaceComponent &surface, const ModifyTitleRequest &r
void System::modify_resolution(SurfaceComponent &surface, const ModifyResolutionRequest &request) void System::modify_resolution(SurfaceComponent &surface, const ModifyResolutionRequest &request)
{ {
// WIP(Light):
std::ignore = surface;
std::ignore = request;
// surface.m_resolution = request.resolution; // surface.m_resolution = request.resolution;
// auto &[display, window, _] = surface.m_native_data; // auto &[display, window, _] = surface.m_native_data;
@ -922,6 +1108,10 @@ void System::modify_resolution(SurfaceComponent &surface, const ModifyResolution
void System::modify_position(SurfaceComponent &surface, const ModifyPositionRequest &request) void System::modify_position(SurfaceComponent &surface, const ModifyPositionRequest &request)
{ {
// WIP(Light): Use ignored local-variables
std::ignore = surface;
std::ignore = request;
// surface.m_position = request.position; // surface.m_position = request.position;
// auto &[display, window, _] = surface.m_native_data; // auto &[display, window, _] = surface.m_native_data;
@ -961,6 +1151,10 @@ void System::modify_position(SurfaceComponent &surface, const ModifyPositionRequ
void System::modify_visiblity(SurfaceComponent &surface, const ModifyVisibilityRequest &request) void System::modify_visiblity(SurfaceComponent &surface, const ModifyVisibilityRequest &request)
{ {
// WIP(Light): Use ignored local-variables
std::ignore = surface;
std::ignore = request;
// const auto &[display, window, _] = surface.get_native_data(); // const auto &[display, window, _] = surface.get_native_data();
// surface.m_visible = request.visible; // surface.m_visible = request.visible;
@ -1024,139 +1218,27 @@ void ensure_component_sanity(const SurfaceComponent &component)
); );
} }
auto CALLBACK native_window_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -> LRESULT auto CALLBACK window_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -> LRESULT
{ {
constexpr auto translate_key = [](auto code) -> Key {
switch (code)
{
using enum Key;
case VK_LBUTTON: return left_mouse_button;
case VK_RBUTTON: return right_mouse_button;
case VK_MBUTTON: return middle_mouse_button;
case VK_BACK: return backspace;
case VK_TAB: return tab;
case VK_CAPITAL: return capslock;
case VK_RETURN: enter;
case VK_SPACE: space;
case VK_DELETE: return delete_;
case VK_SHIFT: shift;
case VK_RSHIFT: right_shift;
case VK_CONTROL: control;
case VK_RCONTROL: right_control;
case VK_MENU: alt;
case VK_RMENU: right_alt;
case VK_PRIOR: return pageup;
case VK_NEXT: return pagedown;
case VK_END: return end;
case VK_HOME: return home;
case VK_LEFT: return left_arrow;
case VK_RIGHT: return right_arrow;
case VK_DOWN: return down_arrow;
case VK_UP: return up_arrow;
case VK_CANCEL: return cancel;
case VK_PAUSE: return pause;
case VK_SELECT: return select;
case VK_PRINT: return print;
case VK_SNAPSHOT: return snapshot;
case VK_INSERT: return insert;
case VK_HELP: return help;
case VK_SLEEP: return sleep;
case '0': return digit_0;
case '1': return digit_1;
case '2': return digit_2;
case '3': return digit_3;
case '4': return digit_4;
case '5': return digit_5;
case '6': return digit_6;
case '7': return digit_7;
case '8': return digit_8;
case '9': return digit_9;
case 'A': return a;
case 'B': return b;
case 'C': return c;
case 'D': return d;
case 'E': return e;
case 'F': return f;
case 'G': return g;
case 'H': return h;
case 'I': return i;
case 'J': return j;
case 'K': return k;
case 'L': return l;
case 'M': return m;
case 'N': return n;
case 'O': return o;
case 'P': return p;
case 'Q': return q;
case 'R': return r;
case 'S': return s;
case 'T': return t;
case 'U': return u;
case 'V': return v;
case 'W': return w;
case 'X': return x;
case 'Y': return y;
case 'Z': return z;
case VK_LWIN: return super;
case VK_RWIN: return right_super;
case VK_NUMPAD0: return kp_0;
case VK_NUMPAD1: return kp_1;
case VK_NUMPAD2: return kp_2;
case VK_NUMPAD3: return kp_3;
case VK_NUMPAD4: return kp_4;
case VK_NUMPAD5: return kp_5;
case VK_NUMPAD6: return kp_6;
case VK_NUMPAD7: return kp_7;
case VK_NUMPAD8: return kp_8;
case VK_NUMPAD9: return kp_9;
case VK_MULTIPLY: return kp_multiply;
case VK_ADD: return kp_add;
case VK_SUBTRACT: return kp_subtract;
case VK_DECIMAL: return kp_decimal;
case VK_F1: return f1;
case VK_F2: return f2;
case VK_F3: return f3;
case VK_F4: return f4;
case VK_F5: return f5;
case VK_F6: return f6;
case VK_F7: return f7;
case VK_F8: return f8;
case VK_F9: return f9;
case VK_F10: return f10;
case VK_F11: return f11;
case VK_F12: return f12;
default: return unknown;
}
};
switch (uMsg) switch (uMsg)
{ {
case WM_KEYDOWN: log::debug("Keydown: {}", to_string(translate_key(wParam))); case WM_KILLFOCUS:
case WM_KEYUP: log::debug("Keyup__: {}", to_string(translate_key(wParam))); case WM_SETFOCUS: log::debug("GOT FOCUS IN WIN PROC");
case WM_DESTROY: case WM_ACTIVATE:
{ case WM_MOUSEWHEEL:
PostQuitMessage(0); case WM_LBUTTONDOWN:
return 0; case WM_LBUTTONUP:
} case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_XBUTTONDOWN:
case WM_XBUTTONUP:
case WM_KEYDOWN:
case WM_KEYUP: return 0;
case WM_DESTROY: PostQuitMessage(0); return 0;
} }
// log::debug("Window message type (window proc): {}", std::uint32_t { uMsg
// });
return DefWindowProcA(hwnd, uMsg, wParam, lParam); return DefWindowProcA(hwnd, uMsg, wParam, lParam);
} }

View file

@ -31,6 +31,7 @@ export void expect_unreachable(
}; };
}; };
/** @todo(Light7734): Check exception type. */
export constexpr void expect_throw( export constexpr void expect_throw(
std::invocable auto invocable, std::invocable auto invocable,
std::source_location source_location = std::source_location::current() std::source_location source_location = std::source_location::current()
@ -40,7 +41,7 @@ export constexpr void expect_throw(
{ {
invocable(); invocable();
} }
catch (const std::exception &exp) catch (const std::exception &)
{ {
return; return;
} }

View file

@ -108,6 +108,9 @@ constexpr TestFuzzHarness::TestFuzzHarness(auto body)
auto operator""_suite(const char *name, std::size_t size) -> TestSuite auto operator""_suite(const char *name, std::size_t size) -> TestSuite
{ {
// TODO(Light): do we need the size parameter?
std::ignore = size;
Registry::set_last_suite_name(name); Registry::set_last_suite_name(name);
return {}; return {};
} }

View file

@ -24,7 +24,7 @@ Suite expects = "expects"_suite = []() {
// clang-format off // clang-format off
try { expect_unreachable(); } try { expect_unreachable(); }
catch (const std::exception &exp) { unhappy = true; } catch (const std::exception &) { unhappy = true; }
// clang-format on // clang-format on
if (!unhappy) if (!unhappy)
@ -48,16 +48,16 @@ Suite expects = "expects"_suite = []() {
// clang-format off // clang-format off
try { expect_true(where_oongaboonga_ptr); } try { expect_true(where_oongaboonga_ptr); }
catch (const std::exception& exp) { ++unhappy_counter; } catch (const std::exception&) { ++unhappy_counter; }
try { expect_true(!true); } try { expect_true(!true); }
catch (const std::exception& exp) { ++unhappy_counter; } catch (const std::exception&) { ++unhappy_counter; }
try { expect_true(false); } try { expect_true(false); }
catch (const std::exception& exp) { ++unhappy_counter; } catch (const std::exception&) { ++unhappy_counter; }
try { expect_true(0); } // NOLINT try { expect_true(0); } // NOLINT
catch (const std::exception& exp) { ++unhappy_counter; } catch (const std::exception&) { ++unhappy_counter; }
// clang-format on // clang-format on
}; };
@ -66,27 +66,30 @@ Suite expects = "expects"_suite = []() {
expect_false(oongaboonga_is_slacking); expect_false(oongaboonga_is_slacking);
expect_false(false); expect_false(false);
expect_false(0); // NOLINT
}; };
Case { "expect_false - unhappy" } = [] { Case { "expect_false - unhappy" } = [] {
auto oongaboonga = int {};
auto *oonga_oonga_can_rest_now = (int *)nullptr; auto *oonga_oonga_can_rest_now = (int *)nullptr;
auto unhappy_counter = 0u; auto unhappy_counter = 0u;
// clang-format off // clang-format off
try { expect_false(oonga_oonga_can_rest_now); } try { expect_false(oonga_oonga_can_rest_now); }
catch (const std::exception& exp) { ++unhappy_counter; } catch (const std::exception&) { ++unhappy_counter; }
try { expect_false(true); } try { expect_false(true); }
catch (const std::exception& exp) { ++unhappy_counter; } catch (const std::exception&) { ++unhappy_counter; }
try { expect_false(!false); } try { expect_false(!false); }
catch (const std::exception& exp) { ++unhappy_counter; } catch (const std::exception&) { ++unhappy_counter; }
try { expect_false(1); } // NOLINT try { expect_false(!!1); }
catch (const std::exception& exp) { ++unhappy_counter; } catch (const std::exception&) { ++unhappy_counter; }
// clang-format on // clang-format on
if (unhappy_counter != 4)
{
throw std::runtime_error { "expect_false - unhappy" };
}
}; };
Case { "expect_true - unhappy" } = [] { Case { "expect_true - unhappy" } = [] {
@ -95,23 +98,28 @@ Suite expects = "expects"_suite = []() {
// clang-format off // clang-format off
try { expect_true(where_oongaboonga_ptr); } try { expect_true(where_oongaboonga_ptr); }
catch (const std::exception& exp) { ++unhappy_counter; } catch (const std::exception&) { ++unhappy_counter; }
try { expect_true(!true); } try { expect_true(!true); }
catch (const std::exception& exp) { ++unhappy_counter; } catch (const std::exception&) { ++unhappy_counter; }
try { expect_true(false); } try { expect_true(false); }
catch (const std::exception& exp) { ++unhappy_counter; } catch (const std::exception&) { ++unhappy_counter; }
try { expect_true(0); } // NOLINT try { expect_true(!!0); }
catch (const std::exception& exp) { ++unhappy_counter; } catch (const std::exception&) { ++unhappy_counter; }
// clang-format on // clang-format on
if (unhappy_counter != 4)
{
throw std::runtime_error { "expect_true - unhappy" };
}
}; };
Case { "expect_eq - happy" } = [] { Case { "expect_eq - happy" } = [] {
expect_eq(5, 5); expect_eq(5, 5);
expect_eq(20.0, 20.0); expect_eq(20.0, 20.0);
expect_eq(true, 1); expect_eq(true, true);
}; };
Case { "expect_eq - unhappy" } = [] { Case { "expect_eq - unhappy" } = [] {
@ -119,7 +127,7 @@ Suite expects = "expects"_suite = []() {
// clang-format off // clang-format off
try { expect_eq(true, false); } try { expect_eq(true, false); }
catch (const std::exception &exp) { unhappy = true; } catch (const std::exception &) { unhappy = true; }
// clang-format on // clang-format on
if (!unhappy) if (!unhappy)
@ -131,7 +139,8 @@ Suite expects = "expects"_suite = []() {
Case { "expect_ne - happy " } = [] { Case { "expect_ne - happy " } = [] {
expect_ne(5, 5.0000001); expect_ne(5, 5.0000001);
expect_ne(20.0, 69.0); expect_ne(20.0, 69.0);
expect_ne(true, 0); expect_ne(true, true);
expect_ne(false, false);
}; };
Case { "expect_ne - unhappy" } = [] { Case { "expect_ne - unhappy" } = [] {
@ -139,16 +148,19 @@ Suite expects = "expects"_suite = []() {
// clang-format off // clang-format off
try { expect_ne(5, 5); } try { expect_ne(5, 5); }
catch (const std::exception &exp) { ++unhappy_counter; } catch (const std::exception &) { ++unhappy_counter; }
try { expect_ne(20.0, 20.0); } try { expect_ne(20.0, 20.0); }
catch (const std::exception &exp) { ++unhappy_counter; } catch (const std::exception &) { ++unhappy_counter; }
try { expect_ne(true, 1); } try { expect_ne(true, true); }
catch (const std::exception &exp) { ++unhappy_counter; } catch (const std::exception &) { ++unhappy_counter; }
try { expect_ne(false, false); }
catch (const std::exception &) { ++unhappy_counter; }
// clang-format on // clang-format on
if (unhappy_counter != 3) if (unhappy_counter != 4)
{ {
throw std::runtime_error { "expect_ne unhappy" }; throw std::runtime_error { "expect_ne unhappy" };
} }
@ -163,7 +175,7 @@ Suite expects = "expects"_suite = []() {
// clang-format off // clang-format off
try { expect_throw([] {}); } try { expect_throw([] {}); }
catch (const std::exception &exp) { unhappy = true; } catch (const std::exception &) { unhappy = true; }
// clang-format on // clang-format on
if (!unhappy) if (!unhappy)
@ -175,7 +187,7 @@ Suite expects = "expects"_suite = []() {
Case { "expect_le - happy" } = [] { Case { "expect_le - happy" } = [] {
expect_le(69, 420); expect_le(69, 420);
expect_le(19.694206942069420, 20.0); expect_le(19.694206942069420, 20.0);
expect_le(false, 1); expect_le(false, !!1);
}; };
Case { "expect_le - unhappy" } = [] { Case { "expect_le - unhappy" } = [] {
@ -183,16 +195,16 @@ Suite expects = "expects"_suite = []() {
// clang-format off // clang-format off
try { expect_le(20020619 + 23, 20020619 ); } try { expect_le(20020619 + 23, 20020619 ); }
catch (const std::exception &exp) { ++unhappy_counter; } catch (const std::exception &) { ++unhappy_counter; }
try { expect_le(420, 69); } try { expect_le(420, 69); }
catch (const std::exception &exp) { ++unhappy_counter; } catch (const std::exception &) { ++unhappy_counter; }
try { expect_le(20.0, 19.694206942069420); } try { expect_le(20.0, 19.694206942069420); }
catch (const std::exception &exp) { ++unhappy_counter; } catch (const std::exception &) { ++unhappy_counter; }
try { expect_le(1, false); } try { expect_le(true, false); }
catch (const std::exception &exp) { ++unhappy_counter; } catch (const std::exception &) { ++unhappy_counter; }
// clang-format on // clang-format on
if (unhappy_counter != 4) if (unhappy_counter != 4)

View file

@ -28,6 +28,7 @@ Suite raii = "raii"_suite = [] {
Case { "plenty" } = [] { Case { "plenty" } = [] {
for (auto idx : std::views::iota(0, 100'001)) for (auto idx : std::views::iota(0, 100'001))
{ {
std::ignore = idx;
Timer {}; Timer {};
} }
}; };