OpenShot Audio Library | OpenShotAudio
1.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
juce_EnumHelpers_test.cpp
1
/*
2
==============================================================================
3
4
This file is part of the JUCE library.
5
Copyright (c) 2022 - Raw Material Software Limited
6
7
JUCE is an open source library subject to commercial or open-source
8
licensing.
9
10
The code included in this file is provided under the terms of the ISC license
11
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12
To use, copy, modify, and/or distribute this software for any purpose with or
13
without fee is hereby granted provided that the above copyright notice and
14
this permission notice appear in all copies.
15
16
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18
DISCLAIMED.
19
20
==============================================================================
21
*/
22
23
namespace
juce
24
{
25
26
namespace
detail
27
{
28
enum class
TestEnum
29
{
30
one = 1 << 0,
31
four = 1 << 1,
32
other = 1 << 2
33
};
34
35
JUCE_DECLARE_SCOPED_ENUM_BITWISE_OPERATORS (TestEnum)
36
}
37
38
class
EnumHelperTest final :
public
UnitTest
39
{
40
public
:
41
EnumHelperTest() :
UnitTest
(
"EnumHelpers"
, UnitTestCategories::containers) {}
42
43
void
runTest()
override
44
{
45
using
detail::TestEnum;
46
47
TestEnum e = {};
48
49
beginTest
(
"Default initialised enum is 'none'"
);
50
{
51
expect
(e == TestEnum{});
52
expect
(! hasBitValueSet (e, TestEnum{}));
53
}
54
55
beginTest
(
"withBitValueSet sets correct bit on empty enum"
);
56
{
57
e = withBitValueSet (e, TestEnum::other);
58
expect
(e == TestEnum::other);
59
expect
(hasBitValueSet (e, TestEnum::other));
60
}
61
62
beginTest
(
"withBitValueSet sets correct bit on non-empty enum"
);
63
{
64
e = withBitValueSet (e, TestEnum::one);
65
expect
(hasBitValueSet (e, TestEnum::one));
66
}
67
68
beginTest
(
"withBitValueCleared clears correct bit"
);
69
{
70
e = withBitValueCleared (e, TestEnum::one);
71
expect
(e != TestEnum::one);
72
expect
(hasBitValueSet (e, TestEnum::other));
73
expect
(! hasBitValueSet (e, TestEnum::one));
74
}
75
76
beginTest
(
"operators work as expected"
);
77
{
78
e = TestEnum::one;
79
expect
((e & TestEnum::one) != TestEnum{});
80
e |= TestEnum::other;
81
expect
((e & TestEnum::other) != TestEnum{});
82
83
e &= ~TestEnum::one;
84
expect
((e & TestEnum::one) == TestEnum{});
85
expect
((e & TestEnum::other) != TestEnum{});
86
}
87
}
88
};
89
90
static
EnumHelperTest enumHelperTest;
91
92
}
// namespace juce
juce::UnitTest
Definition
juce_UnitTest.h:70
juce::UnitTest::UnitTest
UnitTest(const String &name, const String &category=String())
Definition
juce_UnitTest.cpp:26
juce::UnitTest::beginTest
void beginTest(const String &testName)
Definition
juce_UnitTest.cpp:89
juce::UnitTest::expect
void expect(bool testResult, const String &failureMessage=String())
Definition
juce_UnitTest.cpp:97
libopenshot-audio
JuceLibraryCode
modules
juce_core
misc
juce_EnumHelpers_test.cpp
Generated by
1.18.0