...
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 TestTagExifA300FileSource_String(t *testing.T) {
14 ut := TagExifA300FileSource(0x1234)
15
16 s := ut.String()
17 if s != "0x00001234" {
18 t.Fatalf("String not correct: [%s]", s)
19 }
20 }
21
22 func TestCodecExifA300FileSource_Encode(t *testing.T) {
23 ut := TagExifA300FileSource(0x1234)
24
25 codec := CodecExifA300FileSource{}
26
27 encoded, unitCount, err := codec.Encode(ut, exifcommon.TestDefaultByteOrder)
28 log.PanicIf(err)
29
30 expectedEncoded := []byte{0, 0, 0x12, 0x34}
31
32 if bytes.Equal(encoded, expectedEncoded) != true {
33 exifcommon.DumpBytesClause(encoded)
34
35 t.Fatalf("Encoding not correct.")
36 } else if unitCount != 1 {
37 t.Fatalf("Unit-count not correct: (%d)", unitCount)
38 }
39 }
40
41 func TestCodecExifA300FileSource_Decode(t *testing.T) {
42 expectedUt := TagExifA300FileSource(0x1234)
43
44 encoded := []byte{0, 0, 0x12, 0x34}
45
46 rawValueOffset := encoded
47
48 valueContext := exifcommon.NewValueContext(
49 "",
50 0,
51 1,
52 0,
53 rawValueOffset,
54 nil,
55 exifcommon.TypeUndefined,
56 exifcommon.TestDefaultByteOrder)
57
58 codec := CodecExifA300FileSource{}
59
60 decoded, err := codec.Decode(valueContext)
61 log.PanicIf(err)
62
63 if reflect.DeepEqual(decoded, expectedUt) != true {
64 t.Fatalf("Decoded struct not correct.")
65 }
66 }
67
View as plain text