test: Merge common stuff

This commit is contained in:
Kim Woelders 2022-02-06 12:34:47 +01:00
parent abc16b8c2c
commit 79a5086b58
12 changed files with 59 additions and 247 deletions

View File

@ -32,29 +32,29 @@ CLEANFILES = file.c img_save-*.*
%.c: $(top_srcdir)/src/lib/%.c
ln -s $< $@
test_file_SOURCES = test_file.cpp
test_file_SOURCES = test.cpp test_file.cpp
nodist_test_file_SOURCES = file.c
test_file_LDADD = $(LIBS)
test_context_SOURCES = test_context.cpp
test_context_SOURCES = test.cpp test_context.cpp
test_context_LDADD = $(LIBS)
test_load_SOURCES = test_load.cpp
test_load_SOURCES = test.cpp test_load.cpp
test_load_LDADD = $(LIBS)
test_load_2_SOURCES = test_load_2.cpp
test_load_2_SOURCES = test.cpp test_load_2.cpp
test_load_2_LDADD = $(LIBS) -lz
test_save_SOURCES = test_save.cpp
test_save_SOURCES = test.cpp test_save.cpp
test_save_LDADD = $(LIBS)
test_grab_SOURCES = test_grab.cpp
test_grab_SOURCES = test.cpp test_grab.cpp
test_grab_LDADD = $(LIBS)
test_scale_SOURCES = test_scale.cpp
test_scale_SOURCES = test.cpp test_scale.cpp
test_scale_LDADD = $(LIBS) -lz
test_rotate_SOURCES = test_rotate.cpp
test_rotate_SOURCES = test.cpp test_rotate.cpp
test_rotate_LDADD = $(LIBS) -lz
TESTS_RUN = $(addprefix run-, $(GTESTS))

31
test/test.cpp Normal file
View File

@ -0,0 +1,31 @@
#include <gtest/gtest.h>
#include "test.h"
int debug = 0;
int
main(int argc, char **argv)
{
const char *s;
::testing::InitGoogleTest(&argc, argv);
for (argc--, argv++; argc > 0; argc--, argv++)
{
s = argv[0];
if (*s++ != '-')
break;
switch (*s)
{
case 'd':
debug++;
break;
}
}
// Required by some tests
mkdir(IMG_GEN, 0755);
return RUN_ALL_TESTS();
}

12
test/test.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef TEST_H
#define TEST_H 1
#define IMG_SRC SRC_DIR "/images"
#define IMG_GEN BLD_DIR "/generated"
#define D(...) if (debug) printf(__VA_ARGS__)
#define D2(...) if (debug > 1) printf(__VA_ARGS__)
extern int debug;
#endif /* TEST_H */

View File

@ -1,3 +0,0 @@
#define IMG_SRC SRC_DIR "/images"
#define IMG_GEN BLD_DIR "/generated"

View File

@ -3,23 +3,12 @@
#include <stddef.h>
#include <Imlib2.h>
#include "test.h"
#define NULC ((Imlib_Context*)0)
#define HAVE_INITIAL_CTX 1
int debug = 0;
#define D(...) if (debug) printf(__VA_ARGS__)
#define D2(...) if (debug > 1) printf(__VA_ARGS__)
#if 0
EAPI Imlib_Context imlib_context_new(void);
EAPI void imlib_context_free(Imlib_Context context);
EAPI void imlib_context_push(Imlib_Context context);
EAPI void imlib_context_pop(void);
EAPI Imlib_Context imlib_context_get(void);
#endif
TEST(CTX, ctx)
{
Imlib_Context ctx, ctx0, ctx1;
@ -119,26 +108,3 @@ TEST(CTX, ctx)
D("%d: ctx = %p\n", __LINE__, ctx);
EXPECT_EQ(ctx, ctx0); // Ctx still default
}
int
main(int argc, char **argv)
{
const char *s;
::testing::InitGoogleTest(&argc, argv);
for (argc--, argv++; argc > 0; argc--, argv++)
{
s = argv[0];
if (*s++ != '-')
break;
switch (*s)
{
case 'd':
debug++;
break;
}
}
return RUN_ALL_TESTS();
}

View File

@ -6,31 +6,18 @@ extern "C" {
}
/**INDENT-ON**/
#if 0
#define D(...) printf(__VA_ARGS__)
#else
#define D(...)
#endif
#define EXPECT_OK(x) EXPECT_FALSE(x)
#define EXPECT_ERR(x) EXPECT_TRUE(x)
#if 0
char *__imlib_FileRealFile(const char *file);
char *__imlib_FileExtension(const char *file);
//int __imlib_FileExists(const char *s);
//int __imlib_FileIsFile(const char *s);
//int __imlib_FileIsDir(const char *s);
char **__imlib_FileDir(const char *dir, int *num);
void __imlib_FileFreeDirList(char **l, int num);
void __imlib_FileDel(const char *s);
time_t __imlib_FileModDate(const char *s);
char *__imlib_FileHomeDir(int uid);
int __imlib_FilePermissions(const char *s);
//int __imlib_FileCanRead(const char *s);
int __imlib_IsRealFile(const char *s);
#endif
#define USE_REAL_FILE 0
@ -248,10 +235,3 @@ TEST(FILE, file_key)
EXPECT_FALSE(key);
free(key);
}
int
main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -4,7 +4,7 @@
#include <Imlib2.h>
#include "config.h"
#include "test_common.h"
#include "test.h"
typedef struct {
Display *dpy;
@ -19,10 +19,6 @@ typedef struct {
} xd_t;
static xd_t xd;
int debug = 0;
#define D(...) if (debug) printf(__VA_ARGS__)
#define D2(...) if (debug > 1) printf(__VA_ARGS__)
static Visual *
_x11_vis_argb(void)
@ -323,29 +319,3 @@ TEST(GRAB, grab_offs_32_sd2)
{
_test_grab("grab_offs_32_sd2", 32, -2, 1);
}
int
main(int argc, char **argv)
{
const char *s;
::testing::InitGoogleTest(&argc, argv);
for (argc--, argv++; argc > 0; argc--, argv++)
{
s = argv[0];
if (*s++ != '-')
break;
switch (*s)
{
case 'd':
while (*s++ == 'd')
debug++;
break;
}
}
mkdir(IMG_GEN, 0755);
return RUN_ALL_TESTS();
}

View File

@ -4,12 +4,7 @@
#include <fcntl.h>
#include "config.h"
#include "test_common.h"
int debug = 0;
#define D(...) if (debug) printf(__VA_ARGS__)
#define D2(...) if (debug > 1) printf(__VA_ARGS__)
#include "test.h"
#define EXPECT_OK(x) EXPECT_FALSE(x)
#define EXPECT_ERR(x) EXPECT_TRUE(x)
@ -169,28 +164,3 @@ TEST(LOAD, load_2)
imlib_context_set_progress_granularity(10);
test_load();
}
int
main(int argc, char **argv)
{
const char *s;
::testing::InitGoogleTest(&argc, argv);
for (argc--, argv++; argc > 0; argc--, argv++)
{
s = argv[0];
if (*s++ != '-')
break;
switch (*s)
{
case 'd':
debug++;
break;
}
}
mkdir(IMG_GEN, 0755);
return RUN_ALL_TESTS();
}

View File

@ -5,11 +5,7 @@
#include <zlib.h>
#include "config.h"
#include "test_common.h"
int debug = 0;
#define D(...) if (debug) printf(__VA_ARGS__)
#include "test.h"
#define EXPECT_OK(x) EXPECT_FALSE(x)
#define EXPECT_ERR(x) EXPECT_TRUE(x)
@ -89,26 +85,3 @@ TEST(LOAD2, load_1)
EXPECT_EQ(crc, tii[i].crc);
}
}
int
main(int argc, char **argv)
{
const char *s;
::testing::InitGoogleTest(&argc, argv);
for (argc--, argv++; argc > 0; argc--, argv++)
{
s = argv[0];
if (*s++ != '-')
break;
switch (*s)
{
case 'd':
debug++;
break;
}
}
return RUN_ALL_TESTS();
}

View File

@ -4,11 +4,7 @@
#include <zlib.h>
#include "config.h"
#include "test_common.h"
int debug = 0;
#define D(...) if (debug) printf(__VA_ARGS__)
#include "test.h"
#define FILE_REF1 "icon-64" // RGB
#define FILE_REF2 "xeyes" // ARGB (shaped)
@ -131,28 +127,3 @@ TEST(ROTAT, rotate_2_noaa)
{
test_rotate(1, 0);
}
int
main(int argc, char **argv)
{
const char *s;
::testing::InitGoogleTest(&argc, argv);
for (argc--, argv++; argc > 0; argc--, argv++)
{
s = argv[0];
if (*s++ != '-')
break;
switch (*s)
{
case 'd':
debug++;
break;
}
}
mkdir(IMG_GEN, 0755);
return RUN_ALL_TESTS();
}

View File

@ -3,11 +3,7 @@
#include <Imlib2.h>
#include "config.h"
#include "test_common.h"
int debug = 0;
#define D(...) if (debug) printf(__VA_ARGS__)
#include "test.h"
#define EXPECT_OK(x) EXPECT_FALSE(x)
#define EXPECT_ERR(x) EXPECT_TRUE(x)
@ -164,28 +160,3 @@ TEST(SAVE, save_2_argb)
{
test_save(FILE_REF2, 1);
}
int
main(int argc, char **argv)
{
const char *s;
::testing::InitGoogleTest(&argc, argv);
for (argc--, argv++; argc > 0; argc--, argv++)
{
s = argv[0];
if (*s++ != '-')
break;
switch (*s)
{
case 'd':
debug++;
break;
}
}
mkdir(IMG_GEN, 0755);
return RUN_ALL_TESTS();
}

View File

@ -4,11 +4,7 @@
#include <zlib.h>
#include "config.h"
#include "test_common.h"
int debug = 0;
#define D(...) if (debug) printf(__VA_ARGS__)
#include "test.h"
#define FILE_REF1 "icon-64" // RGB
#define FILE_REF2 "xeyes" // ARGB (shaped)
@ -102,28 +98,3 @@ TEST(SCALE, scale_1_argb)
{
test_scale(1);
}
int
main(int argc, char **argv)
{
const char *s;
::testing::InitGoogleTest(&argc, argv);
for (argc--, argv++; argc > 0; argc--, argv++)
{
s = argv[0];
if (*s++ != '-')
break;
switch (*s)
{
case 'd':
debug++;
break;
}
}
mkdir(IMG_GEN, 0755);
return RUN_ALL_TESTS();
}