@@ -374,12 +374,12 @@ func TestScanPoint_errors(t *testing.T) {
374374 }
375375}
376376
377- func TestPrefixScannerPrefixSRID (t * testing.T ) {
377+ func TestScannerPrefixSRID (t * testing.T ) {
378378 cases := []struct {
379379 name string
380380 data []byte
381381 srid int
382- expected orb.Point
382+ expected orb.Geometry
383383 }{
384384 {
385385 name : "point" ,
@@ -391,16 +391,15 @@ func TestPrefixScannerPrefixSRID(t *testing.T) {
391391
392392 for _ , tc := range cases {
393393 t .Run (tc .name , func (t * testing.T ) {
394- var p orb.Point
395- s := ScannerPrefixSRID (& p )
394+ s := ScannerPrefixSRID (nil )
396395 err := s .Scan (tc .data )
397396 if err != nil {
398397 t .Fatalf ("scan error: %v" , err )
399398 }
400399
401- if ! p .Equal (tc .expected ) {
400+ if ! orb .Equal (s . Geometry , tc .expected ) {
402401 t .Errorf ("unequal data" )
403- t .Log (p )
402+ t .Log (s . Geometry )
404403 t .Log (tc .expected )
405404 }
406405
@@ -411,6 +410,38 @@ func TestPrefixScannerPrefixSRID(t *testing.T) {
411410 }
412411}
413412
413+ func TestValuePrefixSRID (t * testing.T ) {
414+ cases := []struct {
415+ name string
416+ geom orb.Geometry
417+ srid int
418+ expected []byte
419+ }{
420+ {
421+ name : "point" ,
422+ geom : orb.Point {4 , 5 },
423+ srid : 4326 ,
424+ expected : append ([]byte {230 , 16 , 0 , 0 }, MustMarshal (orb.Point {4 , 5 }, 0 )... ),
425+ },
426+ }
427+
428+ for _ , tc := range cases {
429+ t .Run (tc .name , func (t * testing.T ) {
430+ v := ValuePrefixSRID (tc .geom , tc .srid )
431+ data , err := v .Value ()
432+ if err != nil {
433+ t .Fatalf ("value error: %v" , err )
434+ }
435+
436+ if ! bytes .Equal (data .([]byte ), tc .expected ) {
437+ t .Errorf ("unequal data" )
438+ t .Log (data )
439+ t .Log (tc .expected )
440+ }
441+ })
442+ }
443+ }
444+
414445func TestScanMultiPoint (t * testing.T ) {
415446 cases := []struct {
416447 name string
0 commit comments