...
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 TestTag0002InteropVersion_String(t *testing.T) {
14 ut := Tag0002InteropVersion{"abc"}
15 s := ut.String()
16
17 if s != "abc" {
18 t.Fatalf("String not correct: [%s]", s)
19 }
20 }
21
22 func TestCodec0002InteropVersion_Encode(t *testing.T) {
23 s := "abc"
24 ut := Tag0002InteropVersion{s}
25
26 codec := Codec0002InteropVersion{}
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 TestCodec0002InteropVersion_Decode(t *testing.T) {
39 s := "abc"
40 ut := Tag0002InteropVersion{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 := Codec0002InteropVersion{}
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