lyx_mirror/src/tests/check_Length.cpp
Georg Baum 7910502b8e Add unit test for the Length class
I noticed that inBP() is wrong for several units and want to fix it.
The unit test will help me to find regressions.
2015-07-12 18:10:43 +02:00

42 lines
727 B
C++

#include <config.h>
#include "../Length.h"
#include "../LyXRC.h"
#include "../support/debug.h"
#include <iostream>
using namespace lyx;
using namespace std;
void test_inPixels()
{
// want to see non-zero SP
lyxrc.zoom = 100000;
lyxrc.dpi = 72;
for (int i = Length::BP; i <= Length::UNIT_NONE; ++i) {
Length const l(2342, static_cast<Length::UNIT>(i));
cout << l.inPixels(250) << endl;
}
}
void test_inBP()
{
for (int i = Length::BP; i <= Length::UNIT_NONE; ++i) {
Length const l(2342, static_cast<Length::UNIT>(i));
cout << l.inBP() << endl;
}
}
int main(int, char **)
{
// Connect lyxerr with cout instead of cerr to catch error output
lyx::lyxerr.setStream(cout);
test_inPixels();
test_inBP();
}