LeechCraft
0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
Toggle main menu visibility
Loading...
Searching...
No Matches
eithertest.cpp
Go to the documentation of this file.
1
/**********************************************************************
2
* LeechCraft - modular cross-platform feature rich internet client.
3
* Copyright (C) 2006-2014 Georg Rudoy
4
*
5
* Distributed under the Boost Software License, Version 1.0.
6
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7
**********************************************************************/
8
9
#include "
eithertest.h
"
10
#include <QtTest>
11
#include <either.h>
12
#include <
void.h
>
13
#include <
functor.h
>
14
15
QTEST_MAIN (
LC::Util::EitherTest
)
16
17
namespace
LC
18
{
19
namespace
Util
20
{
21
using
SomeEither_t
=
Either<int, QString>
;
22
23
void
EitherTest::testBasicLeft ()
24
{
25
const
SomeEither_t
left {
Left
(1) };
26
QCOMPARE (left.
IsLeft
(),
true
);
27
QCOMPARE (left.
IsRight
(),
false
);
28
QCOMPARE (left.
GetLeft
(), 1);
29
30
bool
hadCaught =
false
;
31
try
32
{
33
left.
GetRight
();
34
}
35
catch
(
const
std::exception&)
36
{
37
hadCaught =
true
;
38
}
39
QCOMPARE (hadCaught,
true
);
40
}
41
42
void
EitherTest::testBasicRight ()
43
{
44
const
SomeEither_t
right {
"foo"
};
45
QCOMPARE (right.IsLeft (),
false
);
46
QCOMPARE (right.IsRight (),
true
);
47
QCOMPARE (right.GetRight (), QString {
"foo"
});
48
49
bool
hadCaught =
false
;
50
try
51
{
52
right.GetLeft ();
53
}
54
catch
(
const
std::exception&)
55
{
56
hadCaught =
true
;
57
}
58
QCOMPARE (hadCaught,
true
);
59
}
60
}
61
}
LC::Util::Either
Definition
either.h:33
LC::Util::Either::GetLeft
const L & GetLeft() const
Definition
either.h:93
LC::Util::Either::IsRight
bool IsRight() const
Definition
either.h:88
LC::Util::Either::IsLeft
bool IsLeft() const
Definition
either.h:83
LC::Util::Either::GetRight
const R & GetRight() const
Definition
either.h:107
LC::Util::EitherTest
Definition
eithertest.h:18
eithertest.h
functor.h
LC::Util
Definition
icoreproxy.h:34
LC::Util::SomeEither_t
Either< int, QString > SomeEither_t
Definition
eithertest.cpp:21
LC
Definition
constants.h:15
LC::Util::Left
Definition
either.h:20
void.h
src
util
sll
tests
eithertest.cpp
Generated by
1.17.0