File: iter_iter_string.pass.cpp

package info (click to toggle)
libpmemobj-cpp 1.12-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 8,388 kB
  • sloc: cpp: 136,076; sh: 1,022; perl: 381; ansic: 163; makefile: 13
file content (675 lines) | stat: -rw-r--r-- 26,733 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Copyright 2019-2020, Intel Corporation
//
// Modified to test pmem::obj containers
//

#include "unittest.hpp"

#include <libpmemobj++/container/string.hpp>

namespace nvobj = pmem::obj;

using C = pmem::obj::string;

struct root {
	nvobj::persistent_ptr<C> s;
	nvobj::persistent_ptr<C> s_arr[176];
};

template <class S>
void
test(nvobj::pool<struct root> &pop, const S &s1, typename S::size_type pos1,
     typename S::size_type n1, const S &str, const S &expected)
{
	auto r = pop.root();

	nvobj::transaction::run(pop,
				[&] { r->s = nvobj::make_persistent<C>(s1); });

	auto &s = *r->s;

	typename S::size_type old_size = s.size();
	typename S::const_iterator first = s.cbegin() + pos1;
	typename S::const_iterator last = s.cbegin() + pos1 + n1;
	typename S::size_type xlen =
		static_cast<typename S::size_type>(std::distance(first, last));
	s.replace(first, last, str);
	UT_ASSERT(s == expected);
	typename S::size_type rlen = str.size();
	UT_ASSERT(s.size() == old_size - xlen + rlen);

	nvobj::transaction::run(pop,
				[&] { nvobj::delete_persistent<C>(r->s); });
}

template <class S>
void
test0(nvobj::pool<struct root> &pop)
{
	auto &s_arr = pop.root()->s_arr;

	test(pop, *s_arr[0], 0, 0, *s_arr[0], *s_arr[0]);
	test(pop, *s_arr[0], 0, 0, *s_arr[1], *s_arr[1]);
	test(pop, *s_arr[0], 0, 0, *s_arr[2], *s_arr[2]);
	test(pop, *s_arr[0], 0, 0, *s_arr[3], *s_arr[3]);
	test(pop, *s_arr[100], 0, 0, *s_arr[0], *s_arr[100]);
	test(pop, *s_arr[100], 0, 0, *s_arr[1], *s_arr[28]);
	test(pop, *s_arr[100], 0, 0, *s_arr[2], *s_arr[16]);
	test(pop, *s_arr[100], 0, 0, *s_arr[3], *s_arr[4]);
	test(pop, *s_arr[100], 0, 1, *s_arr[0], *s_arr[167]);
	test(pop, *s_arr[100], 0, 1, *s_arr[1], *s_arr[31]);
	test(pop, *s_arr[100], 0, 1, *s_arr[2], *s_arr[19]);
	test(pop, *s_arr[100], 0, 1, *s_arr[3], *s_arr[7]);
	test(pop, *s_arr[100], 0, 2, *s_arr[0], *s_arr[170]);
	test(pop, *s_arr[100], 0, 2, *s_arr[1], *s_arr[34]);
	test(pop, *s_arr[100], 0, 2, *s_arr[2], *s_arr[22]);
	test(pop, *s_arr[100], 0, 2, *s_arr[3], *s_arr[10]);
	test(pop, *s_arr[100], 0, 4, *s_arr[0], *s_arr[171]);
	test(pop, *s_arr[100], 0, 4, *s_arr[1], *s_arr[35]);
	test(pop, *s_arr[100], 0, 4, *s_arr[2], *s_arr[23]);
	test(pop, *s_arr[100], 0, 4, *s_arr[3], *s_arr[11]);
	test(pop, *s_arr[100], 0, 5, *s_arr[0], *s_arr[0]);
	test(pop, *s_arr[100], 0, 5, *s_arr[1], *s_arr[1]);
	test(pop, *s_arr[100], 0, 5, *s_arr[2], *s_arr[2]);
	test(pop, *s_arr[100], 0, 5, *s_arr[3], *s_arr[3]);
	test(pop, *s_arr[100], 1, 0, *s_arr[0], *s_arr[100]);
	test(pop, *s_arr[100], 1, 0, *s_arr[1], *s_arr[68]);
	test(pop, *s_arr[100], 1, 0, *s_arr[2], *s_arr[56]);
	test(pop, *s_arr[100], 1, 0, *s_arr[3], *s_arr[44]);
	test(pop, *s_arr[100], 1, 1, *s_arr[0], *s_arr[158]);
	test(pop, *s_arr[100], 1, 1, *s_arr[1], *s_arr[71]);
	test(pop, *s_arr[100], 1, 1, *s_arr[2], *s_arr[59]);
	test(pop, *s_arr[100], 1, 1, *s_arr[3], *s_arr[47]);
	test(pop, *s_arr[100], 1, 2, *s_arr[0], *s_arr[161]);
	test(pop, *s_arr[100], 1, 2, *s_arr[1], *s_arr[74]);
	test(pop, *s_arr[100], 1, 2, *s_arr[2], *s_arr[62]);
	test(pop, *s_arr[100], 1, 2, *s_arr[3], *s_arr[50]);
	test(pop, *s_arr[100], 1, 3, *s_arr[0], *s_arr[162]);
	test(pop, *s_arr[100], 1, 3, *s_arr[1], *s_arr[75]);
	test(pop, *s_arr[100], 1, 3, *s_arr[2], *s_arr[63]);
	test(pop, *s_arr[100], 1, 3, *s_arr[3], *s_arr[51]);
	test(pop, *s_arr[100], 1, 4, *s_arr[0], *s_arr[40]);
	test(pop, *s_arr[100], 1, 4, *s_arr[1], *s_arr[41]);
	test(pop, *s_arr[100], 1, 4, *s_arr[2], *s_arr[42]);
	test(pop, *s_arr[100], 1, 4, *s_arr[3], *s_arr[43]);
	test(pop, *s_arr[100], 2, 0, *s_arr[0], *s_arr[100]);
	test(pop, *s_arr[100], 2, 0, *s_arr[1], *s_arr[90]);
	test(pop, *s_arr[100], 2, 0, *s_arr[2], *s_arr[87]);
	test(pop, *s_arr[100], 2, 0, *s_arr[3], *s_arr[84]);
	test(pop, *s_arr[100], 2, 1, *s_arr[0], *s_arr[156]);
	test(pop, *s_arr[100], 2, 1, *s_arr[1], *s_arr[91]);
	test(pop, *s_arr[100], 2, 1, *s_arr[2], *s_arr[88]);
	test(pop, *s_arr[100], 2, 1, *s_arr[3], *s_arr[85]);
	test(pop, *s_arr[100], 2, 2, *s_arr[0], *s_arr[157]);
	test(pop, *s_arr[100], 2, 2, *s_arr[1], *s_arr[92]);
	test(pop, *s_arr[100], 2, 2, *s_arr[2], *s_arr[89]);
	test(pop, *s_arr[100], 2, 2, *s_arr[3], *s_arr[86]);
	test(pop, *s_arr[100], 2, 3, *s_arr[0], *s_arr[80]);
	test(pop, *s_arr[100], 2, 3, *s_arr[1], *s_arr[81]);
	test(pop, *s_arr[100], 2, 3, *s_arr[2], *s_arr[82]);
	test(pop, *s_arr[100], 2, 3, *s_arr[3], *s_arr[83]);
	test(pop, *s_arr[100], 4, 0, *s_arr[0], *s_arr[100]);
	test(pop, *s_arr[100], 4, 0, *s_arr[1], *s_arr[99]);
	test(pop, *s_arr[100], 4, 0, *s_arr[2], *s_arr[98]);
	test(pop, *s_arr[100], 4, 0, *s_arr[3], *s_arr[97]);
	test(pop, *s_arr[100], 4, 1, *s_arr[0], *s_arr[93]);
	test(pop, *s_arr[100], 4, 1, *s_arr[1], *s_arr[94]);
	test(pop, *s_arr[100], 4, 1, *s_arr[2], *s_arr[95]);
	test(pop, *s_arr[100], 4, 1, *s_arr[3], *s_arr[96]);
	test(pop, *s_arr[100], 5, 0, *s_arr[0], *s_arr[100]);
	test(pop, *s_arr[100], 5, 0, *s_arr[1], *s_arr[101]);
	test(pop, *s_arr[100], 5, 0, *s_arr[2], *s_arr[102]);
	test(pop, *s_arr[100], 5, 0, *s_arr[3], *s_arr[103]);
	test(pop, *s_arr[123], 0, 0, *s_arr[0], *s_arr[123]);
	test(pop, *s_arr[123], 0, 0, *s_arr[1], *s_arr[29]);
	test(pop, *s_arr[123], 0, 0, *s_arr[2], *s_arr[17]);
	test(pop, *s_arr[123], 0, 0, *s_arr[3], *s_arr[5]);
	test(pop, *s_arr[123], 0, 1, *s_arr[0], *s_arr[168]);
	test(pop, *s_arr[123], 0, 1, *s_arr[1], *s_arr[32]);
	test(pop, *s_arr[123], 0, 1, *s_arr[2], *s_arr[20]);
	test(pop, *s_arr[123], 0, 1, *s_arr[3], *s_arr[8]);
	test(pop, *s_arr[123], 0, 5, *s_arr[0], *s_arr[172]);
	test(pop, *s_arr[123], 0, 5, *s_arr[1], *s_arr[36]);
	test(pop, *s_arr[123], 0, 5, *s_arr[2], *s_arr[24]);
	test(pop, *s_arr[123], 0, 5, *s_arr[3], *s_arr[12]);
	test(pop, *s_arr[123], 0, 9, *s_arr[0], *s_arr[173]);
	test(pop, *s_arr[123], 0, 9, *s_arr[1], *s_arr[37]);
	test(pop, *s_arr[123], 0, 9, *s_arr[2], *s_arr[25]);
	test(pop, *s_arr[123], 0, 9, *s_arr[3], *s_arr[13]);
	test(pop, *s_arr[123], 0, 10, *s_arr[0], *s_arr[0]);
	test(pop, *s_arr[123], 0, 10, *s_arr[1], *s_arr[1]);
	test(pop, *s_arr[123], 0, 10, *s_arr[2], *s_arr[2]);
	test(pop, *s_arr[123], 0, 10, *s_arr[3], *s_arr[3]);
	test(pop, *s_arr[123], 1, 0, *s_arr[0], *s_arr[123]);
	test(pop, *s_arr[123], 1, 0, *s_arr[1], *s_arr[69]);
	test(pop, *s_arr[123], 1, 0, *s_arr[2], *s_arr[57]);
	test(pop, *s_arr[123], 1, 0, *s_arr[3], *s_arr[45]);
	test(pop, *s_arr[123], 1, 1, *s_arr[0], *s_arr[159]);
	test(pop, *s_arr[123], 1, 1, *s_arr[1], *s_arr[72]);
	test(pop, *s_arr[123], 1, 1, *s_arr[2], *s_arr[60]);
	test(pop, *s_arr[123], 1, 1, *s_arr[3], *s_arr[48]);
}

template <class S>
void
test1(nvobj::pool<struct root> &pop)
{
	auto &s_arr = pop.root()->s_arr;

	test(pop, *s_arr[123], 1, 4, *s_arr[0], *s_arr[163]);
	test(pop, *s_arr[123], 1, 4, *s_arr[1], *s_arr[76]);
	test(pop, *s_arr[123], 1, 4, *s_arr[2], *s_arr[64]);
	test(pop, *s_arr[123], 1, 4, *s_arr[3], *s_arr[52]);
	test(pop, *s_arr[123], 1, 8, *s_arr[0], *s_arr[164]);
	test(pop, *s_arr[123], 1, 8, *s_arr[1], *s_arr[77]);
	test(pop, *s_arr[123], 1, 8, *s_arr[2], *s_arr[65]);
	test(pop, *s_arr[123], 1, 8, *s_arr[3], *s_arr[53]);
	test(pop, *s_arr[123], 1, 9, *s_arr[0], *s_arr[40]);
	test(pop, *s_arr[123], 1, 9, *s_arr[1], *s_arr[41]);
	test(pop, *s_arr[123], 1, 9, *s_arr[2], *s_arr[42]);
	test(pop, *s_arr[123], 1, 9, *s_arr[3], *s_arr[43]);
	test(pop, *s_arr[123], 5, 0, *s_arr[0], *s_arr[123]);
	test(pop, *s_arr[123], 5, 0, *s_arr[1], *s_arr[112]);
	test(pop, *s_arr[123], 5, 0, *s_arr[2], *s_arr[108]);
	test(pop, *s_arr[123], 5, 0, *s_arr[3], *s_arr[104]);
	test(pop, *s_arr[123], 5, 1, *s_arr[0], *s_arr[153]);
	test(pop, *s_arr[123], 5, 1, *s_arr[1], *s_arr[113]);
	test(pop, *s_arr[123], 5, 1, *s_arr[2], *s_arr[109]);
	test(pop, *s_arr[123], 5, 1, *s_arr[3], *s_arr[105]);
	test(pop, *s_arr[123], 5, 2, *s_arr[0], *s_arr[154]);
	test(pop, *s_arr[123], 5, 2, *s_arr[1], *s_arr[114]);
	test(pop, *s_arr[123], 5, 2, *s_arr[2], *s_arr[110]);
	test(pop, *s_arr[123], 5, 2, *s_arr[3], *s_arr[106]);
	test(pop, *s_arr[123], 5, 4, *s_arr[0], *s_arr[155]);
	test(pop, *s_arr[123], 5, 4, *s_arr[1], *s_arr[115]);
	test(pop, *s_arr[123], 5, 4, *s_arr[2], *s_arr[111]);
	test(pop, *s_arr[123], 5, 4, *s_arr[3], *s_arr[107]);
	test(pop, *s_arr[123], 5, 5, *s_arr[0], *s_arr[100]);
	test(pop, *s_arr[123], 5, 5, *s_arr[1], *s_arr[101]);
	test(pop, *s_arr[123], 5, 5, *s_arr[2], *s_arr[102]);
	test(pop, *s_arr[123], 5, 5, *s_arr[3], *s_arr[103]);
	test(pop, *s_arr[123], 9, 0, *s_arr[0], *s_arr[123]);
	test(pop, *s_arr[123], 9, 0, *s_arr[1], *s_arr[122]);
	test(pop, *s_arr[123], 9, 0, *s_arr[2], *s_arr[121]);
	test(pop, *s_arr[123], 9, 0, *s_arr[3], *s_arr[120]);
	test(pop, *s_arr[123], 9, 1, *s_arr[0], *s_arr[116]);
	test(pop, *s_arr[123], 9, 1, *s_arr[1], *s_arr[117]);
	test(pop, *s_arr[123], 9, 1, *s_arr[2], *s_arr[118]);
	test(pop, *s_arr[123], 9, 1, *s_arr[3], *s_arr[119]);
	test(pop, *s_arr[123], 10, 0, *s_arr[0], *s_arr[123]);
	test(pop, *s_arr[123], 10, 0, *s_arr[1], *s_arr[124]);
	test(pop, *s_arr[123], 10, 0, *s_arr[2], *s_arr[125]);
	test(pop, *s_arr[123], 10, 0, *s_arr[3], *s_arr[126]);
	test(pop, *s_arr[146], 0, 0, *s_arr[0], *s_arr[146]);
	test(pop, *s_arr[146], 0, 0, *s_arr[1], *s_arr[30]);
	test(pop, *s_arr[146], 0, 0, *s_arr[2], *s_arr[18]);
	test(pop, *s_arr[146], 0, 0, *s_arr[3], *s_arr[6]);
	test(pop, *s_arr[146], 0, 1, *s_arr[0], *s_arr[169]);
	test(pop, *s_arr[146], 0, 1, *s_arr[1], *s_arr[33]);
	test(pop, *s_arr[146], 0, 1, *s_arr[2], *s_arr[21]);
	test(pop, *s_arr[146], 0, 1, *s_arr[3], *s_arr[9]);
	test(pop, *s_arr[146], 0, 10, *s_arr[0], *s_arr[174]);
	test(pop, *s_arr[146], 0, 10, *s_arr[1], *s_arr[38]);
	test(pop, *s_arr[146], 0, 10, *s_arr[2], *s_arr[26]);
	test(pop, *s_arr[146], 0, 10, *s_arr[3], *s_arr[14]);
	test(pop, *s_arr[146], 0, 19, *s_arr[0], *s_arr[175]);
	test(pop, *s_arr[146], 0, 19, *s_arr[1], *s_arr[39]);
	test(pop, *s_arr[146], 0, 19, *s_arr[2], *s_arr[27]);
	test(pop, *s_arr[146], 0, 19, *s_arr[3], *s_arr[15]);
	test(pop, *s_arr[146], 0, 20, *s_arr[0], *s_arr[0]);
	test(pop, *s_arr[146], 0, 20, *s_arr[1], *s_arr[1]);
	test(pop, *s_arr[146], 0, 20, *s_arr[2], *s_arr[2]);
	test(pop, *s_arr[146], 0, 20, *s_arr[3], *s_arr[3]);
	test(pop, *s_arr[146], 1, 0, *s_arr[0], *s_arr[146]);
	test(pop, *s_arr[146], 1, 0, *s_arr[1], *s_arr[70]);
	test(pop, *s_arr[146], 1, 0, *s_arr[2], *s_arr[58]);
	test(pop, *s_arr[146], 1, 0, *s_arr[3], *s_arr[46]);
	test(pop, *s_arr[146], 1, 1, *s_arr[0], *s_arr[160]);
	test(pop, *s_arr[146], 1, 1, *s_arr[1], *s_arr[73]);
	test(pop, *s_arr[146], 1, 1, *s_arr[2], *s_arr[61]);
	test(pop, *s_arr[146], 1, 1, *s_arr[3], *s_arr[49]);
	test(pop, *s_arr[146], 1, 9, *s_arr[0], *s_arr[165]);
	test(pop, *s_arr[146], 1, 9, *s_arr[1], *s_arr[78]);
	test(pop, *s_arr[146], 1, 9, *s_arr[2], *s_arr[66]);
	test(pop, *s_arr[146], 1, 9, *s_arr[3], *s_arr[54]);
	test(pop, *s_arr[146], 1, 18, *s_arr[0], *s_arr[166]);
	test(pop, *s_arr[146], 1, 18, *s_arr[1], *s_arr[79]);
	test(pop, *s_arr[146], 1, 18, *s_arr[2], *s_arr[67]);
	test(pop, *s_arr[146], 1, 18, *s_arr[3], *s_arr[55]);
	test(pop, *s_arr[146], 1, 19, *s_arr[0], *s_arr[40]);
	test(pop, *s_arr[146], 1, 19, *s_arr[1], *s_arr[41]);
	test(pop, *s_arr[146], 1, 19, *s_arr[2], *s_arr[42]);
	test(pop, *s_arr[146], 1, 19, *s_arr[3], *s_arr[43]);
	test(pop, *s_arr[146], 10, 0, *s_arr[0], *s_arr[146]);
	test(pop, *s_arr[146], 10, 0, *s_arr[1], *s_arr[135]);
	test(pop, *s_arr[146], 10, 0, *s_arr[2], *s_arr[131]);
	test(pop, *s_arr[146], 10, 0, *s_arr[3], *s_arr[127]);
	test(pop, *s_arr[146], 10, 1, *s_arr[0], *s_arr[150]);
	test(pop, *s_arr[146], 10, 1, *s_arr[1], *s_arr[136]);
	test(pop, *s_arr[146], 10, 1, *s_arr[2], *s_arr[132]);
	test(pop, *s_arr[146], 10, 1, *s_arr[3], *s_arr[128]);
	test(pop, *s_arr[146], 10, 5, *s_arr[0], *s_arr[151]);
	test(pop, *s_arr[146], 10, 5, *s_arr[1], *s_arr[137]);
	test(pop, *s_arr[146], 10, 5, *s_arr[2], *s_arr[133]);
	test(pop, *s_arr[146], 10, 5, *s_arr[3], *s_arr[129]);
	test(pop, *s_arr[146], 10, 9, *s_arr[0], *s_arr[152]);
	test(pop, *s_arr[146], 10, 9, *s_arr[1], *s_arr[138]);
	test(pop, *s_arr[146], 10, 9, *s_arr[2], *s_arr[134]);
	test(pop, *s_arr[146], 10, 9, *s_arr[3], *s_arr[130]);
}

template <class S>
void
test2(nvobj::pool<struct root> &pop)
{
	auto &s_arr = pop.root()->s_arr;

	test(pop, *s_arr[146], 10, 10, *s_arr[0], *s_arr[123]);
	test(pop, *s_arr[146], 10, 10, *s_arr[1], *s_arr[124]);
	test(pop, *s_arr[146], 10, 10, *s_arr[2], *s_arr[125]);
	test(pop, *s_arr[146], 10, 10, *s_arr[3], *s_arr[126]);
	test(pop, *s_arr[146], 19, 0, *s_arr[0], *s_arr[146]);
	test(pop, *s_arr[146], 19, 0, *s_arr[1], *s_arr[145]);
	test(pop, *s_arr[146], 19, 0, *s_arr[2], *s_arr[144]);
	test(pop, *s_arr[146], 19, 0, *s_arr[3], *s_arr[143]);
	test(pop, *s_arr[146], 19, 1, *s_arr[0], *s_arr[139]);
	test(pop, *s_arr[146], 19, 1, *s_arr[1], *s_arr[140]);
	test(pop, *s_arr[146], 19, 1, *s_arr[2], *s_arr[141]);
	test(pop, *s_arr[146], 19, 1, *s_arr[3], *s_arr[142]);
	test(pop, *s_arr[146], 20, 0, *s_arr[0], *s_arr[146]);
	test(pop, *s_arr[146], 20, 0, *s_arr[1], *s_arr[147]);
	test(pop, *s_arr[146], 20, 0, *s_arr[2], *s_arr[148]);
	test(pop, *s_arr[146], 20, 0, *s_arr[3], *s_arr[149]);
}

static void
test(int argc, char *argv[])
{
	if (argc < 2) {
		UT_FATAL("usage: %s file-name", argv[0]);
	}

	auto path = argv[1];
	auto pop = nvobj::pool<root>::create(
		path, "string_test", 2 * PMEMOBJ_MIN_POOL, S_IWUSR | S_IRUSR);

	auto r = pop.root();
	{
		auto &s_arr = r->s_arr;

		try {
			nvobj::transaction::run(pop, [&] {
				s_arr[0] = nvobj::make_persistent<C>("");
				s_arr[1] = nvobj::make_persistent<C>("12345");
				s_arr[2] =
					nvobj::make_persistent<C>("1234567890");
				s_arr[3] = nvobj::make_persistent<C>(
					"12345678901234567890");
				s_arr[4] = nvobj::make_persistent<C>(
					"12345678901234567890abcde");
				s_arr[5] = nvobj::make_persistent<C>(
					"12345678901234567890abcdefghij");
				s_arr[6] = nvobj::make_persistent<C>(
					"12345678901234567890abcdefghijklmnopqrst");
				s_arr[7] = nvobj::make_persistent<C>(
					"12345678901234567890bcde");
				s_arr[8] = nvobj::make_persistent<C>(
					"12345678901234567890bcdefghij");
				s_arr[9] = nvobj::make_persistent<C>(
					"12345678901234567890bcdefghijklmnopqrst");
				s_arr[10] = nvobj::make_persistent<C>(
					"12345678901234567890cde");
				s_arr[11] = nvobj::make_persistent<C>(
					"12345678901234567890e");
				s_arr[12] = nvobj::make_persistent<C>(
					"12345678901234567890fghij");
				s_arr[13] = nvobj::make_persistent<C>(
					"12345678901234567890j");
				s_arr[14] = nvobj::make_persistent<C>(
					"12345678901234567890klmnopqrst");
				s_arr[15] = nvobj::make_persistent<C>(
					"12345678901234567890t");
				s_arr[16] = nvobj::make_persistent<C>(
					"1234567890abcde");
				s_arr[17] = nvobj::make_persistent<C>(
					"1234567890abcdefghij");
				s_arr[18] = nvobj::make_persistent<C>(
					"1234567890abcdefghijklmnopqrst");
				s_arr[19] = nvobj::make_persistent<C>(
					"1234567890bcde");
				s_arr[20] = nvobj::make_persistent<C>(
					"1234567890bcdefghij");
				s_arr[21] = nvobj::make_persistent<C>(
					"1234567890bcdefghijklmnopqrst");
				s_arr[22] = nvobj::make_persistent<C>(
					"1234567890cde");
				s_arr[23] = nvobj::make_persistent<C>(
					"1234567890e");
				s_arr[24] = nvobj::make_persistent<C>(
					"1234567890fghij");
				s_arr[25] = nvobj::make_persistent<C>(
					"1234567890j");
				s_arr[26] = nvobj::make_persistent<C>(
					"1234567890klmnopqrst");
				s_arr[27] = nvobj::make_persistent<C>(
					"1234567890t");
				s_arr[28] =
					nvobj::make_persistent<C>("12345abcde");
				s_arr[29] = nvobj::make_persistent<C>(
					"12345abcdefghij");
				s_arr[30] = nvobj::make_persistent<C>(
					"12345abcdefghijklmnopqrst");
				s_arr[31] =
					nvobj::make_persistent<C>("12345bcde");
				s_arr[32] = nvobj::make_persistent<C>(
					"12345bcdefghij");
				s_arr[33] = nvobj::make_persistent<C>(
					"12345bcdefghijklmnopqrst");
				s_arr[34] =
					nvobj::make_persistent<C>("12345cde");
				s_arr[35] = nvobj::make_persistent<C>("12345e");
				s_arr[36] =
					nvobj::make_persistent<C>("12345fghij");
				s_arr[37] = nvobj::make_persistent<C>("12345j");
				s_arr[38] = nvobj::make_persistent<C>(
					"12345klmnopqrst");
				s_arr[39] = nvobj::make_persistent<C>("12345t");
				s_arr[40] = nvobj::make_persistent<C>("a");
				s_arr[41] = nvobj::make_persistent<C>("a12345");
				s_arr[42] = nvobj::make_persistent<C>(
					"a1234567890");
				s_arr[43] = nvobj::make_persistent<C>(
					"a12345678901234567890");
				s_arr[44] = nvobj::make_persistent<C>(
					"a12345678901234567890bcde");
				s_arr[45] = nvobj::make_persistent<C>(
					"a12345678901234567890bcdefghij");
				s_arr[46] = nvobj::make_persistent<C>(
					"a12345678901234567890bcdefghijklmnopqrst");
				s_arr[47] = nvobj::make_persistent<C>(
					"a12345678901234567890cde");
				s_arr[48] = nvobj::make_persistent<C>(
					"a12345678901234567890cdefghij");
				s_arr[49] = nvobj::make_persistent<C>(
					"a12345678901234567890cdefghijklmnopqrst");
				s_arr[50] = nvobj::make_persistent<C>(
					"a12345678901234567890de");
				s_arr[51] = nvobj::make_persistent<C>(
					"a12345678901234567890e");
				s_arr[52] = nvobj::make_persistent<C>(
					"a12345678901234567890fghij");
				s_arr[53] = nvobj::make_persistent<C>(
					"a12345678901234567890j");
				s_arr[54] = nvobj::make_persistent<C>(
					"a12345678901234567890klmnopqrst");
				s_arr[55] = nvobj::make_persistent<C>(
					"a12345678901234567890t");
				s_arr[56] = nvobj::make_persistent<C>(
					"a1234567890bcde");
				s_arr[57] = nvobj::make_persistent<C>(
					"a1234567890bcdefghij");
				s_arr[58] = nvobj::make_persistent<C>(
					"a1234567890bcdefghijklmnopqrst");
				s_arr[59] = nvobj::make_persistent<C>(
					"a1234567890cde");
				s_arr[60] = nvobj::make_persistent<C>(
					"a1234567890cdefghij");
				s_arr[61] = nvobj::make_persistent<C>(
					"a1234567890cdefghijklmnopqrst");
				s_arr[62] = nvobj::make_persistent<C>(
					"a1234567890de");
				s_arr[63] = nvobj::make_persistent<C>(
					"a1234567890e");
				s_arr[64] = nvobj::make_persistent<C>(
					"a1234567890fghij");
				s_arr[65] = nvobj::make_persistent<C>(
					"a1234567890j");
				s_arr[66] = nvobj::make_persistent<C>(
					"a1234567890klmnopqrst");
				s_arr[67] = nvobj::make_persistent<C>(
					"a1234567890t");
				s_arr[68] =
					nvobj::make_persistent<C>("a12345bcde");
				s_arr[69] = nvobj::make_persistent<C>(
					"a12345bcdefghij");
				s_arr[70] = nvobj::make_persistent<C>(
					"a12345bcdefghijklmnopqrst");
				s_arr[71] =
					nvobj::make_persistent<C>("a12345cde");
				s_arr[72] = nvobj::make_persistent<C>(
					"a12345cdefghij");
				s_arr[73] = nvobj::make_persistent<C>(
					"a12345cdefghijklmnopqrst");
				s_arr[74] =
					nvobj::make_persistent<C>("a12345de");
				s_arr[75] =
					nvobj::make_persistent<C>("a12345e");
				s_arr[76] = nvobj::make_persistent<C>(
					"a12345fghij");
				s_arr[77] =
					nvobj::make_persistent<C>("a12345j");
				s_arr[78] = nvobj::make_persistent<C>(
					"a12345klmnopqrst");
				s_arr[79] =
					nvobj::make_persistent<C>("a12345t");
				s_arr[80] = nvobj::make_persistent<C>("ab");
				s_arr[81] =
					nvobj::make_persistent<C>("ab12345");
				s_arr[82] = nvobj::make_persistent<C>(
					"ab1234567890");
				s_arr[83] = nvobj::make_persistent<C>(
					"ab12345678901234567890");
				s_arr[84] = nvobj::make_persistent<C>(
					"ab12345678901234567890cde");
				s_arr[85] = nvobj::make_persistent<C>(
					"ab12345678901234567890de");
				s_arr[86] = nvobj::make_persistent<C>(
					"ab12345678901234567890e");
				s_arr[87] = nvobj::make_persistent<C>(
					"ab1234567890cde");
				s_arr[88] = nvobj::make_persistent<C>(
					"ab1234567890de");
				s_arr[89] = nvobj::make_persistent<C>(
					"ab1234567890e");
				s_arr[90] =
					nvobj::make_persistent<C>("ab12345cde");
				s_arr[91] =
					nvobj::make_persistent<C>("ab12345de");
				s_arr[92] =
					nvobj::make_persistent<C>("ab12345e");
				s_arr[93] = nvobj::make_persistent<C>("abcd");
				s_arr[94] =
					nvobj::make_persistent<C>("abcd12345");
				s_arr[95] = nvobj::make_persistent<C>(
					"abcd1234567890");
				s_arr[96] = nvobj::make_persistent<C>(
					"abcd12345678901234567890");
				s_arr[97] = nvobj::make_persistent<C>(
					"abcd12345678901234567890e");
				s_arr[98] = nvobj::make_persistent<C>(
					"abcd1234567890e");
				s_arr[99] =
					nvobj::make_persistent<C>("abcd12345e");
				s_arr[100] = nvobj::make_persistent<C>("abcde");
				s_arr[101] =
					nvobj::make_persistent<C>("abcde12345");
				s_arr[102] = nvobj::make_persistent<C>(
					"abcde1234567890");
				s_arr[103] = nvobj::make_persistent<C>(
					"abcde12345678901234567890");
				s_arr[104] = nvobj::make_persistent<C>(
					"abcde12345678901234567890fghij");
				s_arr[105] = nvobj::make_persistent<C>(
					"abcde12345678901234567890ghij");
				s_arr[106] = nvobj::make_persistent<C>(
					"abcde12345678901234567890hij");
				s_arr[107] = nvobj::make_persistent<C>(
					"abcde12345678901234567890j");
				s_arr[108] = nvobj::make_persistent<C>(
					"abcde1234567890fghij");
				s_arr[109] = nvobj::make_persistent<C>(
					"abcde1234567890ghij");
				s_arr[110] = nvobj::make_persistent<C>(
					"abcde1234567890hij");
				s_arr[111] = nvobj::make_persistent<C>(
					"abcde1234567890j");
				s_arr[112] = nvobj::make_persistent<C>(
					"abcde12345fghij");
				s_arr[113] = nvobj::make_persistent<C>(
					"abcde12345ghij");
				s_arr[114] = nvobj::make_persistent<C>(
					"abcde12345hij");
				s_arr[115] = nvobj::make_persistent<C>(
					"abcde12345j");
				s_arr[116] =
					nvobj::make_persistent<C>("abcdefghi");
				s_arr[117] = nvobj::make_persistent<C>(
					"abcdefghi12345");
				s_arr[118] = nvobj::make_persistent<C>(
					"abcdefghi1234567890");
				s_arr[119] = nvobj::make_persistent<C>(
					"abcdefghi12345678901234567890");
				s_arr[120] = nvobj::make_persistent<C>(
					"abcdefghi12345678901234567890j");
				s_arr[121] = nvobj::make_persistent<C>(
					"abcdefghi1234567890j");
				s_arr[122] = nvobj::make_persistent<C>(
					"abcdefghi12345j");
				s_arr[123] =
					nvobj::make_persistent<C>("abcdefghij");
				s_arr[124] = nvobj::make_persistent<C>(
					"abcdefghij12345");
				s_arr[125] = nvobj::make_persistent<C>(
					"abcdefghij1234567890");
				s_arr[126] = nvobj::make_persistent<C>(
					"abcdefghij12345678901234567890");
				s_arr[127] = nvobj::make_persistent<C>(
					"abcdefghij12345678901234567890klmnopqrst");
				s_arr[128] = nvobj::make_persistent<C>(
					"abcdefghij12345678901234567890lmnopqrst");
				s_arr[129] = nvobj::make_persistent<C>(
					"abcdefghij12345678901234567890pqrst");
				s_arr[130] = nvobj::make_persistent<C>(
					"abcdefghij12345678901234567890t");
				s_arr[131] = nvobj::make_persistent<C>(
					"abcdefghij1234567890klmnopqrst");
				s_arr[132] = nvobj::make_persistent<C>(
					"abcdefghij1234567890lmnopqrst");
				s_arr[133] = nvobj::make_persistent<C>(
					"abcdefghij1234567890pqrst");
				s_arr[134] = nvobj::make_persistent<C>(
					"abcdefghij1234567890t");
				s_arr[135] = nvobj::make_persistent<C>(
					"abcdefghij12345klmnopqrst");
				s_arr[136] = nvobj::make_persistent<C>(
					"abcdefghij12345lmnopqrst");
				s_arr[137] = nvobj::make_persistent<C>(
					"abcdefghij12345pqrst");
				s_arr[138] = nvobj::make_persistent<C>(
					"abcdefghij12345t");
				s_arr[139] = nvobj::make_persistent<C>(
					"abcdefghijklmnopqrs");
				s_arr[140] = nvobj::make_persistent<C>(
					"abcdefghijklmnopqrs12345");
				s_arr[141] = nvobj::make_persistent<C>(
					"abcdefghijklmnopqrs1234567890");
				s_arr[142] = nvobj::make_persistent<C>(
					"abcdefghijklmnopqrs12345678901234567890");
				s_arr[143] = nvobj::make_persistent<C>(
					"abcdefghijklmnopqrs12345678901234567890t");
				s_arr[144] = nvobj::make_persistent<C>(
					"abcdefghijklmnopqrs1234567890t");
				s_arr[145] = nvobj::make_persistent<C>(
					"abcdefghijklmnopqrs12345t");
				s_arr[146] = nvobj::make_persistent<C>(
					"abcdefghijklmnopqrst");
				s_arr[147] = nvobj::make_persistent<C>(
					"abcdefghijklmnopqrst12345");
				s_arr[148] = nvobj::make_persistent<C>(
					"abcdefghijklmnopqrst1234567890");
				s_arr[149] = nvobj::make_persistent<C>(
					"abcdefghijklmnopqrst12345678901234567890");
				s_arr[150] = nvobj::make_persistent<C>(
					"abcdefghijlmnopqrst");
				s_arr[151] = nvobj::make_persistent<C>(
					"abcdefghijpqrst");
				s_arr[152] = nvobj::make_persistent<C>(
					"abcdefghijt");
				s_arr[153] =
					nvobj::make_persistent<C>("abcdeghij");
				s_arr[154] =
					nvobj::make_persistent<C>("abcdehij");
				s_arr[155] =
					nvobj::make_persistent<C>("abcdej");
				s_arr[156] = nvobj::make_persistent<C>("abde");
				s_arr[157] = nvobj::make_persistent<C>("abe");
				s_arr[158] = nvobj::make_persistent<C>("acde");
				s_arr[159] =
					nvobj::make_persistent<C>("acdefghij");
				s_arr[160] = nvobj::make_persistent<C>(
					"acdefghijklmnopqrst");
				s_arr[161] = nvobj::make_persistent<C>("ade");
				s_arr[162] = nvobj::make_persistent<C>("ae");
				s_arr[163] =
					nvobj::make_persistent<C>("afghij");
				s_arr[164] = nvobj::make_persistent<C>("aj");
				s_arr[165] = nvobj::make_persistent<C>(
					"aklmnopqrst");
				s_arr[166] = nvobj::make_persistent<C>("at");
				s_arr[167] = nvobj::make_persistent<C>("bcde");
				s_arr[168] =
					nvobj::make_persistent<C>("bcdefghij");
				s_arr[169] = nvobj::make_persistent<C>(
					"bcdefghijklmnopqrst");
				s_arr[170] = nvobj::make_persistent<C>("cde");
				s_arr[171] = nvobj::make_persistent<C>("e");
				s_arr[172] = nvobj::make_persistent<C>("fghij");
				s_arr[173] = nvobj::make_persistent<C>("j");
				s_arr[174] =
					nvobj::make_persistent<C>("klmnopqrst");
				s_arr[175] = nvobj::make_persistent<C>("t");
			});

			test0<C>(pop);
			test1<C>(pop);
			test2<C>(pop);

			nvobj::transaction::run(pop, [&] {
				for (unsigned i = 0; i < 176; ++i) {
					nvobj::delete_persistent<C>(s_arr[i]);
				}
			});
		} catch (std::exception &e) {
			UT_FATALexc(e);
		}
	}

	pop.close();
}

int
main(int argc, char *argv[])
{
	return run_test([&] { test(argc, argv); });
}

/*
#if TEST_STD_VER > 3
    {   // LWG 2946
    std::string s = "  ";
    s.replace(s.cbegin(), s.cend(), {"abc", 1});
    assert(s.size() == 1);
    assert(s == "a");
    }
#endif
}
*/