diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-08-27 22:48:00 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-09-20 19:30:46 +0200 |
| commit | 7d91e693291014e6b4c637071d83b6f3b501ed12 (patch) | |
| tree | ef63bf8bb1bdf59dd35fb168d7b00d4d73536381 /test | |
| parent | b509d21444a1f486b8713a1a652c0f816b2af0cb (diff) | |
Allow LanguageTag to be constructed from a tag string.
Diffstat (limited to 'test')
| -rw-r--r-- | test/language_tag_test.cc | 21 |
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"); +} + |
