File: validity.cpp

package info (click to toggle)
xca 2.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,328 kB
  • sloc: cpp: 30,584; sh: 341; xml: 74; makefile: 56; python: 34
file content (55 lines) | stat: -rw-r--r-- 1,560 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* vi: set sw=4 ts=4:
 *
 * Copyright (C) 2023 Christian Hohnstaedt.
 *
 * All rights reserved.
 */

#include <QTest>

#include "widgets/MainWindow.h"
#include "widgets/validity.h"

#include "main.h"

void test_main::testValidity()
{
	try {

		Validity *start = new Validity(mainwin);
		Validity *end = new Validity(mainwin);

		QCOMPARE(start->displayFormat(), "yyyy-MM-dd hh:mm 'GMT'");
		QCOMPARE(end->displayFormat(), "yyyy-MM-dd hh:mm 'GMT'");
		end->setEndDate(true);
		start->hideTime(true);
		end->hideTime(true);
		QCOMPARE(start->displayFormat(), "yyyy-MM-dd 00:00 'GMT'");
		QCOMPARE(end->displayFormat(), "yyyy-MM-dd 23:59 'GMT'");

		start->setDate(a1time("20130921094317Z"));
		end->setDiff(start, 7, 0);
		QCOMPARE(start->getDate().toPlain(), "20130921000000Z");
		QCOMPARE(end->getDate().toPlain(), "20130927235959Z");
		start->hideTime(false);
		end->hideTime(false);
		QCOMPARE(start->getDate().toPlain(), "20130921094300Z");
		QCOMPARE(end->getDate().toPlain(), "20130928094300Z");
		start->hideTime(false);
		QCOMPARE(start->getDate().toPlain(), "20130921094300Z");
		start->hideTime(true);
		end->hideTime(true);
		QCOMPARE(start->getDate().toPlain(), "20130921000000Z");
		QCOMPARE(end->getDate().toPlain(), "20130927235959Z");

		end->setDiff(start, 2, 1);
		QCOMPARE(end->getDate().toPlain(), "20131120235959Z");
		end->hideTime(true);
		QCOMPARE(end->getDate().toPlain(), "20131120235959Z");
		end->hideTime(false);
		QCOMPARE(end->getDate().toPlain(), "20131121094300Z");

	} catch (...) {
		QVERIFY2(false, "Exception thrown");
	}
}