| 1 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 | /* |
| 3 | Copyright (C) 2021 Marcin Rybacki |
| 4 | |
| 5 | This file is part of QuantLib, a free-software/open-source library |
| 6 | for financial quantitative analysts and developers - http://quantlib.org/ |
| 7 | |
| 8 | QuantLib is free software: you can redistribute it and/or modify it |
| 9 | under the terms of the QuantLib license. You should have received a |
| 10 | copy of the license along with this program; if not, please email |
| 11 | <quantlib-dev@lists.sf.net>. The license is also available online at |
| 12 | <http://quantlib.org/license.shtml>. |
| 13 | |
| 14 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 16 | FOR A PARTICULAR PURPOSE. See the license for more details. |
| 17 | */ |
| 18 | |
| 19 | #include "currency.hpp" |
| 20 | #include "utilities.hpp" |
| 21 | #include <ql/currency.hpp> |
| 22 | |
| 23 | using namespace QuantLib; |
| 24 | using namespace boost::unit_test_framework; |
| 25 | |
| 26 | void CurrencyTest::testBespokeConstructor() { |
| 27 | BOOST_TEST_MESSAGE("Testing bespoke currency constructor..." ); |
| 28 | |
| 29 | std::string name("Some Currency" ); |
| 30 | std::string code("CCY" ); |
| 31 | std::string symbol("#" ); |
| 32 | |
| 33 | Currency customCcy(name, code, 100, symbol, "" , 100, Rounding(), "" ); |
| 34 | |
| 35 | if (customCcy.empty()) |
| 36 | BOOST_ERROR("Failed to create bespoke currency." ); |
| 37 | |
| 38 | if (customCcy.name() != name) |
| 39 | BOOST_ERROR("incorrect currency name\n" |
| 40 | << " actual: " << customCcy.name() << "\n" |
| 41 | << " expected: " << name << "\n" ); |
| 42 | |
| 43 | if (customCcy.code() != code) |
| 44 | BOOST_ERROR("incorrect currency code\n" |
| 45 | << " actual: " << customCcy.code() << "\n" |
| 46 | << " expected: " << code << "\n" ); |
| 47 | |
| 48 | if (customCcy.symbol() != symbol) |
| 49 | BOOST_ERROR("incorrect currency symbol\n" |
| 50 | << " actual: " << customCcy.symbol() << "\n" |
| 51 | << " expected: " << symbol << "\n" ); |
| 52 | } |
| 53 | |
| 54 | test_suite* CurrencyTest::suite() { |
| 55 | auto* suite = BOOST_TEST_SUITE("Currency tests" ); |
| 56 | |
| 57 | suite->add(QUANTLIB_TEST_CASE(&CurrencyTest::testBespokeConstructor)); |
| 58 | |
| 59 | return suite; |
| 60 | } |
| 61 | |