lib/icu/Converter: Create() throws exception on error

This commit is contained in:
Max Kellermann
2016-04-12 22:18:36 +02:00
parent 33fdaa5b6d
commit 01b68db30e
9 changed files with 45 additions and 45 deletions

View File

@@ -13,6 +13,8 @@
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/extensions/HelperMacros.h>
#include <stdexcept>
#include <string.h>
#include <stdlib.h>
@@ -39,14 +41,16 @@ class TestIcuConverter : public CppUnit::TestFixture {
public:
void TestInvalidCharset() {
CPPUNIT_ASSERT_EQUAL((IcuConverter *)nullptr,
IcuConverter::Create("doesntexist",
IgnoreError()));
try {
IcuConverter::Create("doesntexist");
CPPUNIT_FAIL("Exception expected");
} catch (const std::runtime_error &) {
}
}
void TestLatin1() {
IcuConverter *const converter =
IcuConverter::Create("iso-8859-1", IgnoreError());
IcuConverter::Create("iso-8859-1");
CPPUNIT_ASSERT(converter != nullptr);
for (const auto i : invalid_utf8) {