summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-08-27 22:48:00 +0200
committerCarl Hetherington <cth@carlh.net>2020-09-21 21:57:18 +0200
commit04d4661dd008284aedc95b2a1f9e120cee17571b (patch)
tree50cf2da8a530a33c0b4b44b440584f27df4aff29 /test
parent140d631d7df68d47c36bd15558e9b58ef4038e27 (diff)
Allow LanguageTag to be constructed from a tag string.
Diffstat (limited to 'test')
-rw-r--r--test/language_tag_test.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/language_tag_test.cc b/test/language_tag_test.cc
index fd90b629..28c46b63 100644
--- a/test/language_tag_test.cc
+++ b/test/language_tag_test.cc
@@ -41,7 +41,7 @@ using std::vector;
using std::string;
-BOOST_AUTO_TEST_CASE (language_tag_test)
+BOOST_AUTO_TEST_CASE (language_tag_create_test)
{
/* Bad subtags raise errors */
@@ -177,3 +177,22 @@ BOOST_AUTO_TEST_CASE (language_tag_test)
}
}
+
+
+BOOST_AUTO_TEST_CASE (language_tag_parse_test)
+{
+ BOOST_CHECK_THROW (dcp::LanguageTag(""), dcp::LanguageTagError);
+ BOOST_CHECK_THROW (dcp::LanguageTag("...Aw498012351!"), dcp::LanguageTagError);
+ BOOST_CHECK_THROW (dcp::LanguageTag("fish"), dcp::LanguageTagError);
+ BOOST_CHECK_THROW (dcp::LanguageTag("de-Dogr-fish"), dcp::LanguageTagError);
+ BOOST_CHECK_THROW (dcp::LanguageTag("de-Dogr-DE-aranes-fish"), dcp::LanguageTagError);
+
+ BOOST_CHECK_EQUAL (dcp::LanguageTag("de").to_string(), "de");
+ BOOST_CHECK_EQUAL (dcp::LanguageTag("de-Dogr").to_string(), "de-Dogr");
+ BOOST_CHECK_EQUAL (dcp::LanguageTag("de-Dogr-DE").to_string(), "de-Dogr-DE");
+ BOOST_CHECK_EQUAL (dcp::LanguageTag("de-Dogr-DE-aranes").to_string(), "de-Dogr-DE-aranes");
+ BOOST_CHECK_EQUAL (dcp::LanguageTag("de-Dogr-DE-aranes-lemosin").to_string(), "de-Dogr-DE-aranes-lemosin");
+ BOOST_CHECK_EQUAL (dcp::LanguageTag("de-Dogr-DE-aranes-lemosin-abv").to_string(), "de-Dogr-DE-aranes-lemosin-abv");
+ BOOST_CHECK_EQUAL (dcp::LanguageTag("de-Dogr-DE-aranes-lemosin-abv-zsm").to_string(), "de-Dogr-DE-aranes-lemosin-abv-zsm");
+}
+