summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvisvgm/dvisvgm-src/tests/SpecialManagerTest.cpp
blob: 156dd14f2f4c6444bfac124ea0cb90a2c6a9db06 (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*************************************************************************
** SpecialManagerTest.cpp                                               **
**                                                                      **
** This file is part of dvisvgm -- a fast DVI to SVG converter          **
** Copyright (C) 2005-2020 Martin Gieseking <martin.gieseking@uos.de>   **
**                                                                      **
** This program is free software; you can redistribute it and/or        **
** modify it under the terms of the GNU General Public License as       **
** published by the Free Software Foundation; either version 3 of       **
** the License, or (at your option) any later version.                  **
**                                                                      **
** This program is distributed in the hope that it will be useful, but  **
** WITHOUT ANY WARRANTY; without even the implied warranty of           **
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the         **
** GNU General Public License for more details.                         **
**                                                                      **
** You should have received a copy of the GNU General Public License    **
** along with this program; if not, see <http://www.gnu.org/licenses/>. **
*************************************************************************/

#include <gtest/gtest.h>
#include <sstream>
#include "SpecialManager.hpp"
#include "BgColorSpecialHandler.hpp"
#include "ColorSpecialHandler.hpp"
#include "DvisvgmSpecialHandler.hpp"
#include "EmSpecialHandler.hpp"
#include "HtmlSpecialHandler.hpp"
#include "NoPsSpecialHandler.hpp"
#include "PapersizeSpecialHandler.hpp"
#include "PdfSpecialHandler.hpp"
#include "TpicSpecialHandler.hpp"
#include "utility.hpp"

using namespace std;

class SpecialManagerTest : public ::testing::Test {
	public:
		SpecialManagerTest () {
			handlers.emplace_back(util::make_unique<BgColorSpecialHandler>());
			handlers.emplace_back(util::make_unique<ColorSpecialHandler>());
			handlers.emplace_back(util::make_unique<DvisvgmSpecialHandler>());
			handlers.emplace_back(util::make_unique<EmSpecialHandler>());
			handlers.emplace_back(util::make_unique<HtmlSpecialHandler>());
			handlers.emplace_back(util::make_unique<PapersizeSpecialHandler>());
			handlers.emplace_back(util::make_unique<PdfSpecialHandler>());
			handlers.emplace_back(util::make_unique<TpicSpecialHandler>());
			handlers.emplace_back(util::make_unique<NoPsSpecialHandler>());
		}

		vector<unique_ptr<SpecialHandler>> handlers;
};


TEST_F(SpecialManagerTest, info1) {
	SpecialManager &sm = SpecialManager::instance();
	sm.unregisterHandlers();
	sm.registerHandlers(handlers, "");
	ostringstream oss;
	sm.writeHandlerInfo(oss);
	string expected =
		"bgcolor    background color special\n"
		"color      complete support of color specials\n"
		"dvisvgm    special set for embedding raw SVG snippets\n"
		"em         line drawing statements of the emTeX special set\n"
		"html       hyperref specials\n"
		"papersize  special to set the page size\n"
		"pdf        PDF hyperlink, font map, and pagesize specials\n"
		"tpic       TPIC specials\n";
	EXPECT_EQ(oss.str(), expected);
}


TEST_F(SpecialManagerTest, info2) {
	SpecialManager &sm = SpecialManager::instance();
	sm.unregisterHandlers();
	sm.registerHandlers(handlers, "color,em");
	ostringstream oss;
	sm.writeHandlerInfo(oss);
	string expected =
		"bgcolor    background color special\n"
		"dvisvgm    special set for embedding raw SVG snippets\n"
		"html       hyperref specials\n"
		"papersize  special to set the page size\n"
		"pdf        PDF hyperlink, font map, and pagesize specials\n"
		"tpic       TPIC specials\n";
	EXPECT_EQ(oss.str(), expected);
}