git repos / SagoImageBrowser

blame: test/test_exifreader.cpp

normal view · raw

35c3554c Poul Sander 2026-06-07 13:09 1
#include <QCoreApplication>
35c3554c Poul Sander 2026-06-07 13:09 2
#include <QDebug>
35c3554c Poul Sander 2026-06-07 13:09 3
#include <cassert>
35c3554c Poul Sander 2026-06-07 13:09 4
#include "exifreader.h"
35c3554c Poul Sander 2026-06-07 13:09 5
35c3554c Poul Sander 2026-06-07 13:09 6
int main(int argc, char *argv[]) {
35c3554c Poul Sander 2026-06-07 13:09 7
    QCoreApplication app(argc, argv);
35c3554c Poul Sander 2026-06-07 13:09 8
35c3554c Poul Sander 2026-06-07 13:09 9
    qDebug() << "Running ExifReader test...";
35c3554c Poul Sander 2026-06-07 13:09 10
35c3554c Poul Sander 2026-06-07 13:09 11
    // Test ExifData::isEmpty()
35c3554c Poul Sander 2026-06-07 13:09 12
    ExifData data;
35c3554c Poul Sander 2026-06-07 13:09 13
    assert(data.isEmpty());
35c3554c Poul Sander 2026-06-07 13:09 14
    qDebug() << "ExifData::isEmpty() passed for empty data.";
35c3554c Poul Sander 2026-06-07 13:09 15
35c3554c Poul Sander 2026-06-07 13:09 16
    data.filename = "test.jpg";
35c3554c Poul Sander 2026-06-07 13:09 17
    assert(!data.isEmpty());
35c3554c Poul Sander 2026-06-07 13:09 18
    qDebug() << "ExifData::isEmpty() passed for non-empty data.";
35c3554c Poul Sander 2026-06-07 13:09 19
35c3554c Poul Sander 2026-06-07 13:09 20
    // Test ExifData::toList()
35c3554c Poul Sander 2026-06-07 13:09 21
    data.fileSize = "1.2 MiB";
091a4f7d Poul Sander 2026-06-09 19:54 22
    data.orientation = "1 (top, left)";
091a4f7d Poul Sander 2026-06-09 19:54 23
    data.latitude = "55deg 40' 32.12\" N";
091a4f7d Poul Sander 2026-06-09 19:54 24
    data.longitude = "12deg 34' 11.23\" E";
091a4f7d Poul Sander 2026-06-09 19:54 25
    data.osmLink = "https://www.openstreetmap.org/?mlat=55.675589&mlon=12.569786#map=16/55.675589/12.569786";
35c3554c Poul Sander 2026-06-07 13:09 26
    auto list = data.toList();
35c3554c Poul Sander 2026-06-07 13:09 27
    bool foundFilename = false;
35c3554c Poul Sander 2026-06-07 13:09 28
    bool foundSize = false;
091a4f7d Poul Sander 2026-06-09 19:54 29
    bool foundOrientation = false;
091a4f7d Poul Sander 2026-06-09 19:54 30
    bool foundLat = false;
091a4f7d Poul Sander 2026-06-09 19:54 31
    bool foundLon = false;
091a4f7d Poul Sander 2026-06-09 19:54 32
    bool foundOsm = false;
35c3554c Poul Sander 2026-06-07 13:09 33
    for (const auto &pair : list) {
35c3554c Poul Sander 2026-06-07 13:09 34
        if (pair.first == "Filename" && pair.second == "test.jpg") foundFilename = true;
35c3554c Poul Sander 2026-06-07 13:09 35
        if (pair.first == "File Size" && pair.second == "1.2 MiB") foundSize = true;
091a4f7d Poul Sander 2026-06-09 19:54 36
        if (pair.first == "Orientation" && pair.second == "1 (top, left)") foundOrientation = true;
091a4f7d Poul Sander 2026-06-09 19:54 37
        if (pair.first == "Latitude" && pair.second == "55deg 40' 32.12\" N") foundLat = true;
091a4f7d Poul Sander 2026-06-09 19:54 38
        if (pair.first == "Longitude" && pair.second == "12deg 34' 11.23\" E") foundLon = true;
091a4f7d Poul Sander 2026-06-09 19:54 39
        if (pair.first == "OpenStreetMap" && pair.second == "https://www.openstreetmap.org/?mlat=55.675589&mlon=12.569786#map=16/55.675589/12.569786") foundOsm = true;
35c3554c Poul Sander 2026-06-07 13:09 40
    }
35c3554c Poul Sander 2026-06-07 13:09 41
    assert(foundFilename);
35c3554c Poul Sander 2026-06-07 13:09 42
    assert(foundSize);
091a4f7d Poul Sander 2026-06-09 19:54 43
    assert(foundOrientation);
091a4f7d Poul Sander 2026-06-09 19:54 44
    assert(foundLat);
091a4f7d Poul Sander 2026-06-09 19:54 45
    assert(foundLon);
091a4f7d Poul Sander 2026-06-09 19:54 46
    assert(foundOsm);
35c3554c Poul Sander 2026-06-07 13:09 47
    qDebug() << "ExifData::toList() passed.";
35c3554c Poul Sander 2026-06-07 13:09 48
35c3554c Poul Sander 2026-06-07 13:09 49
    qDebug() << "All ExifReader tests passed!";
35c3554c Poul Sander 2026-06-07 13:09 50
    return 0;
35c3554c Poul Sander 2026-06-07 13:09 51
}
1970-01-01 00:00 52