utf8rewind  1.3.0
System library for processing UTF-8 encoded text
helpers-casemapping.hpp
Go to the documentation of this file.
1 #pragma once
2 
10 #include "helpers-base.hpp"
11 
12 #define EXPECT_CASEMAPPING_CODEPOINT_NUL_EQ(_codepoint, _name) { \
13  ::helpers::CaseMappingEntry e; \
14  e.codepoint = _codepoint; \
15  e.lowercase = std::string(1, '\0'); \
16  e.uppercase = std::string(1, '\0'); \
17  e.titlecase = std::string(1, '\0'); \
18  e.name = _name; \
19  ::helpers::CaseMappingEntry a; \
20  a.lowercase = ::helpers::lowercase(_codepoint); \
21  a.uppercase = ::helpers::uppercase(_codepoint); \
22  a.titlecase = ::helpers::titlecase(_codepoint); \
23  EXPECT_PRED_FORMAT2(::helpers::CompareCodepoint, e, a); \
24 }
25 
26 #define EXPECT_CASEMAPPING_CODEPOINT_EQ(_codepoint, _lowercase, _uppercase, _titlecase, _name) { \
27  ::helpers::CaseMappingEntry e; \
28  e.codepoint = _codepoint; \
29  e.lowercase = _lowercase; \
30  e.uppercase = _uppercase; \
31  e.titlecase = _titlecase; \
32  e.name = _name; \
33  ::helpers::CaseMappingEntry a; \
34  a.lowercase = ::helpers::lowercase(_codepoint); \
35  a.uppercase = ::helpers::uppercase(_codepoint); \
36  a.titlecase = ::helpers::titlecase(_codepoint); \
37  EXPECT_PRED_FORMAT2(::helpers::CompareCodepoint, e, a); \
38 }
39 
40 #define EXPECT_CASEMAPPING_EQ(_input, _lowercase, _uppercase, _titlecase) { \
41  ::helpers::CaseMappingEntry e; \
42  e.lowercase = _lowercase; \
43  e.uppercase = _uppercase; \
44  e.titlecase = _titlecase; \
45  ::helpers::CaseMappingEntry a; \
46  a.input = _input; \
47  a.lowercase = ::helpers::lowercase(_input); \
48  a.uppercase = ::helpers::uppercase(_input); \
49  a.titlecase = ::helpers::titlecase(_input); \
50  EXPECT_PRED_FORMAT2(::helpers::CompareCaseMapping, e, a); \
51 }
52 
53 namespace helpers {
54 
55  std::string uppercase(unicode_t codepoint);
56  std::string uppercase(const std::string& text);
57 
58  std::string lowercase(unicode_t codepoint);
59  std::string lowercase(const std::string& text);
60 
61  std::string titlecase(unicode_t codepoint);
62  std::string titlecase(const std::string& text);
63 
64  struct CaseMappingEntry
65  {
66  CaseMappingEntry()
67  : codepoint(0)
68  {
69  }
70 
71  unicode_t codepoint;
72  std::string name;
73  std::string input;
74  std::string lowercase;
75  std::string uppercase;
76  std::string titlecase;
77  };
78 
79  ::testing::AssertionResult CompareCodepoint(
80  const char* expressionExpected, const char* expressionActual,
81  const CaseMappingEntry& entryExpected, const CaseMappingEntry& entryActual);
82 
83  ::testing::AssertionResult CompareCaseMapping(
84  const char* expressionExpected, const char* expressionActual,
85  const CaseMappingEntry& entryExpected, const CaseMappingEntry& entryActual);
86 
87 };
88 
uint32_t unicode_t
UTF-32 encoded code point.
Definition: utf8rewind.h:235
Base includes for helper methods.