Skip to content

Commit

Permalink
meson: add unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <rosenp@gmail.com>
  • Loading branch information
neheb committed Feb 7, 2023
1 parent 87fd467 commit 22b59ed
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,5 @@ executable(
dependencies: exiv2_dep,
install: true,
)

subdir('unitTests')
4 changes: 4 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ option('video', type : 'boolean',
option('xmp', type : 'feature',
description : 'Build support for XMP',
)

option('unitTests', type : 'feature',
description : 'Build and run unit tests',
)
15 changes: 15 additions & 0 deletions subprojects/gtest.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[wrap-file]
directory = googletest-release-1.12.1
source_url = https://github.com/google/googletest/archive/release-1.12.1.tar.gz
source_filename = gtest-1.12.1.tar.gz
source_hash = 81964fe578e9bd7c94dfdb09c8e4d6e6759e19967e397dbea48d1c10e45d0df2
patch_filename = gtest_1.12.1-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/gtest_1.12.1-1/get_patch
patch_hash = 75143f11e174952bc768699fde3176511fe8e33b25dc6f6347d89e41648e99cf
wrapdb_version = 1.12.1-1

[provide]
gtest = gtest_dep
gtest_main = gtest_main_dep
gmock = gmock_dep
gmock_main = gmock_main_dep
57 changes: 57 additions & 0 deletions unitTests/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
gtest_dep = dependency('gtest', required: get_option('unitTests'))
if not gtest_dep.found()
subdir_done()
endif

gmock_dep = dependency('gmock')

test_sources = files(
'mainTestRunner.cpp',
'test_basicio.cpp',
'test_bmpimage.cpp',
'test_cr2header_int.cpp',
#'test_datasets.cpp',
'test_Error.cpp',
'test_DateValue.cpp',
'test_enforce.cpp',
'test_FileIo.cpp',
'test_futils.cpp',
'test_helper_functions.cpp',
'test_image_int.cpp',
'test_ImageFactory.cpp',
'test_jp2image.cpp',
'test_jp2image_int.cpp',
#'test_IptcKey.cpp',
'test_LangAltValueRead.cpp',
'test_Photoshop.cpp',
'test_pngimage.cpp',
'test_safe_op.cpp',
'test_slice.cpp',
'test_tiffheader.cpp',
'test_types.cpp',
'test_TimeValue.cpp',
'test_utils.cpp',
'test_XmpKey.cpp',
)

if get_option('video')
test_sources += files(
'test_asfvideo.cpp',
'test_matroskavideo.cpp',
'test_riffVideo.cpp',
)
endif

t_args = ['-DTESTDATA_PATH="@0@"'.format('..' / 'test' / 'data')]

privinc = include_directories('../src', '../include/exiv2')
unit_tests = executable(
'unit_tests',
test_sources,
cpp_args: t_args,
dependencies: [exiv2_dep, gmock_dep, gtest_dep],
link_with: exiv_int,
include_directories: privinc,
)

test('Unit Tests', unit_tests)

0 comments on commit 22b59ed

Please sign in to comment.