48 invariants(line, rest);
54 invariants(line, rest);
59 SECTION(
"single chunk") {
63 invariants(line, rest);
64 checkString(line, rest);
66 CHECK(rest.str().size() == 26);
67 CHECK(rest.getChunks().size() == 1);
71 invariants(line, rest);
72 checkString(line, rest);
75 CHECK(rest.str().size() == 13);
76 CHECK(rest.getChunks().size() == 1);
80 invariants(line, rest);
81 checkString(line, rest);
88 invariants(line, rest);
89 checkString(line, rest);
95 SECTION(
"multiple chunks") {
96 auto col1 =
static_cast<imColor>(101);
97 auto col2 =
static_cast<imColor>(102);
98 auto col3 =
static_cast<imColor>(103);
101 line.
addChunk(
"ghijklmnopqr", col2);
105 invariants(line, rest);
106 checkString(line, rest);
108 CHECK(rest.str().size() == 26);
109 CHECK(rest.getChunks().size() == 3);
110 CHECK(rest.getChunks()[0].color == col1);
111 CHECK(rest.getChunks()[0].pos == 0);
112 CHECK(rest.getChunks()[1].color == col2);
113 CHECK(rest.getChunks()[1].pos == 6);
114 CHECK(rest.getChunks()[2].color == col3);
115 CHECK(rest.getChunks()[2].pos == 18);
117 SECTION(
"split 1st chunk") {
119 invariants(line, rest);
120 checkString(line, rest);
125 CHECK(rest.str().size() == 23);
126 CHECK(rest.getChunks().size() == 3);
127 CHECK(rest.getChunks()[0].color == col1);
128 CHECK(rest.getChunks()[0].pos == 0);
129 CHECK(rest.getChunks()[1].color == col2);
130 CHECK(rest.getChunks()[1].pos == 3);
131 CHECK(rest.getChunks()[2].color == col3);
132 CHECK(rest.getChunks()[2].pos == 15);
134 SECTION(
"at 1st chunk") {
136 invariants(line, rest);
137 checkString(line, rest);
142 CHECK(rest.str().size() == 20);
143 CHECK(rest.getChunks().size() == 2);
144 CHECK(rest.getChunks()[0].color == col2);
145 CHECK(rest.getChunks()[0].pos == 0);
146 CHECK(rest.getChunks()[1].color == col3);
147 CHECK(rest.getChunks()[1].pos == 12);
149 SECTION(
"split 2nd chunk") {
151 invariants(line, rest);
152 checkString(line, rest);
159 CHECK(rest.str().size() == 13);
160 CHECK(rest.getChunks().size() == 2);
161 CHECK(rest.getChunks()[0].color == col2);
162 CHECK(rest.getChunks()[0].pos == 0);
163 CHECK(rest.getChunks()[1].color == col3);
164 CHECK(rest.getChunks()[1].pos == 5);
166 SECTION(
"at 2nd chunk") {
168 invariants(line, rest);
169 checkString(line, rest);
176 CHECK(rest.str().size() == 8);
177 CHECK(rest.getChunks().size() == 1);
178 CHECK(rest.getChunks()[0].color == col3);
179 CHECK(rest.getChunks()[0].pos == 0);
181 SECTION(
"split 3rd chunk") {
183 invariants(line, rest);
184 checkString(line, rest);
193 CHECK(rest.str().size() == 6);
194 CHECK(rest.getChunks().size() == 1);
195 CHECK(rest.getChunks()[0].color == col3);
196 CHECK(rest.getChunks()[0].pos == 0);
198 SECTION(
"at 3rd chunk") {
200 invariants(line, rest);
201 checkString(line, rest);
212 SECTION(
"past end") {
214 invariants(line, rest);
215 checkString(line, rest);