File: test-thumbnail-cmdline.cc

package info (click to toggle)
dspdfviewer 1.15.1%2Bgit20230427.d432d8d-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 924 kB
  • sloc: cpp: 2,303; makefile: 22; sh: 7
file content (64 lines) | stat: -rw-r--r-- 1,568 bytes parent folder | download | duplicates (5)
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
#include "testhelpers.hh"

// Test that the commandline accepts "left", "right" and "both",
// but not another string.

BOOST_AUTO_TEST_CASE(thumbnail_cmdline) {
	// correct arguments, left
	{
		const char * const argv[] = {
			"dspdfviewer", "--thumbnail-page-part", "left"
		};
		RuntimeConfiguration rc{ 3, argv };
		BOOST_CHECK_EQUAL( rc.thumbnailPagePart(), PagePart::LeftHalf );
	}
	// shorthand, two words
	{
		const char * const argv[] = {
			"dspdfviewer", "-T", "left"
		};
		RuntimeConfiguration rc{ 3, argv };
		BOOST_CHECK_EQUAL( rc.thumbnailPagePart(), PagePart::LeftHalf );
	}
	// shorthand, one word
	{
		const char * const argv[] = {
			"dspdfviewer", "-Tleft"
		};
		RuntimeConfiguration rc{ 2, argv };
		BOOST_CHECK_EQUAL( rc.thumbnailPagePart(), PagePart::LeftHalf );
	}

	// right
	{
		const char* const argv[] = {
			"dspdfviewer", "--thumbnail-page-part", "right"
		};
		RuntimeConfiguration rc{ 3, argv };
		BOOST_CHECK_EQUAL( rc.thumbnailPagePart(), PagePart::RightHalf );
	}
	{
		const char* const argv[] = {
			"dspdfviewer", "--thumbnail-page-part", "both"
		};
		RuntimeConfiguration rc{ 3, argv };
		BOOST_CHECK_EQUAL( rc.thumbnailPagePart(), PagePart::FullPage );
	}

	// wrong argument
	{
		const char* const argv[] = {
			"dspdfviewer", "--thumbnail-page-part", "something"
		};
		BOOST_CHECK_THROW( RuntimeConfiguration( 3, argv ) , std::logic_error );
	}

	// no argument
	{
		const char* const argv[] = {
			"dspdfviewer", "--thumbnail-page-part"
		};
		BOOST_CHECK_THROW( RuntimeConfiguration( 2, argv) , std::logic_error );
	}
}