mirror of
https://github.com/zaerl/mojibake.git
synced 2026-12-01 16:56:40 +01:00
* Remove obsolete mjb_error Signed-off-by: Francesco Bigiarini <francesco.bigiarini@gmail.com> * Fix: coverage Signed-off-by: Francesco Bigiarini <francesco.bigiarini@gmail.com> --------- Signed-off-by: Francesco Bigiarini <francesco.bigiarini@gmail.com>
32 lines
1.0 KiB
C++
32 lines
1.0 KiB
C++
/**
|
|
* The Mojibake library
|
|
*
|
|
* This file is distributed under the MIT License. See LICENSE for details.
|
|
*/
|
|
|
|
#include "../../../src/cpp/mojibake.hpp"
|
|
#include "../../test.h"
|
|
|
|
int test_cpp_locales(void *arg) {
|
|
const auto locale = mjb::parse_locale("sr-Latn-RS");
|
|
ATT_ASSERT(std::string(locale.language()), std::string("sr"), "parse_locale language")
|
|
ATT_ASSERT(std::string(locale.script()), std::string("Latn"), "parse_locale script")
|
|
ATT_ASSERT(std::string(locale.region()), std::string("RS"), "parse_locale region")
|
|
|
|
bool locale_error = false;
|
|
|
|
try {
|
|
(void)mjb::parse_locale("not_a_locale");
|
|
} catch(const mjb::LocaleError &error) {
|
|
locale_error = error.status() == MJB_STATUS_INVALID_ARGUMENT;
|
|
}
|
|
|
|
ATT_ASSERT(locale_error, true, "LocaleError preserves status")
|
|
mjb::set_locale(MJB_LOCALE_IT);
|
|
ATT_ASSERT((unsigned int)mjb::get_locale(), (unsigned int)MJB_LOCALE_IT,
|
|
"get_locale returns selected locale")
|
|
mjb::set_locale(MJB_LOCALE_EN);
|
|
|
|
return 0;
|
|
}
|