Skip to content

Commit

Permalink
fix psych related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BuonOmo committed Aug 10, 2021
1 parent 436b671 commit ca1d7d0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion test/common/factory_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_marshal_dump_load_factory

def test_psych_dump_load_factory
data = Psych.dump(@factory)
factory2 = Psych.load(data)
factory2 = psych_load(data)
assert_equal(@factory, factory2)
assert_equal(srid, factory2.srid)
end
Expand Down
2 changes: 1 addition & 1 deletion test/common/line_string_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def test_psych_roundtrip
point2 = @factory.point(0, 1)
line1 = @factory.line_string([point1, point2])
data = Psych.dump(line1)
line2 = Psych.load(data)
line2 = psych_load(data)
assert_equal(line1, line2)
end

Expand Down
6 changes: 3 additions & 3 deletions test/common/point_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,21 +341,21 @@ def test_coordinates_4d
def test_psych_roundtrip
point = @factory.point(11, 12)
data = Psych.dump(point)
point2 = Psych.load(data)
point2 = psych_load(data)
assert_equal(point, point2)
end

def test_psych_roundtrip_3d
point = @zfactory.point(11, 12, 13)
data = Psych.dump(point)
point2 = Psych.load(data)
point2 = psych_load(data)
assert_equal(point, point2)
end

def test_psych_roundtrip_4d
point = @zmfactory.point(11, 12, 13, 14)
data = Psych.dump(point)
point2 = Psych.load(data)
point2 = psych_load(data)
assert_equal(point, point2)
end

Expand Down
2 changes: 1 addition & 1 deletion test/coord_sys/ogc_cs_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def test_yaml_roundtrip
input = 'COMPD_CS["OSGB36 / British National Grid + ODN",PROJCS["OSGB 1936 / British National Grid",GEOGCS["OSGB 1936",DATUM["OSGB 1936",SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]],TOWGS84[446.448,-125.157,542.06,0.15,0.247,0.842,-4.2261596151967575],AUTHORITY["EPSG","6277"]],PRIMEM["Greenwich",0.0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943295],AXIS["Geodetic latitude",NORTH],AXIS["Geodetic longitude",EAST],AUTHORITY["EPSG","4277"]],PROJECTION["Transverse Mercator",AUTHORITY["EPSG","9807"]],PARAMETER["central_meridian",-2.0],PARAMETER["latitude_of_origin",49.0],PARAMETER["scale_factor",0.9996012717],PARAMETER["false_easting",400000.0],PARAMETER["false_northing",-100000.0],UNIT["m",1.0],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","27700"]],VERT_CS["Newlyn",VERT_DATUM["Ordnance Datum Newlyn",2005,AUTHORITY["EPSG","5101"]],UNIT["m",1.0],AXIS["Gravity-related height",UP],AUTHORITY["EPSG","5701"]],AUTHORITY["EPSG","7405"]]'
obj1 = RGeo::CoordSys::CS.create_from_wkt(input)
dump = Psych.dump(obj1)
obj2 = Psych.load(dump)
obj2 = psych_load(dump)
assert_equal(obj1, obj2)
end
end
11 changes: 11 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
require "minitest/autorun"
require_relative "../lib/rgeo"
require "psych"

# Only here for Psych 4.0.0 breaking change.
# See https://github.com/ruby/psych/pull/487
def psych_load(*args)
if Psych.respond_to?(:unsafe_load)
Psych.unsafe_load(*args)
else
Psych.load(*args)
end
end

require_relative "common/factory_tests"
require_relative "common/geometry_collection_tests"
require_relative "common/line_string_tests"
Expand Down

0 comments on commit ca1d7d0

Please sign in to comment.