Skip to content

Commit

Permalink
Merge pull request #36132 from jbytheway/variant_stringmaker
Browse files Browse the repository at this point in the history
StringMaker specialization for cata_variant
  • Loading branch information
ZhilkinSerg authored Dec 16, 2019
2 parents 00fc642 + 25be731 commit ef1f0a6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/cata_variant_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "cata_variant.h"
#include "json.h"
#include "stringmaker.h"

TEST_CASE( "variant_construction", "[variant]" )
{
Expand Down
1 change: 1 addition & 0 deletions tests/stats_tracker_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "event_statistics.h"
#include "game.h"
#include "stats_tracker.h"
#include "stringmaker.h"

TEST_CASE( "stats_tracker_count_events", "[stats]" )
{
Expand Down
9 changes: 9 additions & 0 deletions tests/stringmaker.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define CATA_TESTS_STRINGMAKER_H

#include "catch/catch.hpp"
#include "cata_variant.h"
#include "item.h"

// StringMaker specializations for Cata types for reporting via Catch2 macros
Expand Down Expand Up @@ -31,6 +32,14 @@ struct StringMaker<box> {
}
};

template<>
struct StringMaker<cata_variant> {
static std::string convert( const cata_variant &v ) {
return string_format( "cata_variant<%s>(\"%s\")",
io::enum_to_string( v.type() ), v.get_string() );
}
};

} // namespace Catch

#endif // CATA_TESTS_STRINGMAKER_H

0 comments on commit ef1f0a6

Please sign in to comment.