...
1 package exif
2
3 import (
4 "os"
5 "testing"
6
7 "github.com/dsoprea/go-logging/v2"
8 "github.com/dsoprea/go-utility/v2/filesystem"
9 )
10
11 func TestGpsDegreesEquals_Equals(t *testing.T) {
12 gi := GpsDegrees{
13 Orientation: 'A',
14 Degrees: 11.0,
15 Minutes: 22.0,
16 Seconds: 33.0,
17 }
18
19 r := GpsDegreesEquals(gi, gi)
20 if r != true {
21 t.Fatalf("GpsDegrees structs were not equal as expected.")
22 }
23 }
24
25 func TestGpsDegreesEquals_NotEqual_Orientation(t *testing.T) {
26 gi1 := GpsDegrees{
27 Orientation: 'A',
28 Degrees: 11.0,
29 Minutes: 22.0,
30 Seconds: 33.0,
31 }
32
33 gi2 := gi1
34 gi2.Orientation = 'B'
35
36 r := GpsDegreesEquals(gi1, gi2)
37 if r != false {
38 t.Fatalf("GpsDegrees structs were equal but not supposed to be.")
39 }
40 }
41
42 func TestGpsDegreesEquals_NotEqual_Position(t *testing.T) {
43 gi1 := GpsDegrees{
44 Orientation: 'A',
45 Degrees: 11.0,
46 Minutes: 22.0,
47 Seconds: 33.0,
48 }
49
50 gi2 := gi1
51 gi2.Minutes = 22.5
52
53 r := GpsDegreesEquals(gi1, gi2)
54 if r != false {
55 t.Fatalf("GpsDegrees structs were equal but not supposed to be.")
56 }
57 }
58
59 func TestGetFlatExifData(t *testing.T) {
60 testExifData := getTestExifData()
61
62 exifTags, _, err := GetFlatExifData(testExifData, nil)
63 log.PanicIf(err)
64
65 if len(exifTags) != 59 {
66 t.Fatalf("Tag count not correct: (%d)", len(exifTags))
67 }
68 }
69
70 func TestGetFlatExifDataUniversalSearch(t *testing.T) {
71 testExifData := getTestExifData()
72
73 exifTags, _, err := GetFlatExifDataUniversalSearch(testExifData, nil, false)
74 log.PanicIf(err)
75
76 if len(exifTags) != 59 {
77 t.Fatalf("Tag count not correct: (%d)", len(exifTags))
78 }
79 }
80
81 func TestGetFlatExifDataUniversalSearchWithReadSeeker(t *testing.T) {
82 testImageFilepath := getTestImageFilepath()
83
84 f, err := os.Open(testImageFilepath)
85 log.PanicIf(err)
86
87 defer f.Close()
88
89 rawExif, err := SearchAndExtractExifWithReader(f)
90 log.PanicIf(err)
91
92 sb := rifs.NewSeekableBufferWithBytes(rawExif)
93
94 exifTags, _, err := GetFlatExifDataUniversalSearchWithReadSeeker(sb, nil, false)
95 log.PanicIf(err)
96
97 if len(exifTags) != 59 {
98 t.Fatalf("Tag count not correct: (%d)", len(exifTags))
99 }
100 }
101
View as plain text