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";
35c3554c Poul Sander 2026-06-07 13:09 22
    auto list = data.toList();
35c3554c Poul Sander 2026-06-07 13:09 23
    bool foundFilename = false;
35c3554c Poul Sander 2026-06-07 13:09 24
    bool foundSize = false;
35c3554c Poul Sander 2026-06-07 13:09 25
    for (const auto &pair : list) {
35c3554c Poul Sander 2026-06-07 13:09 26
        if (pair.first == "Filename" && pair.second == "test.jpg") foundFilename = true;
35c3554c Poul Sander 2026-06-07 13:09 27
        if (pair.first == "File Size" && pair.second == "1.2 MiB") foundSize = true;
35c3554c Poul Sander 2026-06-07 13:09 28
    }
35c3554c Poul Sander 2026-06-07 13:09 29
    assert(foundFilename);
35c3554c Poul Sander 2026-06-07 13:09 30
    assert(foundSize);
35c3554c Poul Sander 2026-06-07 13:09 31
    qDebug() << "ExifData::toList() passed.";
35c3554c Poul Sander 2026-06-07 13:09 32
35c3554c Poul Sander 2026-06-07 13:09 33
    qDebug() << "All ExifReader tests passed!";
35c3554c Poul Sander 2026-06-07 13:09 34
    return 0;
35c3554c Poul Sander 2026-06-07 13:09 35
}
1970-01-01 00:00 36