From 19b4f0b359b76b752cce6633632a6c5f10038a40 Mon Sep 17 00:00:00 2001 From: Masonlet Date: Fri, 21 Nov 2025 21:10:52 -0500 Subject: [PATCH 1/3] Normalize file names to snake_case --- .../data/{data.hpp => base_data.hpp} | 4 ++-- .../data/{cameraData.hpp => camera_data.hpp} | 2 +- .../data/{colourData.hpp => colour_data.hpp} | 0 .../data/{gridData.hpp => grid_data.hpp} | 2 +- .../data/{imageData.hpp => image_data.hpp} | 0 .../data/{lightData.hpp => light_data.hpp} | 2 +- .../data/{meshData.hpp => mesh_data.hpp} | 0 .../data/{modelData.hpp => model_data.hpp} | 2 +- .../{primitiveData.hpp => primitive_data.hpp} | 2 +- .../data/{sceneData.hpp => scene_data.hpp} | 14 ++++++------- .../{textureData.hpp => texture_data.hpp} | 2 +- .../{transformData.hpp => transform_data.hpp} | 0 .../{velocityData.hpp => velocity_data.hpp} | 2 +- .../image/{bmpParser.hpp => bmp_parser.hpp} | 2 +- ...geParserBase.hpp => image_parser_base.hpp} | 0 .../image/{tgaParser.hpp => tga_parser.hpp} | 2 +- .../{imageParser.hpp => image_parser.hpp} | 0 ...eshParserBase.hpp => mesh_parser_base.hpp} | 0 .../mesh/{plyParser.hpp => ply_parser.hpp} | 2 +- .../{meshParser.hpp => mesh_parser.hpp} | 0 .../{sceneParser.hpp => scene_parser.hpp} | 0 .../image/{bmpParser.cpp => bmp_parser.cpp} | 4 ++-- ...geParserBase.cpp => image_parser_base.cpp} | 4 ++-- .../image/{tgaParser.cpp => tga_parser.cpp} | 4 ++-- .../{imageParser.cpp => image_parser.cpp} | 6 +++--- .../mesh/{plyParser.cpp => ply_parser.cpp} | 4 ++-- .../{meshParser.cpp => mesh_parser.cpp} | 4 ++-- .../{cameraParser.cpp => camera_parser.cpp} | 4 ++-- .../{colourParser.cpp => colour_parser.cpp} | 2 +- .../scene/{gridParser.cpp => grid_parser.cpp} | 4 ++-- .../{lightParser.cpp => light_parser.cpp} | 4 ++-- .../{modelParser.cpp => model_parser.cpp} | 4 ++-- ...imitiveParser.cpp => primitive_parser.cpp} | 4 ++-- .../{textureParser.cpp => texture_parser.cpp} | 4 ++-- ...velocityParser.cpp => velocity_parser.cpp} | 4 ++-- .../{sceneParser.cpp => scene_parser.cpp} | 4 ++-- .../{sceneWriter.cpp => scene_writer.cpp} | 20 +++++++++---------- tests/image_parser_test.cpp | 2 -- tests/mesh/ply_parser_test.cpp | 4 ++-- tests/mesh_parser_test.cpp | 4 ++-- tests/scene_parser_test.cpp | 4 ++-- tests/test_helpers.hpp | 4 ++-- 42 files changed, 67 insertions(+), 69 deletions(-) rename inc/starlet-serializer/data/{data.hpp => base_data.hpp} (81%) rename inc/starlet-serializer/data/{cameraData.hpp => camera_data.hpp} (91%) rename inc/starlet-serializer/data/{colourData.hpp => colour_data.hpp} (100%) rename inc/starlet-serializer/data/{gridData.hpp => grid_data.hpp} (90%) rename inc/starlet-serializer/data/{imageData.hpp => image_data.hpp} (100%) rename inc/starlet-serializer/data/{lightData.hpp => light_data.hpp} (93%) rename inc/starlet-serializer/data/{meshData.hpp => mesh_data.hpp} (100%) rename inc/starlet-serializer/data/{modelData.hpp => model_data.hpp} (95%) rename inc/starlet-serializer/data/{primitiveData.hpp => primitive_data.hpp} (88%) rename inc/starlet-serializer/data/{sceneData.hpp => scene_data.hpp} (72%) rename inc/starlet-serializer/data/{textureData.hpp => texture_data.hpp} (93%) rename inc/starlet-serializer/data/{transformData.hpp => transform_data.hpp} (100%) rename inc/starlet-serializer/data/{velocityData.hpp => velocity_data.hpp} (87%) rename inc/starlet-serializer/parser/image/{bmpParser.hpp => bmp_parser.hpp} (88%) rename inc/starlet-serializer/parser/image/{imageParserBase.hpp => image_parser_base.hpp} (100%) rename inc/starlet-serializer/parser/image/{tgaParser.hpp => tga_parser.hpp} (89%) rename inc/starlet-serializer/parser/{imageParser.hpp => image_parser.hpp} (100%) rename inc/starlet-serializer/parser/mesh/{meshParserBase.hpp => mesh_parser_base.hpp} (100%) rename inc/starlet-serializer/parser/mesh/{plyParser.hpp => ply_parser.hpp} (95%) rename inc/starlet-serializer/parser/{meshParser.hpp => mesh_parser.hpp} (100%) rename inc/starlet-serializer/parser/{sceneParser.hpp => scene_parser.hpp} (100%) rename src/parser/image/{bmpParser.cpp => bmp_parser.cpp} (97%) rename src/parser/image/{imageParserBase.cpp => image_parser_base.cpp} (95%) rename src/parser/image/{tgaParser.cpp => tga_parser.cpp} (97%) rename src/parser/{imageParser.cpp => image_parser.cpp} (86%) rename src/parser/mesh/{plyParser.cpp => ply_parser.cpp} (98%) rename src/parser/{meshParser.cpp => mesh_parser.cpp} (88%) rename src/parser/scene/{cameraParser.cpp => camera_parser.cpp} (89%) rename src/parser/scene/{colourParser.cpp => colour_parser.cpp} (96%) rename src/parser/scene/{gridParser.cpp => grid_parser.cpp} (90%) rename src/parser/scene/{lightParser.cpp => light_parser.cpp} (94%) rename src/parser/scene/{modelParser.cpp => model_parser.cpp} (92%) rename src/parser/scene/{primitiveParser.cpp => primitive_parser.cpp} (89%) rename src/parser/scene/{textureParser.cpp => texture_parser.cpp} (89%) rename src/parser/scene/{velocityParser.cpp => velocity_parser.cpp} (66%) rename src/parser/{sceneParser.cpp => scene_parser.cpp} (98%) rename src/writer/{sceneWriter.cpp => scene_writer.cpp} (93%) diff --git a/inc/starlet-serializer/data/data.hpp b/inc/starlet-serializer/data/base_data.hpp similarity index 81% rename from inc/starlet-serializer/data/data.hpp rename to inc/starlet-serializer/data/base_data.hpp index df39f08..976b808 100644 --- a/inc/starlet-serializer/data/data.hpp +++ b/inc/starlet-serializer/data/base_data.hpp @@ -1,7 +1,7 @@ #pragma once -#include "colourData.hpp" -#include "transformData.hpp" +#include "colour_data.hpp" +#include "transform_data.hpp" namespace Starlet::Serializer { diff --git a/inc/starlet-serializer/data/cameraData.hpp b/inc/starlet-serializer/data/camera_data.hpp similarity index 91% rename from inc/starlet-serializer/data/cameraData.hpp rename to inc/starlet-serializer/data/camera_data.hpp index 053f77c..7f45ddc 100644 --- a/inc/starlet-serializer/data/cameraData.hpp +++ b/inc/starlet-serializer/data/camera_data.hpp @@ -1,6 +1,6 @@ #pragma once -#include "data.hpp" +#include "base_data.hpp" namespace Starlet::Serializer { diff --git a/inc/starlet-serializer/data/colourData.hpp b/inc/starlet-serializer/data/colour_data.hpp similarity index 100% rename from inc/starlet-serializer/data/colourData.hpp rename to inc/starlet-serializer/data/colour_data.hpp diff --git a/inc/starlet-serializer/data/gridData.hpp b/inc/starlet-serializer/data/grid_data.hpp similarity index 90% rename from inc/starlet-serializer/data/gridData.hpp rename to inc/starlet-serializer/data/grid_data.hpp index c7756d2..c9ae525 100644 --- a/inc/starlet-serializer/data/gridData.hpp +++ b/inc/starlet-serializer/data/grid_data.hpp @@ -1,6 +1,6 @@ #pragma once -#include "data.hpp" +#include "base_data.hpp" namespace Starlet::Serializer { diff --git a/inc/starlet-serializer/data/imageData.hpp b/inc/starlet-serializer/data/image_data.hpp similarity index 100% rename from inc/starlet-serializer/data/imageData.hpp rename to inc/starlet-serializer/data/image_data.hpp diff --git a/inc/starlet-serializer/data/lightData.hpp b/inc/starlet-serializer/data/light_data.hpp similarity index 93% rename from inc/starlet-serializer/data/lightData.hpp rename to inc/starlet-serializer/data/light_data.hpp index a0a247f..03dc016 100644 --- a/inc/starlet-serializer/data/lightData.hpp +++ b/inc/starlet-serializer/data/light_data.hpp @@ -1,6 +1,6 @@ #pragma once -#include "data.hpp" +#include "base_data.hpp" #include "starlet-math/vec2.hpp" #include "starlet-math/vec4.hpp" diff --git a/inc/starlet-serializer/data/meshData.hpp b/inc/starlet-serializer/data/mesh_data.hpp similarity index 100% rename from inc/starlet-serializer/data/meshData.hpp rename to inc/starlet-serializer/data/mesh_data.hpp diff --git a/inc/starlet-serializer/data/modelData.hpp b/inc/starlet-serializer/data/model_data.hpp similarity index 95% rename from inc/starlet-serializer/data/modelData.hpp rename to inc/starlet-serializer/data/model_data.hpp index 4120b7f..f8451d7 100644 --- a/inc/starlet-serializer/data/modelData.hpp +++ b/inc/starlet-serializer/data/model_data.hpp @@ -1,6 +1,6 @@ #pragma once -#include "data.hpp" +#include "base_data.hpp" #include "starlet-math/vec2.hpp" diff --git a/inc/starlet-serializer/data/primitiveData.hpp b/inc/starlet-serializer/data/primitive_data.hpp similarity index 88% rename from inc/starlet-serializer/data/primitiveData.hpp rename to inc/starlet-serializer/data/primitive_data.hpp index f1eed1c..965f3f9 100644 --- a/inc/starlet-serializer/data/primitiveData.hpp +++ b/inc/starlet-serializer/data/primitive_data.hpp @@ -1,6 +1,6 @@ #pragma once -#include "data.hpp" +#include "base_data.hpp" namespace Starlet::Serializer { diff --git a/inc/starlet-serializer/data/sceneData.hpp b/inc/starlet-serializer/data/scene_data.hpp similarity index 72% rename from inc/starlet-serializer/data/sceneData.hpp rename to inc/starlet-serializer/data/scene_data.hpp index 9228004..17398e3 100644 --- a/inc/starlet-serializer/data/sceneData.hpp +++ b/inc/starlet-serializer/data/scene_data.hpp @@ -2,13 +2,13 @@ #include -#include "modelData.hpp" -#include "lightData.hpp" -#include "cameraData.hpp" -#include "primitiveData.hpp" -#include "gridData.hpp" -#include "textureData.hpp" -#include "velocityData.hpp" +#include "model_data.hpp" +#include "light_data.hpp" +#include "camera_data.hpp" +#include "primitive_data.hpp" +#include "grid_data.hpp" +#include "texture_data.hpp" +#include "velocity_data.hpp" #include "starlet-math/vec3.hpp" diff --git a/inc/starlet-serializer/data/textureData.hpp b/inc/starlet-serializer/data/texture_data.hpp similarity index 93% rename from inc/starlet-serializer/data/textureData.hpp rename to inc/starlet-serializer/data/texture_data.hpp index 3cde565..c792f12 100644 --- a/inc/starlet-serializer/data/textureData.hpp +++ b/inc/starlet-serializer/data/texture_data.hpp @@ -1,6 +1,6 @@ #pragma once -#include "data.hpp" +#include "base_data.hpp" #include "starlet-math/vec2.hpp" diff --git a/inc/starlet-serializer/data/transformData.hpp b/inc/starlet-serializer/data/transform_data.hpp similarity index 100% rename from inc/starlet-serializer/data/transformData.hpp rename to inc/starlet-serializer/data/transform_data.hpp diff --git a/inc/starlet-serializer/data/velocityData.hpp b/inc/starlet-serializer/data/velocity_data.hpp similarity index 87% rename from inc/starlet-serializer/data/velocityData.hpp rename to inc/starlet-serializer/data/velocity_data.hpp index 256443b..2c56c8b 100644 --- a/inc/starlet-serializer/data/velocityData.hpp +++ b/inc/starlet-serializer/data/velocity_data.hpp @@ -1,6 +1,6 @@ #pragma once -#include "data.hpp" +#include "base_data.hpp" #include "starlet-math/vec3.hpp" diff --git a/inc/starlet-serializer/parser/image/bmpParser.hpp b/inc/starlet-serializer/parser/image/bmp_parser.hpp similarity index 88% rename from inc/starlet-serializer/parser/image/bmpParser.hpp rename to inc/starlet-serializer/parser/image/bmp_parser.hpp index 4f0997e..0f7c944 100644 --- a/inc/starlet-serializer/parser/image/bmpParser.hpp +++ b/inc/starlet-serializer/parser/image/bmp_parser.hpp @@ -1,6 +1,6 @@ #pragma once -#include "starlet-serializer/parser/image/imageParserBase.hpp" +#include "starlet-serializer/parser/image/image_parser_base.hpp" namespace Starlet::Serializer { diff --git a/inc/starlet-serializer/parser/image/imageParserBase.hpp b/inc/starlet-serializer/parser/image/image_parser_base.hpp similarity index 100% rename from inc/starlet-serializer/parser/image/imageParserBase.hpp rename to inc/starlet-serializer/parser/image/image_parser_base.hpp diff --git a/inc/starlet-serializer/parser/image/tgaParser.hpp b/inc/starlet-serializer/parser/image/tga_parser.hpp similarity index 89% rename from inc/starlet-serializer/parser/image/tgaParser.hpp rename to inc/starlet-serializer/parser/image/tga_parser.hpp index 9a87c83..08370b0 100644 --- a/inc/starlet-serializer/parser/image/tgaParser.hpp +++ b/inc/starlet-serializer/parser/image/tga_parser.hpp @@ -1,6 +1,6 @@ #pragma once -#include "starlet-serializer/parser/image/imageParserBase.hpp" +#include "starlet-serializer/parser/image/image_parser_base.hpp" namespace Starlet::Serializer { diff --git a/inc/starlet-serializer/parser/imageParser.hpp b/inc/starlet-serializer/parser/image_parser.hpp similarity index 100% rename from inc/starlet-serializer/parser/imageParser.hpp rename to inc/starlet-serializer/parser/image_parser.hpp diff --git a/inc/starlet-serializer/parser/mesh/meshParserBase.hpp b/inc/starlet-serializer/parser/mesh/mesh_parser_base.hpp similarity index 100% rename from inc/starlet-serializer/parser/mesh/meshParserBase.hpp rename to inc/starlet-serializer/parser/mesh/mesh_parser_base.hpp diff --git a/inc/starlet-serializer/parser/mesh/plyParser.hpp b/inc/starlet-serializer/parser/mesh/ply_parser.hpp similarity index 95% rename from inc/starlet-serializer/parser/mesh/plyParser.hpp rename to inc/starlet-serializer/parser/mesh/ply_parser.hpp index 01c3a25..3d9549b 100644 --- a/inc/starlet-serializer/parser/mesh/plyParser.hpp +++ b/inc/starlet-serializer/parser/mesh/ply_parser.hpp @@ -1,6 +1,6 @@ #pragma once -#include "meshParserBase.hpp" +#include "mesh_parser_base.hpp" namespace Starlet::Serializer { diff --git a/inc/starlet-serializer/parser/meshParser.hpp b/inc/starlet-serializer/parser/mesh_parser.hpp similarity index 100% rename from inc/starlet-serializer/parser/meshParser.hpp rename to inc/starlet-serializer/parser/mesh_parser.hpp diff --git a/inc/starlet-serializer/parser/sceneParser.hpp b/inc/starlet-serializer/parser/scene_parser.hpp similarity index 100% rename from inc/starlet-serializer/parser/sceneParser.hpp rename to inc/starlet-serializer/parser/scene_parser.hpp diff --git a/src/parser/image/bmpParser.cpp b/src/parser/image/bmp_parser.cpp similarity index 97% rename from src/parser/image/bmpParser.cpp rename to src/parser/image/bmp_parser.cpp index c8c1e5b..6074589 100644 --- a/src/parser/image/bmpParser.cpp +++ b/src/parser/image/bmp_parser.cpp @@ -1,5 +1,5 @@ -#include "starlet-serializer/parser/image/bmpParser.hpp" -#include "starlet-serializer/data/imageData.hpp" +#include "starlet-serializer/parser/image/bmp_parser.hpp" +#include "starlet-serializer/data/image_data.hpp" #include "starlet-logger/logger.hpp" diff --git a/src/parser/image/imageParserBase.cpp b/src/parser/image/image_parser_base.cpp similarity index 95% rename from src/parser/image/imageParserBase.cpp rename to src/parser/image/image_parser_base.cpp index 483e3af..a13f2f0 100644 --- a/src/parser/image/imageParserBase.cpp +++ b/src/parser/image/image_parser_base.cpp @@ -1,5 +1,5 @@ -#include "starlet-serializer/parser/image/imageParserBase.hpp" -#include "starlet-serializer/data/imageData.hpp" +#include "starlet-serializer/parser/image/image_parser_base.hpp" +#include "starlet-serializer/data/image_data.hpp" #include "starlet-logger/logger.hpp" diff --git a/src/parser/image/tgaParser.cpp b/src/parser/image/tga_parser.cpp similarity index 97% rename from src/parser/image/tgaParser.cpp rename to src/parser/image/tga_parser.cpp index 41be84b..16587e7 100644 --- a/src/parser/image/tgaParser.cpp +++ b/src/parser/image/tga_parser.cpp @@ -1,5 +1,5 @@ -#include "starlet-serializer/parser/image/tgaParser.hpp" -#include "starlet-serializer/data/imageData.hpp" +#include "starlet-serializer/parser/image/tga_parser.hpp" +#include "starlet-serializer/data/image_data.hpp" #include "starlet-logger/logger.hpp" diff --git a/src/parser/imageParser.cpp b/src/parser/image_parser.cpp similarity index 86% rename from src/parser/imageParser.cpp rename to src/parser/image_parser.cpp index 68daa6d..dd63d2e 100644 --- a/src/parser/imageParser.cpp +++ b/src/parser/image_parser.cpp @@ -1,7 +1,7 @@ -#include "starlet-serializer/parser/imageParser.hpp" +#include "starlet-serializer/parser/image_parser.hpp" -#include "starlet-serializer/parser/image/bmpParser.hpp" -#include "starlet-serializer/parser/image/tgaParser.hpp" +#include "starlet-serializer/parser/image/bmp_parser.hpp" +#include "starlet-serializer/parser/image/tga_parser.hpp" #include "starlet-logger/logger.hpp" diff --git a/src/parser/mesh/plyParser.cpp b/src/parser/mesh/ply_parser.cpp similarity index 98% rename from src/parser/mesh/plyParser.cpp rename to src/parser/mesh/ply_parser.cpp index f333466..b1f61ab 100644 --- a/src/parser/mesh/plyParser.cpp +++ b/src/parser/mesh/ply_parser.cpp @@ -1,5 +1,5 @@ -#include "starlet-serializer/parser/mesh/plyParser.hpp" -#include "starlet-serializer/data/meshData.hpp" +#include "starlet-serializer/parser/mesh/ply_parser.hpp" +#include "starlet-serializer/data/mesh_data.hpp" #include "starlet-logger/logger.hpp" diff --git a/src/parser/meshParser.cpp b/src/parser/mesh_parser.cpp similarity index 88% rename from src/parser/meshParser.cpp rename to src/parser/mesh_parser.cpp index 7313cc5..c15f724 100644 --- a/src/parser/meshParser.cpp +++ b/src/parser/mesh_parser.cpp @@ -1,6 +1,6 @@ -#include "starlet-serializer/parser/meshParser.hpp" +#include "starlet-serializer/parser/mesh_parser.hpp" -#include "starlet-serializer/parser/mesh/plyParser.hpp" +#include "starlet-serializer/parser/mesh/ply_parser.hpp" #include "starlet-logger/logger.hpp" diff --git a/src/parser/scene/cameraParser.cpp b/src/parser/scene/camera_parser.cpp similarity index 89% rename from src/parser/scene/cameraParser.cpp rename to src/parser/scene/camera_parser.cpp index 6595da3..17aea27 100644 --- a/src/parser/scene/cameraParser.cpp +++ b/src/parser/scene/camera_parser.cpp @@ -1,5 +1,5 @@ -#include "starlet-serializer/parser/sceneParser.hpp" -#include "starlet-serializer/data/cameraData.hpp" +#include "starlet-serializer/parser/scene_parser.hpp" +#include "starlet-serializer/data/camera_data.hpp" namespace Starlet::Serializer { diff --git a/src/parser/scene/colourParser.cpp b/src/parser/scene/colour_parser.cpp similarity index 96% rename from src/parser/scene/colourParser.cpp rename to src/parser/scene/colour_parser.cpp index 841aad0..0a161ec 100644 --- a/src/parser/scene/colourParser.cpp +++ b/src/parser/scene/colour_parser.cpp @@ -1,4 +1,4 @@ -#include "starlet-serializer/parser/sceneParser.hpp" +#include "starlet-serializer/parser/scene_parser.hpp" #include "starlet-math/vec4.hpp" diff --git a/src/parser/scene/gridParser.cpp b/src/parser/scene/grid_parser.cpp similarity index 90% rename from src/parser/scene/gridParser.cpp rename to src/parser/scene/grid_parser.cpp index 08cb992..4bcfb1d 100644 --- a/src/parser/scene/gridParser.cpp +++ b/src/parser/scene/grid_parser.cpp @@ -1,6 +1,6 @@ -#include "starlet-serializer/parser/sceneParser.hpp" +#include "starlet-serializer/parser/scene_parser.hpp" -#include "starlet-serializer/data/gridData.hpp" +#include "starlet-serializer/data/grid_data.hpp" namespace Starlet::Serializer { diff --git a/src/parser/scene/lightParser.cpp b/src/parser/scene/light_parser.cpp similarity index 94% rename from src/parser/scene/lightParser.cpp rename to src/parser/scene/light_parser.cpp index 6cba91b..46e0647 100644 --- a/src/parser/scene/lightParser.cpp +++ b/src/parser/scene/light_parser.cpp @@ -1,5 +1,5 @@ -#include "starlet-serializer/parser/sceneParser.hpp" -#include "starlet-serializer/data/lightData.hpp" +#include "starlet-serializer/parser/scene_parser.hpp" +#include "starlet-serializer/data/light_data.hpp" #include "starlet-logger/logger.hpp" diff --git a/src/parser/scene/modelParser.cpp b/src/parser/scene/model_parser.cpp similarity index 92% rename from src/parser/scene/modelParser.cpp rename to src/parser/scene/model_parser.cpp index 7a21c21..d46a672 100644 --- a/src/parser/scene/modelParser.cpp +++ b/src/parser/scene/model_parser.cpp @@ -1,5 +1,5 @@ -#include "starlet-serializer/parser/sceneParser.hpp" -#include "starlet-serializer/data/modelData.hpp" +#include "starlet-serializer/parser/scene_parser.hpp" +#include "starlet-serializer/data/model_data.hpp" namespace Starlet::Serializer { diff --git a/src/parser/scene/primitiveParser.cpp b/src/parser/scene/primitive_parser.cpp similarity index 89% rename from src/parser/scene/primitiveParser.cpp rename to src/parser/scene/primitive_parser.cpp index 6bfa763..73f38a2 100644 --- a/src/parser/scene/primitiveParser.cpp +++ b/src/parser/scene/primitive_parser.cpp @@ -1,5 +1,5 @@ -#include "starlet-serializer/parser/sceneParser.hpp" -#include "starlet-serializer/data/primitiveData.hpp" +#include "starlet-serializer/parser/scene_parser.hpp" +#include "starlet-serializer/data/primitive_data.hpp" namespace Starlet::Serializer { diff --git a/src/parser/scene/textureParser.cpp b/src/parser/scene/texture_parser.cpp similarity index 89% rename from src/parser/scene/textureParser.cpp rename to src/parser/scene/texture_parser.cpp index 4cc6904..6d57fc9 100644 --- a/src/parser/scene/textureParser.cpp +++ b/src/parser/scene/texture_parser.cpp @@ -1,5 +1,5 @@ -#include "starlet-serializer/parser/sceneParser.hpp" -#include "starlet-serializer/data/textureData.hpp" +#include "starlet-serializer/parser/scene_parser.hpp" +#include "starlet-serializer/data/texture_data.hpp" namespace Starlet::Serializer { diff --git a/src/parser/scene/velocityParser.cpp b/src/parser/scene/velocity_parser.cpp similarity index 66% rename from src/parser/scene/velocityParser.cpp rename to src/parser/scene/velocity_parser.cpp index b2bd29e..3384941 100644 --- a/src/parser/scene/velocityParser.cpp +++ b/src/parser/scene/velocity_parser.cpp @@ -1,5 +1,5 @@ -#include "starlet-serializer/parser/sceneParser.hpp" -#include "starlet-serializer/data/velocityData.hpp" +#include "starlet-serializer/parser/scene_parser.hpp" +#include "starlet-serializer/data/velocity_data.hpp" namespace Starlet::Serializer { diff --git a/src/parser/sceneParser.cpp b/src/parser/scene_parser.cpp similarity index 98% rename from src/parser/sceneParser.cpp rename to src/parser/scene_parser.cpp index 9a255df..e0bb4f9 100644 --- a/src/parser/sceneParser.cpp +++ b/src/parser/scene_parser.cpp @@ -1,5 +1,5 @@ -#include "starlet-serializer/parser/sceneParser.hpp" -#include "starlet-serializer/data/sceneData.hpp" +#include "starlet-serializer/parser/scene_parser.hpp" +#include "starlet-serializer/data/scene_data.hpp" #include "starlet-logger/logger.hpp" diff --git a/src/writer/sceneWriter.cpp b/src/writer/scene_writer.cpp similarity index 93% rename from src/writer/sceneWriter.cpp rename to src/writer/scene_writer.cpp index 2b3ba9a..68db9ba 100644 --- a/src/writer/sceneWriter.cpp +++ b/src/writer/scene_writer.cpp @@ -1,16 +1,16 @@ #include "starlet-serializer/writer/writer.hpp" #include "starlet-logger/logger.hpp" -#include "starlet-serializer/data/sceneData.hpp" -#include "starlet-serializer/data/modelData.hpp" -#include "starlet-serializer/data/lightData.hpp" -#include "starlet-serializer/data/cameraData.hpp" -#include "starlet-serializer/data/gridData.hpp" -#include "starlet-serializer/data/textureData.hpp" -#include "starlet-serializer/data/primitiveData.hpp" -#include "starlet-serializer/data/transformData.hpp" -#include "starlet-serializer/data/velocityData.hpp" -#include "starlet-serializer/data/colourData.hpp" +#include "starlet-serializer/data/scene_data.hpp" +#include "starlet-serializer/data/model_data.hpp" +#include "starlet-serializer/data/light_data.hpp" +#include "starlet-serializer/data/camera_data.hpp" +#include "starlet-serializer/data/grid_data.hpp" +#include "starlet-serializer/data/texture_data.hpp" +#include "starlet-serializer/data/primitive_data.hpp" +#include "starlet-serializer/data/transform_data.hpp" +#include "starlet-serializer/data/velocity_data.hpp" +#include "starlet-serializer/data/colour_data.hpp" #include diff --git a/tests/image_parser_test.cpp b/tests/image_parser_test.cpp index dadafae..32d922a 100644 --- a/tests/image_parser_test.cpp +++ b/tests/image_parser_test.cpp @@ -1,7 +1,5 @@ #include -#include "starlet-serializer/parser/imageParser.hpp" -#include "starlet-serializer/data/imageData.hpp" #include "test_helpers.hpp" #include diff --git a/tests/mesh/ply_parser_test.cpp b/tests/mesh/ply_parser_test.cpp index 8197ae6..a93d7fa 100644 --- a/tests/mesh/ply_parser_test.cpp +++ b/tests/mesh/ply_parser_test.cpp @@ -1,7 +1,7 @@ #include -#include "starlet-serializer/parser/meshParser.hpp" -#include "starlet-serializer/data/meshData.hpp" +#include "starlet-serializer/parser/mesh_parser.hpp" +#include "starlet-serializer/data/mesh_data.hpp" #include "../test_helpers.hpp" #include diff --git a/tests/mesh_parser_test.cpp b/tests/mesh_parser_test.cpp index 6cddc91..9478be9 100644 --- a/tests/mesh_parser_test.cpp +++ b/tests/mesh_parser_test.cpp @@ -1,7 +1,7 @@ #include -#include "starlet-serializer/parser/meshParser.hpp" -#include "starlet-serializer/data/meshData.hpp" +#include "starlet-serializer/parser/mesh_parser.hpp" +#include "starlet-serializer/data/mesh_data.hpp" #include "test_helpers.hpp" #include diff --git a/tests/scene_parser_test.cpp b/tests/scene_parser_test.cpp index 47c9b0c..c8aa387 100644 --- a/tests/scene_parser_test.cpp +++ b/tests/scene_parser_test.cpp @@ -1,7 +1,7 @@ #include "gtest/gtest.h" -#include "starlet-serializer/parser/sceneParser.hpp" -#include "starlet-serializer/data/sceneData.hpp" +#include "starlet-serializer/parser/scene_parser.hpp" +#include "starlet-serializer/data/scene_data.hpp" #include "test_helpers.hpp" #include "starlet-math/vec4.hpp" diff --git a/tests/test_helpers.hpp b/tests/test_helpers.hpp index 6d26979..130b93a 100644 --- a/tests/test_helpers.hpp +++ b/tests/test_helpers.hpp @@ -1,8 +1,8 @@ #pragma once #include -#include "starlet-serializer/parser/imageParser.hpp" -#include "starlet-serializer/data/imageData.hpp" +#include "starlet-serializer/parser/image_parser.hpp" +#include "starlet-serializer/data/image_data.hpp" #include #include From 1795f1890b72aae327c5c1ec0f8749efae2efd87 Mon Sep 17 00:00:00 2001 From: Masonlet Date: Fri, 21 Nov 2025 21:16:51 -0500 Subject: [PATCH 2/3] Refactor mesh/image tests and consolidate helpers - Remove redundant includes - Clean up mesh test and unify under shared test fixture --- tests/image_parser_test.cpp | 7 -- tests/mesh/ply_parser_test.cpp | 129 ++++++++------------------------- tests/mesh_parser_test.cpp | 29 ++------ tests/test_helpers.hpp | 9 +++ 4 files changed, 46 insertions(+), 128 deletions(-) diff --git a/tests/image_parser_test.cpp b/tests/image_parser_test.cpp index 32d922a..7fb7bb9 100644 --- a/tests/image_parser_test.cpp +++ b/tests/image_parser_test.cpp @@ -1,12 +1,5 @@ -#include - #include "test_helpers.hpp" -#include -#include - -namespace SSerializer = Starlet::Serializer; - // BMP format detection TEST_F(ImageParserTest, DetectFormatBmpLowercase) { createTestFile("test_data/image.bmp", "BM"); diff --git a/tests/mesh/ply_parser_test.cpp b/tests/mesh/ply_parser_test.cpp index a93d7fa..43601e3 100644 --- a/tests/mesh/ply_parser_test.cpp +++ b/tests/mesh/ply_parser_test.cpp @@ -1,16 +1,9 @@ -#include - -#include "starlet-serializer/parser/mesh_parser.hpp" -#include "starlet-serializer/data/mesh_data.hpp" #include "../test_helpers.hpp" -#include -#include - -namespace SSerializer = Starlet::Serializer; +class PlyParserTest : public MeshParserTest {}; // Valid PLY parsing tests -TEST(PlyParserTest, ValidPlyMinimal) { +TEST_F(PlyParserTest, ValidPlyMinimal) { const std::string_view plyContent = R"(ply format ascii 1.0 element vertex 3 @@ -26,8 +19,6 @@ end_header 3 0 1 2 )"; createTestFile("test_data/minimal.ply", plyContent); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_TRUE(parser.parse("test_data/minimal.ply", out)); EXPECT_EQ(out.numVertices, 3); EXPECT_EQ(out.numTriangles, 1); @@ -39,7 +30,7 @@ end_header EXPECT_FALSE(out.hasTexCoords); } -TEST(PlyParserTest, ValidPlyWithNormals) { +TEST_F(PlyParserTest, ValidPlyWithNormals) { const std::string_view plyContent = R"(ply format ascii 1.0 element vertex 3 @@ -58,8 +49,6 @@ end_header 3 0 1 2 )"; createTestFile("test_data/normals.ply", plyContent); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_TRUE(parser.parse("test_data/normals.ply", out)); EXPECT_EQ(out.numVertices, 3); EXPECT_EQ(out.numTriangles, 1); @@ -71,7 +60,7 @@ end_header EXPECT_FALSE(out.hasTexCoords); } -TEST(PlyParserTest, ValidPlyWithColours) { +TEST_F(PlyParserTest, ValidPlyWithColours) { const std::string_view plyContent = R"(ply format ascii 1.0 element vertex 3 @@ -90,8 +79,6 @@ end_header 3 0 1 2 )"; createTestFile("test_data/colours.ply", plyContent); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_TRUE(parser.parse("test_data/colours.ply", out)); EXPECT_EQ(out.numVertices, 3); EXPECT_EQ(out.numTriangles, 1); @@ -105,7 +92,7 @@ end_header EXPECT_FLOAT_EQ(out.vertices[0].col.z, 0.0f); } -TEST(PlyParserTest, ValidPlyWithTexCoords) { +TEST_F(PlyParserTest, ValidPlyWithTexCoords) { const std::string_view plyContent = R"(ply format ascii 1.0 element vertex 3 @@ -123,8 +110,6 @@ end_header 3 0 1 2 )"; createTestFile("test_data/texcoords.ply", plyContent); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_TRUE(parser.parse("test_data/texcoords.ply", out)); EXPECT_EQ(out.numVertices, 3); EXPECT_EQ(out.numTriangles, 1); @@ -138,7 +123,7 @@ end_header EXPECT_FLOAT_EQ(out.vertices[2].texCoord.y, 1.0f); } -TEST(PlyParserTest, ValidPlyMultipleTriangles) { +TEST_F(PlyParserTest, ValidPlyMultipleTriangles) { const std::string_view plyContent = R"(ply format ascii 1.0 element vertex 4 @@ -156,8 +141,6 @@ end_header 3 0 2 3 )"; createTestFile("test_data/quad.ply", plyContent); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_TRUE(parser.parse("test_data/quad.ply", out)); EXPECT_EQ(out.numVertices, 4); EXPECT_EQ(out.numTriangles, 2); @@ -170,7 +153,7 @@ end_header EXPECT_EQ(out.indices[5], 3); } -TEST(PlyParserTest, PlyExtremeFloatValues) { +TEST_F(PlyParserTest, PlyExtremeFloatValues) { const std::string_view plyContent = R"(ply format ascii 1.0 element vertex 2 @@ -185,14 +168,12 @@ end_header 3 0 1 1 )"; createTestFile("test_data/extreme_float.ply", plyContent); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_TRUE(parser.parse("test_data/extreme_float.ply", out)); EXPECT_FLOAT_EQ(out.vertices[0].pos.x, 1e38f); EXPECT_FLOAT_EQ(out.vertices[1].pos.x, -1e38f); } -TEST(PlyParserTest, LargePly) { +TEST_F(PlyParserTest, LargePly) { const int NUM = 100000; std::ofstream file("test_data/large.ply"); file << "ply\nformat ascii 1.0\nelement vertex " << NUM << "\n" @@ -202,14 +183,12 @@ TEST(PlyParserTest, LargePly) { for (int i = 0; i < NUM - 2; i++) file << "3 " << i << " " << (i + 1) << " " << (i + 2) << "\n"; file.close(); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_TRUE(parser.parse("test_data/large.ply", out)); EXPECT_EQ(out.numVertices, NUM); EXPECT_EQ(out.numTriangles, NUM - 2); } -TEST(PlyParserTest, PartialNormalsNotCounted) { +TEST_F(PlyParserTest, PartialNormalsNotCounted) { const std::string_view ply = R"(ply format ascii 1.0 element vertex 1 @@ -225,13 +204,11 @@ end_header 3 0 0 0 )"; createTestFile("test_data/partial_normals.ply", ply); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_TRUE(parser.parse("test_data/partial_normals.ply", out)); EXPECT_FALSE(out.hasNormals); } -TEST(PlyParserTest, AcceptAlternatePropertyNames) { +TEST_F(PlyParserTest, AcceptAlternatePropertyNames) { const std::string_view ply = R"(ply format ascii 1.0 element vertex 1 @@ -250,14 +227,12 @@ end_header 3 0 0 0 )"; createTestFile("test_data/alt_names.ply", ply); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_TRUE(parser.parse("test_data/alt_names.ply", out)); EXPECT_TRUE(out.hasNormals); EXPECT_TRUE(out.hasTexCoords); } -TEST(PlyParserTest, FloatColourParsing) { +TEST_F(PlyParserTest, FloatColourParsing) { const std::string_view ply = R"(ply format ascii 1.0 element vertex 1 @@ -274,8 +249,6 @@ end_header 3 0 0 0 )"; createTestFile("test_data/float_colours.ply", ply); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_TRUE(parser.parse("test_data/float_colours.ply", out)); EXPECT_TRUE(out.hasColours); EXPECT_FLOAT_EQ(out.vertices[0].col.x, 0.5f); @@ -283,7 +256,7 @@ end_header EXPECT_FLOAT_EQ(out.vertices[0].col.z, 1.0f); } -TEST(PlyParserTest, UcharColourWithAlpha) { +TEST_F(PlyParserTest, UcharColourWithAlpha) { const std::string_view ply = R"(ply format ascii 1.0 element vertex 1 @@ -301,14 +274,12 @@ end_header 3 0 0 0 )"; createTestFile("test_data/uchar_alpha.ply", ply); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_TRUE(parser.parse("test_data/uchar_alpha.ply", out)); EXPECT_TRUE(out.hasColours); EXPECT_FLOAT_EQ(out.vertices[0].col.w, 128.0f / 255.0f); } -TEST(PlyParserTest, PlyExtraVertexProperties) { +TEST_F(PlyParserTest, PlyExtraVertexProperties) { const std::string_view plyContent = R"(ply format ascii 1.0 element vertex 2 @@ -327,13 +298,11 @@ end_header 3 0 1 0 )"; createTestFile("test_data/extra_props.ply", plyContent); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_TRUE(parser.parse("test_data/extra_props.ply", out)); EXPECT_EQ(out.numVertices, 2); } -TEST(PlyParserTest, PlyVertexPositionBounds) { +TEST_F(PlyParserTest, PlyVertexPositionBounds) { const std::string_view plyContent = R"(ply format ascii 1.0 element vertex 3 @@ -349,14 +318,12 @@ end_header 3 0 1 2 )"; createTestFile("test_data/bounds.ply", plyContent); - Starlet::Serializer::MeshParser parser; - Starlet::Serializer::MeshData out; EXPECT_TRUE(parser.parse("test_data/bounds.ply", out)); EXPECT_FLOAT_EQ(out.minY, -5.0f); EXPECT_FLOAT_EQ(out.maxY, 10.0f); } -TEST(PlyParserTest, HandlesWhitespaceBetweenSections) { +TEST_F(PlyParserTest, HandlesWhitespaceBetweenSections) { const std::string_view ply = R"(ply format ascii 1.0 element vertex 2 @@ -374,12 +341,10 @@ end_header 3 0 1 0 )"; createTestFile("test_data/whitespace.ply", ply); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_TRUE(parser.parse("test_data/whitespace.ply", out)); } -TEST(PlyParserTest, SupportsComments) { +TEST_F(PlyParserTest, SupportsComments) { const std::string_view ply = R"(ply format ascii 1.0 comment created by test @@ -394,12 +359,10 @@ end_header 3 0 0 0 )"; createTestFile("test_data/comments.ply", ply); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_TRUE(parser.parse("test_data/comments.ply", out)); } -TEST(PlyParserTest, ExtraFacePropertiesIgnored) { +TEST_F(PlyParserTest, ExtraFacePropertiesIgnored) { const std::string_view ply = R"(ply format ascii 1.0 element vertex 3 @@ -416,28 +379,22 @@ end_header 3 0 1 2 42.0 )"; createTestFile("test_data/extra_face_props.ply", ply); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_TRUE(parser.parse("test_data/extra_face_props.ply", out)); } // Error tests -TEST(PlyParserTest, PlyEmpty) { +TEST_F(PlyParserTest, PlyEmpty) { createTestFile("test_data/empty.ply", ""); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_FALSE(parser.parse("test_data/empty.ply", out)); } -TEST(PlyParserTest, PlyNoHeader) { +TEST_F(PlyParserTest, PlyNoHeader) { createTestFile("test_data/noheader.ply", "0.0 0.0 0.0\n"); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_FALSE(parser.parse("test_data/noheader.ply", out)); } -TEST(PlyParserTest, PlyZeroVertices) { +TEST_F(PlyParserTest, PlyZeroVertices) { const std::string_view plyContent = R"(ply format ascii 1.0 element vertex 0 @@ -445,12 +402,10 @@ element face 0 end_header )"; createTestFile("test_data/zero.ply", plyContent); - Starlet::Serializer::MeshParser parser; - Starlet::Serializer::MeshData out; EXPECT_FALSE(parser.parse("test_data/zero.ply", out)); } -TEST(PlyParserTest, PlyZeroFaces) { +TEST_F(PlyParserTest, PlyZeroFaces) { const std::string_view plyContent = R"(ply format ascii 1.0 element vertex 3 @@ -464,12 +419,10 @@ end_header 0 1 0 )"; createTestFile("test_data/nofaces.ply", plyContent); - Starlet::Serializer::MeshParser parser; - Starlet::Serializer::MeshData out; EXPECT_FALSE(parser.parse("test_data/nofaces.ply", out)); } -TEST(PlyParserTest, PlyInvalidFloat) { +TEST_F(PlyParserTest, PlyInvalidFloat) { const std::string_view plyContent = R"(ply format ascii 1.0 element vertex 1 @@ -481,12 +434,10 @@ end_header a b c )"; createTestFile("test_data/invalid_float.ply", plyContent); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_FALSE(parser.parse("test_data/invalid_float.ply", out)); } -TEST(PlyParserTest, PlyMissingEndHeader) { +TEST_F(PlyParserTest, PlyMissingEndHeader) { const std::string_view plyContent = R"(ply format ascii 1.0 element vertex 3 @@ -496,18 +447,14 @@ property float z 0.0 0.0 0.0 )"; createTestFile("test_data/noend.ply", plyContent); - Starlet::Serializer::MeshParser parser; - Starlet::Serializer::MeshData out; EXPECT_FALSE(parser.parse("test_data/noend.ply", out)); } -TEST(PlyParserTest, PlyNonexistentFile) { - Starlet::Serializer::MeshParser parser; - Starlet::Serializer::MeshData out; +TEST_F(PlyParserTest, PlyNonexistentFile) { EXPECT_FALSE(parser.parse("test_data/nonexistent.ply", out)); } -TEST(PlyParserTest, PlyFewerVerticesThanDeclared) { +TEST_F(PlyParserTest, PlyFewerVerticesThanDeclared) { const std::string_view ply = R"(ply format ascii 1.0 element vertex 3 @@ -521,12 +468,10 @@ end_header 1 0 0 )"; createTestFile("test_data/fewer_verts.ply", ply); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_FALSE(parser.parse("test_data/fewer_verts.ply", out)); } -TEST(PlyParserTest, PlyFewerFacesThanDeclared) { +TEST_F(PlyParserTest, PlyFewerFacesThanDeclared) { const std::string_view ply = R"(ply format ascii 1.0 element vertex 3 @@ -542,12 +487,10 @@ end_header 3 0 1 2 )"; createTestFile("test_data/fewer_faces.ply", ply); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_FALSE(parser.parse("test_data/fewer_faces.ply", out)); } -TEST(PlyParserTest, PlyInvalidVertexIndex) { +TEST_F(PlyParserTest, PlyInvalidVertexIndex) { const std::string_view ply = R"(ply format ascii 1.0 element vertex 2 @@ -562,12 +505,10 @@ end_header 3 0 1 5 )"; createTestFile("test_data/invalid_index.ply", ply); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_FALSE(parser.parse("test_data/invalid_index.ply", out)); } -TEST(PlyParserTest, RejectNonTriangleFace) { +TEST_F(PlyParserTest, RejectNonTriangleFace) { const std::string_view ply = R"(ply format ascii 1.0 element vertex 4 @@ -584,12 +525,10 @@ end_header 4 0 1 2 3 )"; createTestFile("test_data/quad_face.ply", ply); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_FALSE(parser.parse("test_data/quad_face.ply", out)); } -TEST(PlyParserTest, RejectFaceWithZeroIndices) { +TEST_F(PlyParserTest, RejectFaceWithZeroIndices) { const std::string_view ply = R"(ply format ascii 1.0 element vertex 1 @@ -603,12 +542,10 @@ end_header 0 )"; createTestFile("test_data/zero_face.ply", ply); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_FALSE(parser.parse("test_data/zero_face.ply", out)); } -TEST(PlyParserTest, RejectFaceWithOneIndex) { +TEST_F(PlyParserTest, RejectFaceWithOneIndex) { const std::string_view ply = R"(ply format ascii 1.0 element vertex 1 @@ -622,12 +559,10 @@ end_header 1 0 )"; createTestFile("test_data/one_face.ply", ply); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_FALSE(parser.parse("test_data/one_face.ply", out)); } -TEST(PlyParserTest, RejectIncompleteVertexData) { +TEST_F(PlyParserTest, RejectIncompleteVertexData) { const std::string_view ply = R"(ply format ascii 1.0 element vertex 2 @@ -641,7 +576,5 @@ end_header 1 0 )"; createTestFile("test_data/incomplete_vertex.ply", ply); - SSerializer::MeshParser parser; - SSerializer::MeshData out; EXPECT_FALSE(parser.parse("test_data/incomplete_vertex.ply", out)); } \ No newline at end of file diff --git a/tests/mesh_parser_test.cpp b/tests/mesh_parser_test.cpp index 9478be9..dbb76a8 100644 --- a/tests/mesh_parser_test.cpp +++ b/tests/mesh_parser_test.cpp @@ -1,28 +1,11 @@ -#include - -#include "starlet-serializer/parser/mesh_parser.hpp" -#include "starlet-serializer/data/mesh_data.hpp" #include "test_helpers.hpp" -#include -#include - -namespace SSerializer = Starlet::Serializer; - -class MeshParserTest : public ::testing::Test { -protected: - SSerializer::MeshParser parser; - SSerializer::MeshData meshData; - const std::string testFileName = "test_data/test_mesh.ply"; -}; - - // PLY format detection TEST_F(MeshParserTest, DetectFormatPlyLowercase) { createTestFile("test_data/model.ply", "ply\nformat ascii 1.0\nelement vertex 0\nelement face 0\nend_header\n"); testing::internal::CaptureStderr(); - EXPECT_FALSE(parser.parse("test_data/model.ply", meshData)); + EXPECT_FALSE(parser.parse("test_data/model.ply", out)); std::string output = testing::internal::GetCapturedStderr(); // PLY extension was properly detected and routed to PlyParser @@ -33,7 +16,7 @@ TEST_F(MeshParserTest, DetectFormatPlyUppercase) { createTestFile("test_data/model.PLY", "ply\nformat ascii 1.0\nelement vertex 0\nelement face 0\nend_header\n"); testing::internal::CaptureStderr(); - EXPECT_FALSE(parser.parse("test_data/model.PLY", meshData)); + EXPECT_FALSE(parser.parse("test_data/model.PLY", out)); std::string output = testing::internal::GetCapturedStderr(); // PLY extension was properly detected and routed to PlyParser @@ -44,7 +27,7 @@ TEST_F(MeshParserTest, DetectFormatPlyMixedCase) { createTestFile("test_data/model.PlY", "ply\nformat ascii 1.0\nelement vertex 0\nelement face 0\nend_header\n"); testing::internal::CaptureStderr(); - EXPECT_FALSE(parser.parse("test_data/model.PlY", meshData)); + EXPECT_FALSE(parser.parse("test_data/model.PlY", out)); std::string output = testing::internal::GetCapturedStderr(); // PLY extension was properly detected and routed to PlyParser @@ -57,7 +40,7 @@ TEST_F(MeshParserTest, DetectFormatNoExtension) { createTestFile("test_data/model", "ply\nformat ascii 1.0\nelement vertex 0\nelement face 0\nend_header\n"); testing::internal::CaptureStderr(); - EXPECT_FALSE(parser.parse("test_data/model", meshData)); + EXPECT_FALSE(parser.parse("test_data/model", out)); std::string output = testing::internal::GetCapturedStderr(); EXPECT_NE(output.find("Unsupported mesh format: test_data/model"), std::string::npos); @@ -67,7 +50,7 @@ TEST_F(MeshParserTest, DetectFormatUnknownExtension) { createTestFile("test_data/model.unknown", "ply\nformat ascii 1.0\nelement vertex 0\nelement face 0\nend_header\n"); testing::internal::CaptureStderr(); - EXPECT_FALSE(parser.parse("test_data/model.unknown", meshData)); + EXPECT_FALSE(parser.parse("test_data/model.unknown", out)); std::string output = testing::internal::GetCapturedStderr(); EXPECT_NE(output.find("Unsupported mesh format: test_data/model.unknown"), std::string::npos); @@ -77,7 +60,7 @@ TEST_F(MeshParserTest, DetectFormatEmptyExtension) { createTestFile("test_data/model.", "ply\n"); testing::internal::CaptureStderr(); - EXPECT_FALSE(parser.parse("test_data/model.", meshData)); + EXPECT_FALSE(parser.parse("test_data/model.", out)); std::string output = testing::internal::GetCapturedStderr(); EXPECT_NE(output.find("Unsupported mesh format: test_data/model."), std::string::npos); diff --git a/tests/test_helpers.hpp b/tests/test_helpers.hpp index 130b93a..5c940f0 100644 --- a/tests/test_helpers.hpp +++ b/tests/test_helpers.hpp @@ -4,6 +4,9 @@ #include "starlet-serializer/parser/image_parser.hpp" #include "starlet-serializer/data/image_data.hpp" +#include "starlet-serializer/parser/mesh_parser.hpp" +#include "starlet-serializer/data/mesh_data.hpp" + #include #include @@ -39,4 +42,10 @@ class ImageParserTest : public ::testing::Test { SSerializer::ImageParser parser; SSerializer::ImageData out; +}; + +class MeshParserTest : public ::testing::Test { +protected: + SSerializer::MeshParser parser; + SSerializer::MeshData out; }; \ No newline at end of file From 9c766787e3a17c2a0931be0bc5478d77f8e05c45 Mon Sep 17 00:00:00 2001 From: Masonlet Date: Fri, 21 Nov 2025 21:30:24 -0500 Subject: [PATCH 3/3] Refactor PlyParserTests to use helper functions consistently --- tests/mesh/ply_parser_test.cpp | 86 ++++++++++++---------------------- tests/test_helpers.hpp | 12 +++++ 2 files changed, 42 insertions(+), 56 deletions(-) diff --git a/tests/mesh/ply_parser_test.cpp b/tests/mesh/ply_parser_test.cpp index 43601e3..7e13651 100644 --- a/tests/mesh/ply_parser_test.cpp +++ b/tests/mesh/ply_parser_test.cpp @@ -19,12 +19,7 @@ end_header 3 0 1 2 )"; createTestFile("test_data/minimal.ply", plyContent); - EXPECT_TRUE(parser.parse("test_data/minimal.ply", out)); - EXPECT_EQ(out.numVertices, 3); - EXPECT_EQ(out.numTriangles, 1); - EXPECT_EQ(out.numIndices, 3); - EXPECT_EQ(out.indices.size(), 3); - EXPECT_EQ(out.vertices.size(), 3); + expectValidParse("test_data/minimal.ply", 3, 1); EXPECT_FALSE(out.hasNormals); EXPECT_FALSE(out.hasColours); EXPECT_FALSE(out.hasTexCoords); @@ -49,12 +44,7 @@ end_header 3 0 1 2 )"; createTestFile("test_data/normals.ply", plyContent); - EXPECT_TRUE(parser.parse("test_data/normals.ply", out)); - EXPECT_EQ(out.numVertices, 3); - EXPECT_EQ(out.numTriangles, 1); - EXPECT_EQ(out.numIndices, 3); - EXPECT_EQ(out.indices.size(), 3); - EXPECT_EQ(out.vertices.size(), 3); + expectValidParse("test_data/normals.ply", 3, 1); EXPECT_TRUE(out.hasNormals); EXPECT_FALSE(out.hasColours); EXPECT_FALSE(out.hasTexCoords); @@ -79,12 +69,7 @@ end_header 3 0 1 2 )"; createTestFile("test_data/colours.ply", plyContent); - EXPECT_TRUE(parser.parse("test_data/colours.ply", out)); - EXPECT_EQ(out.numVertices, 3); - EXPECT_EQ(out.numTriangles, 1); - EXPECT_EQ(out.numIndices, 3); - EXPECT_EQ(out.indices.size(), 3); - EXPECT_EQ(out.vertices.size(), 3); + expectValidParse("test_data/colours.ply", 3, 1); EXPECT_FALSE(out.hasNormals); EXPECT_TRUE(out.hasColours); EXPECT_FLOAT_EQ(out.vertices[0].col.x, 1.0f); @@ -110,12 +95,7 @@ end_header 3 0 1 2 )"; createTestFile("test_data/texcoords.ply", plyContent); - EXPECT_TRUE(parser.parse("test_data/texcoords.ply", out)); - EXPECT_EQ(out.numVertices, 3); - EXPECT_EQ(out.numTriangles, 1); - EXPECT_EQ(out.numIndices, 3); - EXPECT_EQ(out.indices.size(), 3); - EXPECT_EQ(out.vertices.size(), 3); + expectValidParse("test_data/texcoords.ply", 3, 1); EXPECT_FALSE(out.hasNormals); EXPECT_FALSE(out.hasColours); EXPECT_TRUE(out.hasTexCoords); @@ -141,10 +121,7 @@ end_header 3 0 2 3 )"; createTestFile("test_data/quad.ply", plyContent); - EXPECT_TRUE(parser.parse("test_data/quad.ply", out)); - EXPECT_EQ(out.numVertices, 4); - EXPECT_EQ(out.numTriangles, 2); - EXPECT_EQ(out.numIndices, 6); + expectValidParse("test_data/quad.ply", 4, 2); EXPECT_EQ(out.indices[0], 0); EXPECT_EQ(out.indices[1], 1); EXPECT_EQ(out.indices[2], 2); @@ -168,7 +145,7 @@ end_header 3 0 1 1 )"; createTestFile("test_data/extreme_float.ply", plyContent); - EXPECT_TRUE(parser.parse("test_data/extreme_float.ply", out)); + expectValidParse("test_data/extreme_float.ply", 2, 1); EXPECT_FLOAT_EQ(out.vertices[0].pos.x, 1e38f); EXPECT_FLOAT_EQ(out.vertices[1].pos.x, -1e38f); } @@ -183,9 +160,7 @@ TEST_F(PlyParserTest, LargePly) { for (int i = 0; i < NUM - 2; i++) file << "3 " << i << " " << (i + 1) << " " << (i + 2) << "\n"; file.close(); - EXPECT_TRUE(parser.parse("test_data/large.ply", out)); - EXPECT_EQ(out.numVertices, NUM); - EXPECT_EQ(out.numTriangles, NUM - 2); + expectValidParse("test_data/large.ply", NUM, NUM - 2); } TEST_F(PlyParserTest, PartialNormalsNotCounted) { @@ -204,7 +179,7 @@ end_header 3 0 0 0 )"; createTestFile("test_data/partial_normals.ply", ply); - EXPECT_TRUE(parser.parse("test_data/partial_normals.ply", out)); + expectValidParse("test_data/partial_normals.ply", 1, 1); EXPECT_FALSE(out.hasNormals); } @@ -227,7 +202,7 @@ end_header 3 0 0 0 )"; createTestFile("test_data/alt_names.ply", ply); - EXPECT_TRUE(parser.parse("test_data/alt_names.ply", out)); + expectValidParse("test_data/alt_names.ply", 1, 1); EXPECT_TRUE(out.hasNormals); EXPECT_TRUE(out.hasTexCoords); } @@ -249,7 +224,7 @@ end_header 3 0 0 0 )"; createTestFile("test_data/float_colours.ply", ply); - EXPECT_TRUE(parser.parse("test_data/float_colours.ply", out)); + expectValidParse("test_data/float_colours.ply", 1, 1); EXPECT_TRUE(out.hasColours); EXPECT_FLOAT_EQ(out.vertices[0].col.x, 0.5f); EXPECT_FLOAT_EQ(out.vertices[0].col.y, 0.25f); @@ -274,7 +249,7 @@ end_header 3 0 0 0 )"; createTestFile("test_data/uchar_alpha.ply", ply); - EXPECT_TRUE(parser.parse("test_data/uchar_alpha.ply", out)); + expectValidParse("test_data/uchar_alpha.ply", 1, 1); EXPECT_TRUE(out.hasColours); EXPECT_FLOAT_EQ(out.vertices[0].col.w, 128.0f / 255.0f); } @@ -298,8 +273,7 @@ end_header 3 0 1 0 )"; createTestFile("test_data/extra_props.ply", plyContent); - EXPECT_TRUE(parser.parse("test_data/extra_props.ply", out)); - EXPECT_EQ(out.numVertices, 2); + expectValidParse("test_data/extra_props.ply", 2, 1); } TEST_F(PlyParserTest, PlyVertexPositionBounds) { @@ -318,7 +292,7 @@ end_header 3 0 1 2 )"; createTestFile("test_data/bounds.ply", plyContent); - EXPECT_TRUE(parser.parse("test_data/bounds.ply", out)); + expectValidParse("test_data/bounds.ply", 3, 1); EXPECT_FLOAT_EQ(out.minY, -5.0f); EXPECT_FLOAT_EQ(out.maxY, 10.0f); } @@ -341,7 +315,7 @@ end_header 3 0 1 0 )"; createTestFile("test_data/whitespace.ply", ply); - EXPECT_TRUE(parser.parse("test_data/whitespace.ply", out)); + expectValidParse("test_data/whitespace.ply", 2, 1); } TEST_F(PlyParserTest, SupportsComments) { @@ -359,7 +333,7 @@ end_header 3 0 0 0 )"; createTestFile("test_data/comments.ply", ply); - EXPECT_TRUE(parser.parse("test_data/comments.ply", out)); + expectValidParse("test_data/comments.ply", 1, 1); } TEST_F(PlyParserTest, ExtraFacePropertiesIgnored) { @@ -379,19 +353,19 @@ end_header 3 0 1 2 42.0 )"; createTestFile("test_data/extra_face_props.ply", ply); - EXPECT_TRUE(parser.parse("test_data/extra_face_props.ply", out)); + expectValidParse("test_data/extra_face_props.ply", 3, 1); } // Error tests TEST_F(PlyParserTest, PlyEmpty) { createTestFile("test_data/empty.ply", ""); - EXPECT_FALSE(parser.parse("test_data/empty.ply", out)); + expectInvalidParse("test_data/empty.ply"); } TEST_F(PlyParserTest, PlyNoHeader) { createTestFile("test_data/noheader.ply", "0.0 0.0 0.0\n"); - EXPECT_FALSE(parser.parse("test_data/noheader.ply", out)); + expectInvalidParse("test_data/noheader.ply"); } TEST_F(PlyParserTest, PlyZeroVertices) { @@ -402,7 +376,7 @@ element face 0 end_header )"; createTestFile("test_data/zero.ply", plyContent); - EXPECT_FALSE(parser.parse("test_data/zero.ply", out)); + expectInvalidParse("test_data/zero.ply"); } TEST_F(PlyParserTest, PlyZeroFaces) { @@ -419,7 +393,7 @@ end_header 0 1 0 )"; createTestFile("test_data/nofaces.ply", plyContent); - EXPECT_FALSE(parser.parse("test_data/nofaces.ply", out)); + expectInvalidParse("test_data/nofaces.ply"); } TEST_F(PlyParserTest, PlyInvalidFloat) { @@ -434,7 +408,7 @@ end_header a b c )"; createTestFile("test_data/invalid_float.ply", plyContent); - EXPECT_FALSE(parser.parse("test_data/invalid_float.ply", out)); + expectInvalidParse("test_data/invalid_float.ply"); } TEST_F(PlyParserTest, PlyMissingEndHeader) { @@ -447,11 +421,11 @@ property float z 0.0 0.0 0.0 )"; createTestFile("test_data/noend.ply", plyContent); - EXPECT_FALSE(parser.parse("test_data/noend.ply", out)); + expectInvalidParse("test_data/noend.ply"); } TEST_F(PlyParserTest, PlyNonexistentFile) { - EXPECT_FALSE(parser.parse("test_data/nonexistent.ply", out)); + expectInvalidParse("test_data/nonexistent.ply"); } TEST_F(PlyParserTest, PlyFewerVerticesThanDeclared) { @@ -468,7 +442,7 @@ end_header 1 0 0 )"; createTestFile("test_data/fewer_verts.ply", ply); - EXPECT_FALSE(parser.parse("test_data/fewer_verts.ply", out)); + expectInvalidParse("test_data/fewer_verts.ply"); } TEST_F(PlyParserTest, PlyFewerFacesThanDeclared) { @@ -487,7 +461,7 @@ end_header 3 0 1 2 )"; createTestFile("test_data/fewer_faces.ply", ply); - EXPECT_FALSE(parser.parse("test_data/fewer_faces.ply", out)); + expectInvalidParse("test_data/fewer_faces.ply"); } TEST_F(PlyParserTest, PlyInvalidVertexIndex) { @@ -505,7 +479,7 @@ end_header 3 0 1 5 )"; createTestFile("test_data/invalid_index.ply", ply); - EXPECT_FALSE(parser.parse("test_data/invalid_index.ply", out)); + expectInvalidParse("test_data/invalid_index.ply"); } TEST_F(PlyParserTest, RejectNonTriangleFace) { @@ -525,7 +499,7 @@ end_header 4 0 1 2 3 )"; createTestFile("test_data/quad_face.ply", ply); - EXPECT_FALSE(parser.parse("test_data/quad_face.ply", out)); + expectInvalidParse("test_data/quad_face.ply"); } TEST_F(PlyParserTest, RejectFaceWithZeroIndices) { @@ -542,7 +516,7 @@ end_header 0 )"; createTestFile("test_data/zero_face.ply", ply); - EXPECT_FALSE(parser.parse("test_data/zero_face.ply", out)); + expectInvalidParse("test_data/zero_face.ply"); } TEST_F(PlyParserTest, RejectFaceWithOneIndex) { @@ -559,7 +533,7 @@ end_header 1 0 )"; createTestFile("test_data/one_face.ply", ply); - EXPECT_FALSE(parser.parse("test_data/one_face.ply", out)); + expectInvalidParse("test_data/one_face.ply"); } TEST_F(PlyParserTest, RejectIncompleteVertexData) { @@ -576,5 +550,5 @@ end_header 1 0 )"; createTestFile("test_data/incomplete_vertex.ply", ply); - EXPECT_FALSE(parser.parse("test_data/incomplete_vertex.ply", out)); + expectInvalidParse("test_data/incomplete_vertex.ply"); } \ No newline at end of file diff --git a/tests/test_helpers.hpp b/tests/test_helpers.hpp index 5c940f0..a309485 100644 --- a/tests/test_helpers.hpp +++ b/tests/test_helpers.hpp @@ -46,6 +46,18 @@ class ImageParserTest : public ::testing::Test { class MeshParserTest : public ::testing::Test { protected: + void expectValidParse(const std::string& fileName, uint32_t numVertices, uint32_t numTriangles) { + EXPECT_TRUE(parser.parse(fileName, out)); + EXPECT_EQ(out.numVertices, numVertices); + EXPECT_EQ(out.numTriangles, numTriangles); + EXPECT_EQ(out.numIndices, numTriangles * 3); + EXPECT_EQ(out.indices.size(), out.numIndices); + } + + void expectInvalidParse(const std::string& filename) { + EXPECT_FALSE(parser.parse(filename, out)); + } + SSerializer::MeshParser parser; SSerializer::MeshData out; }; \ No newline at end of file