mirror of
https://github.com/taglib/taglib.git
synced 2025-07-18 13:04:18 -04:00
Add a CppUnit-based test suite (only very few things is covered for now, but it's a start).
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@734995 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
25
tests/utils.h
Normal file
25
tests/utils.h
Normal file
@ -0,0 +1,25 @@
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <sys/fcntl.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
inline string copyFile(const string &filename, const string &ext)
|
||||
{
|
||||
string newname = string(tempnam(NULL, NULL)) + ext;
|
||||
string oldname = string("data/") + filename + ext;
|
||||
char buffer[4096];
|
||||
int bytes;
|
||||
int inf = open(oldname.c_str(), O_RDONLY);
|
||||
int outf = open(newname.c_str(), O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR);
|
||||
while((bytes = read(inf, buffer, sizeof(buffer))) > 0)
|
||||
write(outf, buffer, bytes);
|
||||
close(outf);
|
||||
close(inf);
|
||||
return newname;
|
||||
}
|
||||
|
||||
inline void deleteFile(const string &filename)
|
||||
{
|
||||
remove(filename.c_str());
|
||||
}
|
Reference in New Issue
Block a user