From ab2aeb88ea6f0569097374f54bf28506b499ad4d Mon Sep 17 00:00:00 2001 From: Adam Kewley Date: Mon, 1 Jul 2024 15:57:05 +0200 Subject: [PATCH] Refactor some methods/tests to snake_case --- .../MeshWarper/UndoableTPSDocumentActions.cpp | 12 +++++----- .../Documents/Model/UndoableModelActions.cpp | 4 ++-- .../UI/MeshImporter/MeshImporterSharedState.h | 2 +- .../UI/MeshImporter/MeshImporterTab.cpp | 4 ++-- .../UI/ModelEditor/ExportPointsPopup.cpp | 2 +- .../UI/ModelEditor/ModelMusclePlotPanel.cpp | 4 ++-- .../UI/PerformanceAnalyzerTab.cpp | 2 +- src/OpenSimCreator/UI/Shared/BasicWidgets.cpp | 6 ++--- .../UI/Simulation/ISimulatorUIAPI.cpp | 2 +- src/oscar/Platform/os.cpp | 22 +++++++++---------- src/oscar/Platform/os.h | 2 +- src/oscar/UI/Tabs/ScreenshotTab.cpp | 2 +- tests/testoscar/Formats/TestDAE.cpp | 8 +++---- tests/testoscar/Formats/TestImage.cpp | 6 ++--- .../TestVertexAttributeFormatHelpers.cpp | 6 ++--- .../Detail/TestVertexAttributeFormatList.cpp | 2 +- .../Detail/TestVertexAttributeHelpers.cpp | 2 +- .../Detail/TestVertexAttributeList.cpp | 2 +- .../Graphics/Scene/TestSceneCache.cpp | 4 ++-- 19 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/OpenSimCreator/Documents/MeshWarper/UndoableTPSDocumentActions.cpp b/src/OpenSimCreator/Documents/MeshWarper/UndoableTPSDocumentActions.cpp index f1ca19537..94cbd9242 100644 --- a/src/OpenSimCreator/Documents/MeshWarper/UndoableTPSDocumentActions.cpp +++ b/src/OpenSimCreator/Documents/MeshWarper/UndoableTPSDocumentActions.cpp @@ -250,7 +250,7 @@ void osc::ActionSaveLandmarksToCSV( lm::LandmarkCSVFlags flags) { const std::optional maybeCSVPath = - PromptUserForFileSaveLocationAndAddExtensionIfNecessary("csv"); + promp_user_for_file_save_location_add_extension_if_necessary("csv"); if (!maybeCSVPath) { return; // user didn't select a save location @@ -281,7 +281,7 @@ void osc::ActionSaveNonParticipatingLandmarksToCSV( lm::LandmarkCSVFlags flags) { const std::optional maybeCSVPath = - PromptUserForFileSaveLocationAndAddExtensionIfNecessary("csv"); + promp_user_for_file_save_location_add_extension_if_necessary("csv"); if (!maybeCSVPath) { return; // user didn't select a save location @@ -307,7 +307,7 @@ void osc::ActionSaveNonParticipatingLandmarksToCSV( void osc::ActionSavePairedLandmarksToCSV(const TPSDocument& doc, lm::LandmarkCSVFlags flags) { const std::optional maybeCSVPath = - PromptUserForFileSaveLocationAndAddExtensionIfNecessary("csv"); + promp_user_for_file_save_location_add_extension_if_necessary("csv"); if (!maybeCSVPath) { return; // user didn't select a save location @@ -361,7 +361,7 @@ void osc::ActionSavePairedLandmarksToCSV(const TPSDocument& doc, lm::LandmarkCSV void osc::ActionTrySaveMeshToObjFile(const Mesh& mesh, ObjWriterFlags flags) { const std::optional maybeSavePath = - PromptUserForFileSaveLocationAndAddExtensionIfNecessary("obj"); + promp_user_for_file_save_location_add_extension_if_necessary("obj"); if (!maybeSavePath) { return; // user didn't select a save location @@ -394,7 +394,7 @@ void osc::ActionTrySaveMeshToObjFile(const Mesh& mesh, ObjWriterFlags flags) void osc::ActionTrySaveMeshToStlFile(const Mesh& mesh) { const std::optional maybeSTLPath = - PromptUserForFileSaveLocationAndAddExtensionIfNecessary("stl"); + promp_user_for_file_save_location_add_extension_if_necessary("stl"); if (!maybeSTLPath) { return; // user didn't select a save location @@ -424,7 +424,7 @@ void osc::ActionSaveWarpedNonParticipatingLandmarksToCSV( TPSResultCache& cache, lm::LandmarkCSVFlags flags) { - const auto maybeCSVPath = PromptUserForFileSaveLocationAndAddExtensionIfNecessary("csv"); + const auto maybeCSVPath = promp_user_for_file_save_location_add_extension_if_necessary("csv"); if (!maybeCSVPath) { return; // user didn't select a save location diff --git a/src/OpenSimCreator/Documents/Model/UndoableModelActions.cpp b/src/OpenSimCreator/Documents/Model/UndoableModelActions.cpp index 5355edea8..a35e69d72 100644 --- a/src/OpenSimCreator/Documents/Model/UndoableModelActions.cpp +++ b/src/OpenSimCreator/Documents/Model/UndoableModelActions.cpp @@ -90,7 +90,7 @@ namespace std::optional PromptSaveOneFile() { - return PromptUserForFileSaveLocationAndAddExtensionIfNecessary("osim"); + return promp_user_for_file_save_location_add_extension_if_necessary("osim"); } bool IsAnExampleFile(const std::filesystem::path& path) @@ -2293,7 +2293,7 @@ bool osc::ActionImportLandmarks( bool osc::ActionExportModelGraphToDotviz(const UndoableModelStatePair& model) { - if (auto p = PromptUserForFileSaveLocationAndAddExtensionIfNecessary("dot")) { + if (auto p = promp_user_for_file_save_location_add_extension_if_necessary("dot")) { if (std::ofstream of{*p}) { WriteComponentTopologyGraphAsDotViz(model.getModel(), of); return true; diff --git a/src/OpenSimCreator/UI/MeshImporter/MeshImporterSharedState.h b/src/OpenSimCreator/UI/MeshImporter/MeshImporterSharedState.h index 55593911d..b0fec860e 100644 --- a/src/OpenSimCreator/UI/MeshImporter/MeshImporterSharedState.h +++ b/src/OpenSimCreator/UI/MeshImporter/MeshImporterSharedState.h @@ -138,7 +138,7 @@ namespace osc::mi bool exportAsModelGraphAsOsimFile() { const std::optional maybeExportPath = - PromptUserForFileSaveLocationAndAddExtensionIfNecessary("osim"); + promp_user_for_file_save_location_add_extension_if_necessary("osim"); if (!maybeExportPath) { diff --git a/src/OpenSimCreator/UI/MeshImporter/MeshImporterTab.cpp b/src/OpenSimCreator/UI/MeshImporter/MeshImporterTab.cpp index 6e4182784..78b13a568 100644 --- a/src/OpenSimCreator/UI/MeshImporter/MeshImporterTab.cpp +++ b/src/OpenSimCreator/UI/MeshImporter/MeshImporterTab.cpp @@ -1356,7 +1356,7 @@ class osc::mi::MeshImporterTab::Impl final : public IMeshImporterUILayerHost { { // prompt user for a save location const std::optional maybeUserSaveLocation = - PromptUserForFileSaveLocationAndAddExtensionIfNecessary("obj"); + promp_user_for_file_save_location_add_extension_if_necessary("obj"); if (!maybeUserSaveLocation) { return; // user didn't select a save location @@ -1395,7 +1395,7 @@ class osc::mi::MeshImporterTab::Impl final : public IMeshImporterUILayerHost { { // prompt user for a save location const std::optional maybeUserSaveLocation = - PromptUserForFileSaveLocationAndAddExtensionIfNecessary("stl"); + promp_user_for_file_save_location_add_extension_if_necessary("stl"); if (!maybeUserSaveLocation) { return; // user didn't select a save location diff --git a/src/OpenSimCreator/UI/ModelEditor/ExportPointsPopup.cpp b/src/OpenSimCreator/UI/ModelEditor/ExportPointsPopup.cpp index 6c035525b..6137a1a00 100644 --- a/src/OpenSimCreator/UI/ModelEditor/ExportPointsPopup.cpp +++ b/src/OpenSimCreator/UI/ModelEditor/ExportPointsPopup.cpp @@ -518,7 +518,7 @@ namespace bool shouldExportPointsWithAbsPathNames) { // prompt user to select a save location - const std::optional saveLoc = PromptUserForFileSaveLocationAndAddExtensionIfNecessary("csv"); + const std::optional saveLoc = promp_user_for_file_save_location_add_extension_if_necessary("csv"); if (!saveLoc) { return ExportStepReturn::UserCancelled; } diff --git a/src/OpenSimCreator/UI/ModelEditor/ModelMusclePlotPanel.cpp b/src/OpenSimCreator/UI/ModelEditor/ModelMusclePlotPanel.cpp index ab0cce22f..899373968 100644 --- a/src/OpenSimCreator/UI/ModelEditor/ModelMusclePlotPanel.cpp +++ b/src/OpenSimCreator/UI/ModelEditor/ModelMusclePlotPanel.cpp @@ -989,7 +989,7 @@ namespace void ActionPromptUserToSavePlotToCSV(const OpenSim::Coordinate& coord, const PlotParameters& params, const Plot& plot) { const std::optional maybeCSVPath = - PromptUserForFileSaveLocationAndAddExtensionIfNecessary("csv"); + promp_user_for_file_save_location_add_extension_if_necessary("csv"); if (maybeCSVPath) { @@ -1437,7 +1437,7 @@ namespace void ActionPromptUserToSavePlotLinesToCSV(const OpenSim::Coordinate& coord, const PlotParameters& params, const PlotLines& lines) { const std::optional maybeCSVPath = - PromptUserForFileSaveLocationAndAddExtensionIfNecessary("csv"); + promp_user_for_file_save_location_add_extension_if_necessary("csv"); if (maybeCSVPath) { diff --git a/src/OpenSimCreator/UI/PerformanceAnalyzerTab.cpp b/src/OpenSimCreator/UI/PerformanceAnalyzerTab.cpp index 6a413c5fb..508783772 100644 --- a/src/OpenSimCreator/UI/PerformanceAnalyzerTab.cpp +++ b/src/OpenSimCreator/UI/PerformanceAnalyzerTab.cpp @@ -142,7 +142,7 @@ class osc::PerformanceAnalyzerTab::Impl final { { // try prompt user for save location const std::optional maybeCSVPath = - PromptUserForFileSaveLocationAndAddExtensionIfNecessary("csv"); + promp_user_for_file_save_location_add_extension_if_necessary("csv"); if (!maybeCSVPath) { return; // user probably cancelled out diff --git a/src/OpenSimCreator/UI/Shared/BasicWidgets.cpp b/src/OpenSimCreator/UI/Shared/BasicWidgets.cpp index 37fd32ebb..ae2daa65e 100644 --- a/src/OpenSimCreator/UI/Shared/BasicWidgets.cpp +++ b/src/OpenSimCreator/UI/Shared/BasicWidgets.cpp @@ -76,7 +76,7 @@ namespace void TryPromptUserToSaveAsDAE(std::span scene) { std::optional maybeDAEPath = - PromptUserForFileSaveLocationAndAddExtensionIfNecessary("dae"); + promp_user_for_file_save_location_add_extension_if_necessary("dae"); if (!maybeDAEPath) { @@ -200,7 +200,7 @@ namespace { // prompt user for a save location const std::optional maybeUserSaveLocation = - PromptUserForFileSaveLocationAndAddExtensionIfNecessary("obj"); + promp_user_for_file_save_location_add_extension_if_necessary("obj"); if (!maybeUserSaveLocation) { return; // user didn't select a save location @@ -248,7 +248,7 @@ namespace { // prompt user for a save location const std::optional maybeUserSaveLocation = - PromptUserForFileSaveLocationAndAddExtensionIfNecessary("stl"); + promp_user_for_file_save_location_add_extension_if_necessary("stl"); if (!maybeUserSaveLocation) { return; // user didn't select a save location diff --git a/src/OpenSimCreator/UI/Simulation/ISimulatorUIAPI.cpp b/src/OpenSimCreator/UI/Simulation/ISimulatorUIAPI.cpp index b649e25e8..7025ca2b5 100644 --- a/src/OpenSimCreator/UI/Simulation/ISimulatorUIAPI.cpp +++ b/src/OpenSimCreator/UI/Simulation/ISimulatorUIAPI.cpp @@ -26,7 +26,7 @@ namespace { // prompt user for save location std::optional path = - PromptUserForFileSaveLocationAndAddExtensionIfNecessary("csv"); + promp_user_for_file_save_location_add_extension_if_necessary("csv"); if (not path) { return std::nullopt; // user probably cancelled out } diff --git a/src/oscar/Platform/os.cpp b/src/oscar/Platform/os.cpp index b48a1f398..af45cb858 100644 --- a/src/oscar/Platform/os.cpp +++ b/src/oscar/Platform/os.cpp @@ -182,26 +182,26 @@ std::vector osc::prompt_user_to_select_files( #endif } -std::optional osc::PromptUserForFileSaveLocationAndAddExtensionIfNecessary( - std::optional maybeExtension, - std::optional maybeInitialDirectoryToOpen) +std::optional osc::promp_user_for_file_save_location_add_extension_if_necessary( + std::optional maybe_extension, + std::optional maybe_initial_directory_to_open) { #ifdef EMSCRIPTEN - static_cast(maybeExtension); - static_cast(maybeInitialDirectoryToOpen); + static_cast(maybe_extension); + static_cast(maybe_initial_directory_to_open); return std::nullopt; #else - if (maybeExtension) + if (maybe_extension) { - OSC_ASSERT(!contains(*maybeExtension, ',') && "can only provide one extension to this implementation!"); + OSC_ASSERT(!contains(*maybe_extension, ',') && "can only provide one extension to this implementation!"); } auto [path, result] = [&]() { nfdchar_t* ptr = nullptr; const nfdresult_t res = NFD_SaveDialog( - maybeExtension ? maybeExtension->c_str() : nullptr, - maybeInitialDirectoryToOpen ? maybeInitialDirectoryToOpen->c_str() : nullptr, + maybe_extension ? maybe_extension->c_str() : nullptr, + maybe_initial_directory_to_open ? maybe_initial_directory_to_open->c_str() : nullptr, &ptr ); return std::pair, nfdresult_t> @@ -219,7 +219,7 @@ std::optional osc::PromptUserForFileSaveLocationAndAddExt static_assert(std::is_same_v); auto p = std::filesystem::weakly_canonical(path.get()); - if (maybeExtension) + if (maybe_extension) { // ensure that the user-selected path is tested against '.$EXTENSION' (#771) // @@ -227,7 +227,7 @@ std::optional osc::PromptUserForFileSaveLocationAndAddExt // NFD requires) but the user may have manually wrote a string that is // suffixed with the dot-less version of the extension (e.g. "somecsv") - const std::string fullExtension = std::string{"."} + *maybeExtension; + const std::string fullExtension = std::string{"."} + *maybe_extension; if (!std::string_view{path.get()}.ends_with(fullExtension)) { p += fullExtension; } diff --git a/src/oscar/Platform/os.h b/src/oscar/Platform/os.h index bef231b01..56e018b8e 100644 --- a/src/oscar/Platform/os.h +++ b/src/oscar/Platform/os.h @@ -152,7 +152,7 @@ namespace osc // // returns std::nullopt if the user doesn't select a file; otherwise, returns the user-selected save location--including the extension--if // the user selects a location - std::optional PromptUserForFileSaveLocationAndAddExtensionIfNecessary( + std::optional promp_user_for_file_save_location_add_extension_if_necessary( std::optional maybeExtension = std::nullopt, std::optional maybeInitialDirectoryToOpen = std::nullopt ); diff --git a/src/oscar/UI/Tabs/ScreenshotTab.cpp b/src/oscar/UI/Tabs/ScreenshotTab.cpp index 2c5ce9c83..cac391cb3 100644 --- a/src/oscar/UI/Tabs/ScreenshotTab.cpp +++ b/src/oscar/UI/Tabs/ScreenshotTab.cpp @@ -183,7 +183,7 @@ class osc::ScreenshotTab::Impl final : public StandardTabImpl { void action_try_save_annotated_screenshot() { const std::optional maybe_image_path = - PromptUserForFileSaveLocationAndAddExtensionIfNecessary("png"); + promp_user_for_file_save_location_add_extension_if_necessary("png"); if (maybe_image_path) { std::ofstream fout{*maybe_image_path, std::ios_base::binary}; diff --git a/tests/testoscar/Formats/TestDAE.cpp b/tests/testoscar/Formats/TestDAE.cpp index 22942f94b..ffa2f4026 100644 --- a/tests/testoscar/Formats/TestDAE.cpp +++ b/tests/testoscar/Formats/TestDAE.cpp @@ -12,7 +12,7 @@ using namespace osc; -TEST(write_as_dae, WorksForEmptyScene) +TEST(write_as_dae, works_for_empty_scene) { DAEMetadata metadata{TESTOSCAR_APPNAME_STRING, TESTOSCAR_APPNAME_STRING}; @@ -22,7 +22,7 @@ TEST(write_as_dae, WorksForEmptyScene) ASSERT_FALSE(ss.str().empty()); } -TEST(write_as_dae, WorksForNonEmptyScene) +TEST(write_as_dae, works_for_nonempty_scene) { DAEMetadata metadata{TESTOSCAR_APPNAME_STRING, TESTOSCAR_APPNAME_STRING}; @@ -34,7 +34,7 @@ TEST(write_as_dae, WorksForNonEmptyScene) ASSERT_FALSE(ss.str().empty()); } -TEST(write_as_dae, SetAuthorWritesAuthorToOutput) +TEST(write_as_dae, set_author_writes_author_to_output) { DAEMetadata metadata{TESTOSCAR_APPNAME_STRING, TESTOSCAR_APPNAME_STRING}; metadata.author = "TestThis"; @@ -45,7 +45,7 @@ TEST(write_as_dae, SetAuthorWritesAuthorToOutput) ASSERT_TRUE(contains(ss.str(), metadata.author)); } -TEST(write_as_dae, SetAuthoringToolsWritesAuthoringToolToOutput) +TEST(write_as_dae, set_authoring_tool_writes_authoring_tool_to_output) { DAEMetadata metadata{TESTOSCAR_APPNAME_STRING, TESTOSCAR_APPNAME_STRING}; metadata.authoring_tool = "TestThis"; diff --git a/tests/testoscar/Formats/TestImage.cpp b/tests/testoscar/Formats/TestImage.cpp index 20192dab9..1fcba6d62 100644 --- a/tests/testoscar/Formats/TestImage.cpp +++ b/tests/testoscar/Formats/TestImage.cpp @@ -13,7 +13,7 @@ using namespace osc; -TEST(Image, LoadTexture2DFromImageRespectsSRGBColorSpace) +TEST(Image, load_texture2D_from_image_respects_sRGB_color_space) { const auto path = std::filesystem::path{OSC_TESTING_RESOURCES_DIR} / "awesomeface.png"; const Texture2D loaded_texture = load_texture2D_from_image(ResourceStream{path}, ColorSpace::sRGB); @@ -21,7 +21,7 @@ TEST(Image, LoadTexture2DFromImageRespectsSRGBColorSpace) ASSERT_EQ(loaded_texture.color_space(), ColorSpace::sRGB); } -TEST(Image, LoadTexture2DFromImageRespectsLinearColorSpace) +TEST(Image, load_texture2D_from_image_respects_linear_color_space) { const auto path = std::filesystem::path{OSC_TESTING_RESOURCES_DIR} / "awesomeface.png"; const Texture2D loaded_texture = load_texture2D_from_image(ResourceStream{path}, ColorSpace::Linear); @@ -29,7 +29,7 @@ TEST(Image, LoadTexture2DFromImageRespectsLinearColorSpace) ASSERT_EQ(loaded_texture.color_space(), ColorSpace::Linear); } -TEST(Image, CanLoadAndThenWriteImage) +TEST(Image, can_load_and_then_write_an_image) { const auto path = std::filesystem::path{OSC_TESTING_RESOURCES_DIR} / "awesomeface.png"; const Texture2D loaded_texture = load_texture2D_from_image(ResourceStream{path}, ColorSpace::Linear); diff --git a/tests/testoscar/Graphics/Detail/TestVertexAttributeFormatHelpers.cpp b/tests/testoscar/Graphics/Detail/TestVertexAttributeFormatHelpers.cpp index 0652f1dc4..3d87fd60c 100644 --- a/tests/testoscar/Graphics/Detail/TestVertexAttributeFormatHelpers.cpp +++ b/tests/testoscar/Graphics/Detail/TestVertexAttributeFormatHelpers.cpp @@ -6,17 +6,17 @@ using namespace osc; using namespace osc::detail; -TEST(stride_of, WorksAsExpected) +TEST(stride_of, works_as_expected) { static_assert(stride_of(VertexAttributeFormat::Float32x2) == 2*sizeof(float)); } -TEST(num_components_in, WorksAsExpected) +TEST(num_components_in, works_as_expected) { static_assert(num_components_in(VertexAttributeFormat::Float32x3) == 3); } -TEST(component_size, WorksAsExpected) +TEST(component_size, works_as_expected) { static_assert(component_size(VertexAttributeFormat::Float32x3) == sizeof(float)); } diff --git a/tests/testoscar/Graphics/Detail/TestVertexAttributeFormatList.cpp b/tests/testoscar/Graphics/Detail/TestVertexAttributeFormatList.cpp index 0ed84ae0b..20eb7cf96 100644 --- a/tests/testoscar/Graphics/Detail/TestVertexAttributeFormatList.cpp +++ b/tests/testoscar/Graphics/Detail/TestVertexAttributeFormatList.cpp @@ -11,7 +11,7 @@ using namespace osc; using namespace osc::detail; -TEST(VertexAttributeFormatList, EveryEntryInTheListHasAnAssociatedTraitsObject) +TEST(VertexAttributeFormatList, every_entry_in_the_list_has_an_associated_VertexAttributeFormatTraits_implementation) { [[maybe_unused]] auto ary = [](OptionList) { diff --git a/tests/testoscar/Graphics/Detail/TestVertexAttributeHelpers.cpp b/tests/testoscar/Graphics/Detail/TestVertexAttributeHelpers.cpp index 1ad85ee9d..1e269459b 100644 --- a/tests/testoscar/Graphics/Detail/TestVertexAttributeHelpers.cpp +++ b/tests/testoscar/Graphics/Detail/TestVertexAttributeHelpers.cpp @@ -7,7 +7,7 @@ using namespace osc; using namespace osc::detail; -TEST(default_format, WorksAsExpected) +TEST(default_format, works_as_expected) { static_assert(default_format(VertexAttribute::Position) == VertexAttributeFormat::Float32x3); } diff --git a/tests/testoscar/Graphics/Detail/TestVertexAttributeList.cpp b/tests/testoscar/Graphics/Detail/TestVertexAttributeList.cpp index de8ffcf17..784eaf1b9 100644 --- a/tests/testoscar/Graphics/Detail/TestVertexAttributeList.cpp +++ b/tests/testoscar/Graphics/Detail/TestVertexAttributeList.cpp @@ -10,7 +10,7 @@ using namespace osc; using namespace osc::detail; -TEST(VertexAttributeList, EveryEntryInTheListHasAnAssociatedTraitsObject) +TEST(VertexAttributeList, every_entry_has_an_associted_VertexAttributeTraits_implementation) { [[maybe_unused]] constexpr auto ary = [](OptionList) { diff --git a/tests/testoscar/Graphics/Scene/TestSceneCache.cpp b/tests/testoscar/Graphics/Scene/TestSceneCache.cpp index b0be04988..1351685ad 100644 --- a/tests/testoscar/Graphics/Scene/TestSceneCache.cpp +++ b/tests/testoscar/Graphics/Scene/TestSceneCache.cpp @@ -12,7 +12,7 @@ using namespace osc; -TEST(SceneCache, GetBVHOnEmptyMeshReturnsEmptyBVH) +TEST(SceneCache, get_bvh_on_empty_mesh_returns_empty_bvh) { SceneCache c; Mesh m; @@ -20,7 +20,7 @@ TEST(SceneCache, GetBVHOnEmptyMeshReturnsEmptyBVH) ASSERT_TRUE(bvh.empty()); } -TEST(SceneCache, GetBVHOnNonEmptyMeshReturnsExpectedRootNode) +TEST(SceneCache, get_bvh_on_nonempty_mesh_returns_expected_root_node) { const auto pyramid = std::to_array({ {-1.0f, -1.0f, 0.0f}, // base: bottom-left