mirror of
https://github.com/Karaka-Management/cOMS.git
synced 2026-01-28 10:28:40 +00:00
setup tests
This commit is contained in:
parent
92cbe800c3
commit
c51b60152a
|
|
@ -1,8 +1,6 @@
|
|||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Image
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Image
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Image
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package App
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
|
|
@ -15,7 +13,7 @@
|
|||
#include "../../Image/Skew.h"
|
||||
#include "../../Image/Thresholding.h"
|
||||
|
||||
int main(int argc, char** argv )
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (argc != 3) {
|
||||
printf("A input image and a output image is required\n");
|
||||
|
|
|
|||
28
Utils/TestUtils.h
Normal file
28
Utils/TestUtils.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* Karaka
|
||||
*
|
||||
* @package Utils
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://karaka.app
|
||||
*/
|
||||
#ifndef UTILS_TEST_UTILS_H
|
||||
#define UTILS_TEST_UTILS_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#define ASSERT_EQUALS(a, b, t1, t2) \
|
||||
({ __typeof__ (a) _a = (a); \
|
||||
__typeof__ (b) _b = (b); \
|
||||
if (_a == _b) { printf("."); } else { printf("F"); printf("\n\n%s - %i: ", __FILE__, __LINE__); printf(t1, a); printf(" != "); printf(t2, b); return 0; } \
|
||||
})
|
||||
|
||||
#define ASSERT_EQUALS__DELTA(a, b, delta, t1, t2) \
|
||||
({ __typeof__ (a) _a = (a); \
|
||||
__typeof__ (b) _b = (b); \
|
||||
if (abs(_a - _b) <= delta) { printf("."); } else { printf("F"); printf("\n\n%s - %i: ", __FILE__, __LINE__); printf(t1, a); printf(" != "); printf(t2, b); printf("\n"); return 0; } \
|
||||
})
|
||||
|
||||
#endif
|
||||
33
tests/Image/ImageUtilsTest.cpp
Normal file
33
tests/Image/ImageUtilsTest.cpp
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* Karaka
|
||||
*
|
||||
* @package Test
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://karaka.app
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../../Utils/TestUtils.h"
|
||||
#include "../../Image/ImageUtils.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
printf("ImageUtils:\n\n");
|
||||
|
||||
printf("lightnessFromRgb:\n");
|
||||
|
||||
float white = Image::ImageUtils::lightnessFromRgb(255, 255, 255);
|
||||
ASSERT_EQUALS(white, 1.0, "%f", "%f");
|
||||
|
||||
float black = Image::ImageUtils::lightnessFromRgb(0, 0, 0);
|
||||
ASSERT_EQUALS(black, 0.0, "%f", "%f");
|
||||
|
||||
float other = Image::ImageUtils::lightnessFromRgb(125, 125, 125);
|
||||
ASSERT_EQUALS__DELTA(other, 0.524, 0.00001, "%f", "%f");
|
||||
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
3
tests/test.sh
Executable file
3
tests/test.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
g++ Image/ImageUtilsTest.cpp -o Image/ImageUtilsTest && ./Image/ImageUtilsTest && rm Image/ImageUtilsTest
|
||||
Loading…
Reference in New Issue
Block a user