Skip to content

Commit

Permalink
Remove TMJ emitter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-johansson committed Oct 21, 2024
1 parent f8d1efd commit 64825dd
Show file tree
Hide file tree
Showing 13 changed files with 10 additions and 1,482 deletions.
21 changes: 0 additions & 21 deletions source/core/lib/src/util/string_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@ template <typename T, std::invocable<const char*, const char*, T&> Parser>
return std::unexpected {ErrorCode::kBadParam};
}

template <std::integral T>
[[nodiscard]] auto _parse_number(const std::string_view str, const int base)
-> std::expected<T, ErrorCode>
{
return _parse_impl<T>(str, [base](const char* begin, const char* end, T& number) {
return std::from_chars(begin, end, number, base);
});
}

template <std::floating_point T>
[[nodiscard]] auto _parse_number(const std::string_view str) -> std::expected<T, ErrorCode>
{
Expand Down Expand Up @@ -137,18 +128,6 @@ auto from_native_string(const NativeStringView str) -> std::expected<std::string
#endif // TACTILE_OS_WINDOWS
}

auto parse_int(const std::string_view str, const int base)
-> std::expected<std::int64_t, ErrorCode>
{
return _parse_number<std::int64_t>(str, base);
}

auto parse_uint(const std::string_view str, const int base)
-> std::expected<std::uint64_t, ErrorCode>
{
return _parse_number<std::uint64_t>(str, base);
}

auto parse_float(const std::string_view str) -> std::expected<double, ErrorCode>
{
return _parse_number<double>(str);
Expand Down
13 changes: 8 additions & 5 deletions source/plugins/tiled_tmj/lib/src/tmj_format_tileset_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,20 @@ auto _parse_tile(const nlohmann::json& tile_json) -> std::expected<ir::Tile, Err
auto _parse_tileset(const nlohmann::json& tileset_json)
-> std::expected<ir::Tileset, ErrorCode>
{
if (!tileset_json.contains("name")) {
runtime::log(LogLevel::kError, "Could not parse tileset name");
return std::unexpected {ErrorCode::kParseError};
}

ir::Tileset tileset {};

if (auto metadata = parse_tiled_tmj_metadata(tileset_json)) {
tileset.meta = std::move(*metadata);
}

if (const auto name_iter = tileset_json.find("name"); name_iter != tileset_json.end()) {
name_iter->get_to(tileset.meta.name);
}
else {
runtime::log(LogLevel::kError, "Could not parse tileset name");
return std::unexpected {ErrorCode::kParseError};
}

if (const auto tile_width_iter = tileset_json.find("tilewidth");
tile_width_iter != tileset_json.end()) {
tile_width_iter->get_to(tileset.tile_size[0]);
Expand Down
7 changes: 0 additions & 7 deletions source/plugins/tiled_tmj/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,9 @@ target_sources(tactile-tiled-tmj-format-test
PRIVATE
"src/main.cpp"
"src/tmj_format_attribute_parser_test.cpp"
"src/tmj_format_layer_emitter_test.cpp"
"src/tmj_format_layer_parser_test.cpp"
"src/tmj_format_map_parser_test.cpp"
"src/tmj_format_map_emitter_test.cpp"
"src/tmj_format_meta_emitter_test.cpp"
"src/tmj_format_object_emitter_test.cpp"
"src/tmj_format_object_parser_test.cpp"
"src/tmj_format_roundtrip_test.cpp"
"src/tmj_format_tile_emitter_test.cpp"
"src/tmj_format_tileset_emitter_test.cpp"
"src/tmj_format_tileset_parser_test.cpp"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,22 +327,4 @@ TEST_F(TmjFormatAttributeParserTest, ParseTiledTmjMetadata)
Contains(Eq(ir::NamedAttribute {"an_object", Attribute {ObjectRef {123}}})));
}

// tactile::parse_tiled_tmj_metadata
TEST_F(TmjFormatAttributeParserTest, ParseTiledTmjMetadataWithName)
{
using namespace nlohmann::json_literals;

const auto metadata_json = R"({
"name": "test",
"properties": []
})"_json;

const auto metadata = parse_tiled_tmj_metadata(metadata_json);
ASSERT_TRUE(metadata.has_value());

EXPECT_EQ(metadata->name, "test");
EXPECT_EQ(metadata->properties.size(), 0);
EXPECT_EQ(metadata->components.size(), 0);
}

} // namespace tactile::test
Loading

0 comments on commit 64825dd

Please sign in to comment.