]> git.mxchange.org Git - simgear.git/blob - simgear/misc/utf8tolatin1_test.cxx
Fix VS2010 lack of fminf
[simgear.git] / simgear / misc / utf8tolatin1_test.cxx
1 /// Unit tests for utf8ToLatin1 conversion function
2 #define BOOST_TEST_MODULE misc
3 #include <BoostTestTargetConfig.h>
4
5 #include "strutils.hxx"
6 #include <string>
7
8 BOOST_AUTO_TEST_CASE( utf8_latin1_conversion )
9 {
10   std::string utf8_string1 = "Zweibr\u00FCcken";
11   //valid UTF-8, convertible to Latin-1
12   std::string latin1_string1 = "Zweibr\374cken";
13   //Latin-1, not valid UTF-8
14   std::string utf8_string2 = "\u600f\U00010143";
15   //valid UTF-8, out of range for Latin-1
16
17   std::string output_string1u = simgear::strutils::utf8ToLatin1(utf8_string1);
18   BOOST_CHECK_EQUAL(output_string1u, latin1_string1);
19
20   std::string output_string1l = simgear::strutils::utf8ToLatin1(latin1_string1);
21   BOOST_CHECK_EQUAL(output_string1l, latin1_string1);
22
23   std::string output_string3 = simgear::strutils::utf8ToLatin1(utf8_string2);
24   //we don't check the result of this one as there is no right answer,
25   //just make sure it doesn't crash/hang
26 }