1 #include <msp/stringcodec/ascii.h>
2 #include <msp/stringcodec/utf8.h>
3 #include <msp/test/test.h>
8 class CodecTests: public Test::RegisteredTest<CodecTests>
13 static const char *get_name() { return "Codec"; }
16 void invalid_character();
17 void invalid_sequence();
21 CodecTests::CodecTests()
23 add(&CodecTests::invalid_character, "invalid_character").expect_throw<StringCodec::invalid_character>();
24 add(&CodecTests::invalid_sequence, "invalid_sequence").expect_throw<StringCodec::invalid_sequence>();
27 void CodecTests::invalid_character()
29 StringCodec::unichar ch = 0xE4;
30 StringCodec::Ascii::Encoder enc;
32 enc.encode_char(ch, buf);
35 void CodecTests::invalid_sequence()
37 string str = "\343\201";
38 string::const_iterator iter = str.begin();
39 StringCodec::Utf8::Decoder dec;
40 dec.decode_char(str, iter);