// Pruebas del módulo convertido, solo por su interfaz. No compila hasta que Image exista y
// estén las funciones image_width, image_height, image_max_value, image_get e image_set.
#include <assert.h>
#include <stdio.h>

#include "filters.h"

static void test_new_get_set(void) {
    Image *img = image_new(3, 2, 255, 7);
    assert(img != NULL);
    assert(image_width(img) == 3);
    assert(image_height(img) == 2);
    assert(image_max_value(img) == 255);
    assert(image_get(img, 2, 1) == 7);

    image_set(img, 2, 0, 99);
    assert(image_get(img, 2, 0) == 99);
    assert(image_get(img, 0, 1) == 7);
    image_free(img);
    image_free(NULL);
}

static void test_flip_keeps_rows_apart(void) {
    Image *img = image_new(3, 2, 255, 0);
    assert(img != NULL);
    image_set(img, 0, 0, 1);
    image_set(img, 2, 1, 6);
    flip_horizontal(img);
    assert(image_get(img, 2, 0) == 1);
    assert(image_get(img, 0, 1) == 6);
    assert(image_get(img, 0, 0) == 0);
    image_free(img);
}

int main(void) {
    test_new_get_set();
    test_flip_keeps_rows_apart();

    printf("Todas las pruebas pasaron\n");
    return 0;
}
