class PostgresqlGeometricTest
Public Instance Methods
test_alternative_format()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/geometric_test.rb, line 204 def test_alternative_format g = PostgresqlGeometric.new( a_line_segment: "((2.0, 3), (5.5, 7.0))", a_box: "(2.0, 3), (5.5, 7.0)", a_path: "((2.0, 3), (5.5, 7.0), (8.5, 11.0))", a_polygon: "2.0, 3, 5.5, 7.0, 8.5, 11.0", a_circle: "((5.3, 10.4), 2)" ) g.save! h = PostgresqlGeometric.find(g.id) assert_equal "[(2,3),(5.5,7)]", h.a_line_segment assert_equal "(5.5,7),(2,3)", h.a_box # reordered to store upper right corner then bottom left corner assert_equal "((2,3),(5.5,7),(8.5,11))", h.a_path assert_equal "((2,3),(5.5,7),(8.5,11))", h.a_polygon assert_equal "<(5.3,10.4),2>", h.a_circle end
test_geometric_function()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/geometric_test.rb, line 223 def test_geometric_function PostgresqlGeometric.create! a_path: "[(2.0, 3), (5.5, 7.0), (8.5, 11.0)]" # [ ] is an open path PostgresqlGeometric.create! a_path: "((2.0, 3), (5.5, 7.0), (8.5, 11.0))" # ( ) is a closed path objs = PostgresqlGeometric.find_by_sql "SELECT isopen(a_path) FROM postgresql_geometrics ORDER BY id ASC" assert_equal [true, false], objs.map(&:isopen) objs = PostgresqlGeometric.find_by_sql "SELECT isclosed(a_path) FROM postgresql_geometrics ORDER BY id ASC" assert_equal [false, true], objs.map(&:isclosed) end
test_geometric_types()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/geometric_test.rb, line 184 def test_geometric_types g = PostgresqlGeometric.new( a_line_segment: "(2.0, 3), (5.5, 7.0)", a_box: "2.0, 3, 5.5, 7.0", a_path: "[(2.0, 3), (5.5, 7.0), (8.5, 11.0)]", a_polygon: "((2.0, 3), (5.5, 7.0), (8.5, 11.0))", a_circle: "<(5.3, 10.4), 2>" ) g.save! h = PostgresqlGeometric.find(g.id) assert_equal "[(2,3),(5.5,7)]", h.a_line_segment assert_equal "(5.5,7),(2,3)", h.a_box # reordered to store upper right corner then bottom left corner assert_equal "[(2,3),(5.5,7),(8.5,11)]", h.a_path assert_equal "((2,3),(5.5,7),(8.5,11))", h.a_polygon assert_equal "<(5.3,10.4),2>", h.a_circle end
test_schema_dumping()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/geometric_test.rb, line 234 def test_schema_dumping output = dump_table_schema("postgresql_geometrics") assert_match %r{t\.lseg\s+"a_line_segment"$}, output assert_match %r{t\.box\s+"a_box"$}, output assert_match %r{t\.path\s+"a_path"$}, output assert_match %r{t\.polygon\s+"a_polygon"$}, output assert_match %r{t\.circle\s+"a_circle"$}, output end