Skip to content

Commit

Permalink
Fix tests usage of to_s for Ruby 3.4 and later
Browse files Browse the repository at this point in the history
Aparently Hash#to_s formatting changed with Ruby 3.4 so we need to track
that now.
  • Loading branch information
jasonroelofs committed Jan 28, 2025
1 parent ff0bc94 commit b99f9bb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/test_Stl_Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "embed_ruby.hpp"
#include <rice/rice.hpp>
#include <rice/stl.hpp>
#include <ruby/version.h>

using namespace Rice;

Expand Down Expand Up @@ -257,7 +258,11 @@ TESTCASE(Iterate)
ASSERT_EQUAL(3u, result.size());

std::string result_string = result.to_s().str();
#if RUBY_API_VERSION_MAJOR == 3 && RUBY_API_VERSION_MINOR >= 4
ASSERT_EQUAL("{\"five\" => 10, \"seven\" => 14, \"six\" => 12}", result_string);
#else
ASSERT_EQUAL("{\"five\"=>10, \"seven\"=>14, \"six\"=>12}", result_string);
#endif
}

TESTCASE(ToEnum)
Expand All @@ -280,7 +285,12 @@ TESTCASE(ToEnum)
ASSERT_EQUAL(3u, result.size());

std::string result_string = result.to_s().str();

#if RUBY_API_VERSION_MAJOR == 3 && RUBY_API_VERSION_MINOR >= 4
ASSERT_EQUAL("{\"five\" => 10, \"seven\" => 14, \"six\" => 12}", result_string);
#else
ASSERT_EQUAL("{\"five\"=>10, \"seven\"=>14, \"six\"=>12}", result_string);
#endif
}

TESTCASE(ToEnumSize)
Expand Down

0 comments on commit b99f9bb

Please sign in to comment.