2016-02-19 05:25:34 +00:00
|
|
|
// This file is part of Background Music.
|
|
|
|
//
|
|
|
|
// Background Music 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 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Background Music 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 Background Music. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
//
|
|
|
|
// BGM_TestUtils.h
|
2016-03-30 08:00:20 +00:00
|
|
|
// SharedSource
|
2016-02-19 05:25:34 +00:00
|
|
|
//
|
|
|
|
// Copyright © 2016 Kyle Neideck
|
|
|
|
//
|
|
|
|
|
2016-03-30 08:00:20 +00:00
|
|
|
#ifndef __SharedSource__BGM_TestUtils__
|
|
|
|
#define __SharedSource__BGM_TestUtils__
|
2016-02-19 05:25:34 +00:00
|
|
|
|
|
|
|
// Test Framework
|
|
|
|
#import <XCTest/XCTest.h>
|
|
|
|
|
2016-03-30 08:00:20 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
|
2016-02-19 05:25:34 +00:00
|
|
|
// STL Includes
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
|
2016-03-30 08:00:20 +00:00
|
|
|
// Fails the test if f doesn't throw ExpectedException when run.
|
|
|
|
// (The "self" argument is required by XCTFail, presumably so it can report the context.)
|
2016-02-19 05:25:34 +00:00
|
|
|
template<typename ExpectedException>
|
2016-03-30 08:00:20 +00:00
|
|
|
void BGMShouldThrow(XCTestCase* self, const std::function<void()>& f)
|
2016-02-19 05:25:34 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
f();
|
|
|
|
XCTFail();
|
|
|
|
}
|
|
|
|
catch (ExpectedException)
|
|
|
|
{ }
|
|
|
|
}
|
|
|
|
|
2016-03-30 08:00:20 +00:00
|
|
|
#endif /* defined(__cplusplus) */
|
|
|
|
|
|
|
|
#endif /* __SharedSource__BGM_TestUtils__ */
|
2016-02-19 05:25:34 +00:00
|
|
|
|