Compare commits

...

3 Commits

Author SHA1 Message Date
mrbesen 5b0576aa0d
added tests to meson 2021-09-07 02:44:50 +02:00
mrbesen 5435d54510
fixed warning 2021-09-07 02:05:18 +02:00
mrbesen 489f8e38e2
basic meson 2021-09-07 02:05:13 +02:00
6 changed files with 53 additions and 3 deletions

9
inc/meson.build Normal file
View File

@ -0,0 +1,9 @@
headers = files([
'config.h',
'doy.h',
'files.h',
'mrbesen.h',
'util.h',
])
install_headers(headers, subdir: 'libmrbesen')

9
meson.build Normal file
View File

@ -0,0 +1,9 @@
project('libmrbesen', 'cpp', default_options : ['cpp_std=c++17', 'warning_level=3'])
inc = include_directories('inc')
subdir('inc')
subdir('src')
subdir('tests')

View File

@ -79,7 +79,7 @@ bool mrbesen::files::iterateFile(std::istream& file, fileLineCallback clb, bool
template<class Container>
bool mrbesen::files::scan(const std::string& path, std::insert_iterator<Container> it, bool prefixdir, fileNameFilter fnf) {
return scan(path, [&](const std::string& p, FileType t){ it = p; }, prefixdir, fnf);
return scan(path, [&](const std::string& p, [[maybe_unused]] FileType t){ it = p; }, prefixdir, fnf);
}
//curently only these are supported, because iterators may break on others upon insertion

18
src/meson.build Normal file
View File

@ -0,0 +1,18 @@
libmrbesenSrc = files([
'config.cpp',
'doy.cpp',
'files.cpp',
'util.cpp',
])
libmrbesen = both_libraries(
'mrbesen',
libmrbesenSrc,
include_directories: inc,
install: true,
)
libmrbesen_dep = declare_dependency(
link_with: libmrbesen.get_static_lib(),
include_directories: inc
)

View File

@ -147,11 +147,13 @@ int testFiles_readFile() {
ASSERT(!files::readFile(NONEXISTENT_FILE, buf), "this file should not be read"); //try to read non existing file
bool r = files::readFile(std::string("tests/filestests.cpp"), buf);
const char* testfile = "tests/filestests.cpp";
bool r = files::readFile(std::string(testfile), buf);
ASSERT(r, "failed to read");
//alternative read
int fd = open("tests/filestests.cpp", O_RDONLY);
int fd = open(testfile, O_RDONLY);
const unsigned int size = 1024*1024; //1MB
char* buf2 = new char[size];
ssize_t rc = read(fd, buf2, size);

12
tests/meson.build Normal file
View File

@ -0,0 +1,12 @@
testSrc = files([
'doytests.cpp',
'filestests.cpp',
'main.cpp',
'stringspliteratortest.cpp',
'test.h',
'utilstest.cpp',
])
libmrbesentestexe = executable('libmrbesen_test', testSrc, libmrbesenSrc, include_directories: inc,)
test('libmrbesenTest', libmrbesentestexe, is_parallel: true, workdir: meson.source_root())