OSDN Git Service

f1194e4bb6dad275ab47ae8bf9a0f2990dfec63c
[winmerge-jp/winmerge-jp.git] / Testing / GoogleTest / Encoding / charsets_test.cpp
1 #include <gtest/gtest.h>
2 #include "charsets.h"
3
4 namespace
5 {
6         // The fixture for testing paths functions.
7         class CharsetsTest : public testing::Test
8         {
9         protected:
10                 // You can remove any or all of the following functions if its body
11                 // is   empty.
12
13                 CharsetsTest()
14                 {
15                         // You can do set-up work for each test here.
16                 }
17
18                 virtual ~CharsetsTest()
19                 {
20                         // You can do clean-up work     that doesn't throw exceptions here.
21                 }
22
23                 // If   the     constructor     and     destructor are not enough for setting up
24                 // and cleaning up each test, you can define the following methods:
25
26                 virtual void SetUp()
27                 {
28                         // Code here will be called     immediately     after the constructor (right
29                         // before each test).
30                 }
31
32                 virtual void TearDown()
33                 {
34                         // Code here will be called     immediately     after each test (right
35                         // before the destructor).
36                 }
37
38                 // Objects declared here can be used by all tests in the test case for Foo.
39         };
40
41         TEST_F(CharsetsTest, name_to_codepage)
42         {
43                 EXPECT_EQ(65001, GetEncodingCodePageFromId(GetEncodingIdFromName("UTF-8")));
44                 EXPECT_EQ(65001, GetEncodingCodePageFromName("utf-8"));
45                 EXPECT_EQ(0, GetEncodingIdFromName("abc"));
46                 EXPECT_EQ(0, GetEncodingCodePageFromId(GetEncodingIdFromName("abc")));
47                 EXPECT_EQ(0, GetEncodingCodePageFromName("abc"));
48         }
49
50         TEST_F(CharsetsTest, codepage_to_name)
51         {
52                 EXPECT_STREQ("utf-8", GetEncodingNameFromId(GetEncodingIdFromCodePage(65001)));
53                 EXPECT_STREQ("utf-8", GetEncodingNameFromCodePage(65001));
54                 EXPECT_EQ(0, GetEncodingNameFromId(GetEncodingIdFromCodePage(99999)));
55                 EXPECT_EQ(NULL, GetEncodingNameFromCodePage(99999));
56         }
57
58
59 }  // namespace