...

Source file src/github.com/dsoprea/go-exif/v3/undefined/gps_001B_gps_processing_method_test.go

Documentation: github.com/dsoprea/go-exif/v3/undefined

     1  package exifundefined
     2  
     3  import (
     4  	"bytes"
     5  	"reflect"
     6  	"testing"
     7  
     8  	"github.com/dsoprea/go-logging"
     9  
    10  	"github.com/dsoprea/go-exif/v3/common"
    11  )
    12  
    13  func TestTag001BGPSProcessingMethod_String(t *testing.T) {
    14  	ut := Tag001BGPSProcessingMethod{"abc"}
    15  	s := ut.String()
    16  
    17  	if s != "abc" {
    18  		t.Fatalf("String not correct: [%s]", s)
    19  	}
    20  }
    21  
    22  func TestCodec001BGPSProcessingMethod_Encode(t *testing.T) {
    23  	s := "abc"
    24  	ut := Tag001BGPSProcessingMethod{s}
    25  
    26  	codec := Codec001BGPSProcessingMethod{}
    27  
    28  	encoded, unitCount, err := codec.Encode(ut, exifcommon.TestDefaultByteOrder)
    29  	log.PanicIf(err)
    30  
    31  	if bytes.Equal(encoded, []byte(s)) != true {
    32  		t.Fatalf("Encoded bytes not correct: %v", encoded)
    33  	} else if unitCount != uint32(len(s)) {
    34  		t.Fatalf("Unit-count not correct: (%d)", unitCount)
    35  	}
    36  }
    37  
    38  func TestCodec001BGPSProcessingMethod_Decode(t *testing.T) {
    39  	s := "abc"
    40  	ut := Tag001BGPSProcessingMethod{s}
    41  
    42  	encoded := []byte(s)
    43  
    44  	rawValueOffset := encoded
    45  
    46  	valueContext := exifcommon.NewValueContext(
    47  		"",
    48  		0,
    49  		uint32(len(encoded)),
    50  		0,
    51  		rawValueOffset,
    52  		nil,
    53  		exifcommon.TypeUndefined,
    54  		exifcommon.TestDefaultByteOrder)
    55  
    56  	codec := Codec001BGPSProcessingMethod{}
    57  
    58  	value, err := codec.Decode(valueContext)
    59  	log.PanicIf(err)
    60  
    61  	if reflect.DeepEqual(value, ut) != true {
    62  		t.Fatalf("Decoded value not correct: %s\n", value)
    63  	}
    64  }
    65  

View as plain text