• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

polserver / polserver / 25972182398

16 May 2026 08:30PM UTC coverage: 60.836% (-0.07%) from 60.903%
25972182398

Pull #884

github

turleypol
updated dynproperties
Pull Request #884: Attackable item

241 of 527 new or added lines in 26 files covered. (45.73%)

17 existing lines in 7 files now uncovered.

44729 of 73524 relevant lines covered (60.84%)

446850.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

74.82
/pol-core/pol/testing/testmisc.cpp
1
/** @file
2
 *
3
 * @par History
4
 */
5

6
#include <algorithm>
7
#include <array>
8
#include <cstring>
9
#include <limits>
10
#include <string>
11
#include <string_view>
12

13
#include "../../clib/boostutils.h"
14
#include "../../clib/logfacility.h"
15
#include "../../clib/maputil.h"
16
#include "../../clib/rawtypes.h"
17
#include "../../plib/maptile.h"
18
#include "../dynproperties.h"
19
#include "../globals/uvars.h"
20
#include "../network/packethelper.h"
21
#include "../realms/realm.h"
22
#include "testenv.h"
23

24
#include <curl/curl.h>
25
#include <type_traits>
26

27

28
namespace Pol::Testing
29
{
30
void dummy() {}
×
31

32
void map_test()
×
33
{
34
  Plib::MAPTILE_CELL cell = Core::gamestate.main_realm->getmaptile( Core::Pos2d( 1453, 1794 ) );
×
35
  INFO_PRINTLN( "{} {}", cell.landtile, cell.z );
×
36
}
×
37

38
void dynprops_test()
1✔
39
{
40
  struct VecTest
41
  {
42
    bool test = false;
43
  };
44

45
  int i = 1;
1✔
46
  class Test : public Core::DynamicPropsHolder
47
  {
48
  public:
49
    DYN_PROPERTY( armod, s16, Core::PROP_AR_MOD, 0 );
8✔
50
    DYN_PROPERTY( max_items, u32, Core::PROP_MAX_ITEMS_MOD, 0 );
51
    DYN_PROPERTY( itemname, std::string, Core::PROP_NAME_SUFFIX, "" );
8✔
52
    DYN_PROPERTY_POINTER( pointer, int*, Core::PROP_GUILD );
7✔
53
    DYN_PROPERTY_REF( vec, std::vector<VecTest>, Core::PROP_PROCESS, std::vector<VecTest>{} );
9✔
54
  };
55
  Test h;
1✔
56
  if ( h.armod() || h.has_armod() )
1✔
57
  {
58
    INFO_PRINTLN( "initial ar {} {}", h.armod(), h.has_armod() );
×
59
    UnitTest::inc_failures();
×
60
  }
61
  else
62
    UnitTest::inc_successes();
1✔
63
  h.armod( 10 );
1✔
64
  if ( h.armod() != 10 || !h.has_armod() )
1✔
65
  {
66
    INFO_PRINTLN( "ar {} {}", h.armod(), h.has_armod() );
×
67
    UnitTest::inc_failures();
×
68
  }
69
  else
70
    UnitTest::inc_successes();
1✔
71
  h.armod( 0 );
1✔
72
  if ( h.armod() || h.has_armod() )
1✔
73
  {
74
    INFO_PRINTLN( "removed ar {} {}", h.armod(), h.has_armod() );
×
75
    UnitTest::inc_failures();
×
76
  }
77
  else
78
    UnitTest::inc_successes();
1✔
79

80
  if ( !h.itemname().empty() || h.has_itemname() )
1✔
81
  {
82
    INFO_PRINTLN( "initial name {} {}", h.itemname(), h.has_itemname() );
×
83
    UnitTest::inc_failures();
×
84
  }
85
  else
86
    UnitTest::inc_successes();
1✔
87
  h.itemname( "hello world" );
1✔
88
  if ( h.itemname() != "hello world" || !h.has_itemname() )
1✔
89
  {
90
    INFO_PRINTLN( "name {} {}", h.itemname(), h.has_itemname() );
×
91
    UnitTest::inc_failures();
×
92
  }
93
  else
94
    UnitTest::inc_successes();
1✔
95
  h.itemname( "" );
1✔
96
  if ( !h.itemname().empty() || h.has_itemname() )
1✔
97
  {
98
    INFO_PRINTLN( "removed name {} {}", h.itemname(), h.has_itemname() );
×
99
    UnitTest::inc_failures();
×
100
  }
101
  else
102
    UnitTest::inc_successes();
1✔
103

104
  if ( h.has_pointer() )
1✔
105
  {
NEW
106
    INFO_PRINTLN( "pointer set" );
×
NEW
107
    UnitTest::inc_failures();
×
108
  }
109
  else
110
    UnitTest::inc_successes();
1✔
111

112
  h.pointer( &i );
1✔
113
  if ( !h.has_pointer() )
1✔
114
  {
NEW
115
    INFO_PRINTLN( "pointer not set" );
×
NEW
116
    UnitTest::inc_failures();
×
117
  }
118
  else
119
    UnitTest::inc_successes();
1✔
120
  if ( h.pointer() != &i )
1✔
121
  {
NEW
122
    INFO_PRINTLN( "pointer set wrong" );
×
NEW
123
    UnitTest::inc_failures();
×
124
  }
125
  else
126
    UnitTest::inc_successes();
1✔
127
  h.pointer( nullptr );
1✔
128
  if ( h.pointer() != nullptr )
1✔
129
  {
NEW
130
    INFO_PRINTLN( "pointer != nullptr" );
×
NEW
131
    UnitTest::inc_failures();
×
132
  }
133
  else
134
    UnitTest::inc_successes();
1✔
135
  if ( h.has_pointer() )
1✔
136
  {
NEW
137
    INFO_PRINTLN( "pointer not cleared" );
×
NEW
138
    UnitTest::inc_failures();
×
139
  }
140
  else
141
    UnitTest::inc_successes();
1✔
142

143
  if ( h.has_vec() )
1✔
144
  {
NEW
145
    INFO_PRINTLN( "testvec set" );
×
NEW
146
    UnitTest::inc_failures();
×
147
  }
148
  else
149
    UnitTest::inc_successes();
1✔
150
  if ( !h.vec()->empty() )
1✔
151
  {
NEW
152
    INFO_PRINTLN( "testvec not empty" );
×
NEW
153
    UnitTest::inc_failures();
×
154
  }
155
  else
156
    UnitTest::inc_successes();
1✔
157
  h.vec()->push_back( VecTest{ true } );
1✔
158
  if ( h.vec()->empty() )
1✔
159
  {
NEW
160
    INFO_PRINTLN( "testvec empty" );
×
NEW
161
    UnitTest::inc_failures();
×
162
  }
163
  else
164
    UnitTest::inc_successes();
1✔
165
  if ( !h.vec()->begin()->test )
1✔
166
  {
NEW
167
    INFO_PRINTLN( "testvec value false" );
×
NEW
168
    UnitTest::inc_failures();
×
169
  }
170
  else
171
    UnitTest::inc_successes();
1✔
172
  if ( !( *h.vec() )[0].test )
1✔
173
  {
NEW
174
    INFO_PRINTLN( "testvec value false" );
×
NEW
175
    UnitTest::inc_failures();
×
176
  }
177
  else
178
    UnitTest::inc_successes();
1✔
179
  if ( []( const auto& o ) { return o.vec()->empty(); }( h ) )
2✔
180
  {
NEW
181
    INFO_PRINTLN( "testvec const !empty" );
×
NEW
182
    UnitTest::inc_failures();
×
183
  }
184
  else
185
    UnitTest::inc_successes();
1✔
186
  h.clear_vec();
1✔
187
  if ( h.has_vec() )
1✔
188
  {
NEW
189
    INFO_PRINTLN( "testvec not cleared" );
×
NEW
190
    UnitTest::inc_failures();
×
191
  }
192
  else
193
    UnitTest::inc_successes();
1✔
194
}
1✔
195

196
void packet_test()
1✔
197
{
198
  using namespace Network;
199
  using namespace Network::PktHelper;
200
  auto debug = []( const PacketOut<PktOut_2F>& p )
×
201
  {
202
    std::string w;
×
203
    for ( auto& c : p->buffer )
×
204
    {
205
      w += fmt::format( "{:x} ", c );
×
206
    }
207
    INFO_PRINTLN( w );
×
208
  };
×
209
  auto test = [&]( const PacketOut<PktOut_2F>& p, const std::array<s8, 10>& a )
5✔
210
  {
211
    if ( std::equal( std::begin( p->buffer ), std::end( p->buffer ), std::begin( a ) ) )
5✔
212
      UnitTest::inc_successes();
5✔
213
    else
214
    {
215
      UnitTest::inc_failures();
×
216
      INFO_PRINTLN( "failed" );
×
217
      debug( p );
×
218
      std::string w;
×
219
      for ( auto& c : a )
×
220
      {
221
        w += fmt::format( "{:x} ", c );
×
222
      }
223
      INFO_PRINTLN( w );
×
224
    }
×
225
  };
5✔
226
  {
227
    PacketOut<PktOut_2F> p;  // size 10
1✔
228
    p->Write<s8>( 0x12 );
1✔
229
    p->Write<u8>( 0x21u );
1✔
230
    p->WriteFlipped<s8>( 0x12 );
1✔
231
    p->WriteFlipped<u8>( 0x21u );
1✔
232
    p->Write<u8>( 0u );
1✔
233
    std::array<s8, 10> a{ { 0x2f, 0x12, 0x21, 0x12, 0x21, 0, 0, 0, 0, 0 } };
1✔
234
    test( p, a );
1✔
235
  }
1✔
236
  {
237
    PacketOut<PktOut_2F> p;  // size 10
1✔
238
    p->Write<s16>( 0x1234 );
1✔
239
    p->Write<u16>( 0x4321u );
1✔
240
    p->WriteFlipped<s16>( 0x1234 );
1✔
241
    p->WriteFlipped<u16>( 0x4321u );
1✔
242
    p->Write<u8>( 0u );
1✔
243
    std::array<s8, 10> a{ { 0x2f, 0x34, 0x12, 0x21, 0x43, 0x12, 0x34, 0x43, 0x21, 0 } };
1✔
244
    test( p, a );
1✔
245
  }
1✔
246
  {
247
    PacketOut<PktOut_2F> p;  // size 10
1✔
248
    p->Write<s32>( 0x12344321 );
1✔
249
    p->Write<u32>( 0x12344321u );
1✔
250
    p->Write<u8>( 0u );
1✔
251
    std::array<s8, 10> a{ { 0x2f, 0x21, 0x43, 0x34, 0x12, 0x21, 0x43, 0x34, 0x12, 0 } };
1✔
252
    test( p, a );
1✔
253
  }
1✔
254
  {
255
    PacketOut<PktOut_2F> p;  // size 10
1✔
256
    p->WriteFlipped<s32>( 0x12344321 );
1✔
257
    p->WriteFlipped<u32>( 0x12344321u );
1✔
258
    p->Write<u8>( 0u );
1✔
259
    std::array<s8, 10> a{ { 0x2f, 0x12, 0x34, 0x43, 0x21, 0x12, 0x34, 0x43, 0x21, 0 } };
1✔
260
    test( p, a );
1✔
261
  }
1✔
262
  {
263
    PacketOut<PktOut_2F> p;  // size 10
1✔
264
    std::string s( "1234" );
1✔
265
    p->Write( s.c_str(), 4, false );
1✔
266
    u8 b[] = { 0x12, 0x34, 0x43, 0x21 };
1✔
267
    p->Write( b, 4 );
1✔
268
    p->Write<u8>( 0u );
1✔
269
    std::array<s8, 10> a{ { 0x2f, 0x31, 0x32, 0x33, 0x34, 0x12, 0x34, 0x43, 0x21, 0 } };
1✔
270
    test( p, a );
1✔
271
  }
1✔
272
}
1✔
273

274
void test_splitnamevalue( const std::string& istr, const std::string& exp_pn,
11✔
275
                          const std::string& exp_pv )
276
{
277
  std::string pn, pv;
11✔
278
  Clib::splitnamevalue( istr, pn, pv );
11✔
279
  if ( pn != exp_pn || pv != exp_pv )
11✔
280
  {
281
    INFO_PRINTLN( "splitnamevalue( \"{}\" ) fails!", istr );
×
282
    UnitTest::inc_failures();
×
283
  }
284
  else
285
    UnitTest::inc_successes();
11✔
286
}
11✔
287

288
void test_splitnamevalue()
1✔
289
{
290
  test_splitnamevalue( "a b", "a", "b" );
1✔
291
  test_splitnamevalue( "av bx", "av", "bx" );
1✔
292
  test_splitnamevalue( "nm=valu", "nm", "valu" );
1✔
293
  test_splitnamevalue( "nm:valu", "nm:valu", "" );
1✔
294
  test_splitnamevalue( "nm", "nm", "" );
1✔
295
  test_splitnamevalue( "  nm", "nm", "" );
1✔
296
  test_splitnamevalue( "  nm  ", "nm", "" );
1✔
297
  test_splitnamevalue( "  nm valu", "nm", "valu" );
1✔
298
  test_splitnamevalue( "  nm   value   ", "nm", "value" );
1✔
299
  test_splitnamevalue( "  nm  value is multiple words", "nm", "value is multiple words" );
1✔
300
  test_splitnamevalue( "  nm  value is multiple words\t ", "nm", "value is multiple words" );
1✔
301
}
1✔
302

303
void test_dqs( const std::string& in, const std::string& out )
4✔
304
{
305
  std::string tmp = in;
4✔
306
  Clib::decodequotedstring( tmp );
4✔
307
  if ( tmp != out )
4✔
308
  {
309
    INFO_PRINTLN( "decodequotedstring( {} ) fails!", in );
×
310
    UnitTest::inc_failures();
×
311
  }
312
  else
313
    UnitTest::inc_successes();
4✔
314

315
  Clib::encodequotedstring( tmp );
4✔
316
  if ( tmp != in )
4✔
317
  {
318
    INFO_PRINTLN( "encodequotedstring( {} ) fails!", out );
×
319
    UnitTest::inc_failures();
×
320
  }
321
  else
322
    UnitTest::inc_successes();
4✔
323
}
4✔
324

325
void test_convertquotedstring()
1✔
326
{
327
  test_dqs( "\"hi\"", "hi" );
1✔
328
  test_dqs( "\"hi \"", "hi " );
1✔
329
  test_dqs( "\" hi \"", " hi " );
1✔
330
  test_dqs( "\" \\\"hi\"", " \"hi" );
1✔
331
}
1✔
332

333
void test_sanitizeUnicodeWithIso()
1✔
334
{
335
  std::string input;
1✔
336
  std::string output;
1✔
337
  std::string expected;
1✔
338

339
  input = "Some weird characters: \xC3 \xD0 \xA9.";
1✔
340
  output = std::string( input );
1✔
341
  expected = "Some weird characters: Ã Ð ©.";
1✔
342
  Clib::sanitizeUnicodeWithIso( &output );
1✔
343
  if ( output != expected )
1✔
344
  {
345
    INFO_PRINTLN(
×
346
        "sanitizeUnicodeWithIso fails!\n"
347
        "\tinput:    {}\n"
348
        "\toutput:   {}\n"
349
        "\texpected: {}",
350
        input, output, expected );
351
    UnitTest::inc_failures();
×
352
  }
353
  else
354
    UnitTest::inc_successes();
1✔
355

356
  input = "Maybe someone just wants to say \xC3\xA4. Well, that is probably an acceptable loss.";
1✔
357
  output = std::string( input );
1✔
358
  expected = "Maybe someone just wants to say ä. Well, that is probably an acceptable loss.";
1✔
359
  Clib::sanitizeUnicodeWithIso( &output );
1✔
360
  if ( output != expected )
1✔
361
  {
362
    INFO_PRINTLN(
×
363
        "sanitizeUnicodeWithIso fails!\n"
364
        "\tinput:    {}\n"
365
        "\toutput:   {}\n"
366
        "\texpected: {}",
367
        input, output, expected );
368
    UnitTest::inc_failures();
×
369
  }
370
  else
371
    UnitTest::inc_successes();
1✔
372
}
1✔
373

374
void test_cp1252ToUtf8( const std::string& in, const std::string& expected )
1✔
375
{
376
  std::string converted = Clib::strCp1252ToUtf8( in );
1✔
377
  if ( converted != expected )
1✔
378
  {
379
    INFO_PRINTLN( "CP-1252 to UTF-8 conversion fails!" );
×
380
    UnitTest::inc_failures();
×
381
  }
382
  else
383
  {
384
    UnitTest::inc_successes();
1✔
385
  }
386
}
1✔
387

388
void test_utf8ToCp1252( const std::string& in, const std::string& expected )
1✔
389
{
390
  std::string converted = Clib::strUtf8ToCp1252( in );
1✔
391
  if ( converted != expected )
1✔
392
  {
393
    INFO_PRINTLN( "UTF-8 to CP-1252 conversion fails!" );
×
394
    UnitTest::inc_failures();
×
395
  }
396
  else
397
  {
398
    UnitTest::inc_successes();
1✔
399
  }
400
}
1✔
401

402
void test_encodingconversions()
1✔
403
{
404
  // All non-control characters in cp1252
405
  const unsigned char cp1252data[] = {
1✔
406
      0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
407
      0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e,
408
      0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d,
409
      0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c,
410
      0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
411
      0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
412
      0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a,
413
      0x8b, 0x8c, 0x8e, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c,
414
      0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac,
415
      0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb,
416
      0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca,
417
      0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9,
418
      0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8,
419
      0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
420
      0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff };
421

422
  // The same characters as above but encoded in UTF-8
423
  const unsigned char utf8data[] = {
1✔
424
      0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
425
      0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e,
426
      0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d,
427
      0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c,
428
      0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
429
      0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
430
      0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0xe2, 0x82, 0xac, 0xe2, 0x80, 0x9a, 0xc6, 0x92, 0xe2, 0x80,
431
      0x9e, 0xe2, 0x80, 0xa6, 0xe2, 0x80, 0xa0, 0xe2, 0x80, 0xa1, 0xcb, 0x86, 0xe2, 0x80, 0xb0,
432
      0xc5, 0xa0, 0xe2, 0x80, 0xb9, 0xc5, 0x92, 0xc5, 0xbd, 0xe2, 0x80, 0x98, 0xe2, 0x80, 0x99,
433
      0xe2, 0x80, 0x9c, 0xe2, 0x80, 0x9d, 0xe2, 0x80, 0xa2, 0xe2, 0x80, 0x93, 0xe2, 0x80, 0x94,
434
      0xcb, 0x9c, 0xe2, 0x84, 0xa2, 0xc5, 0xa1, 0xe2, 0x80, 0xba, 0xc5, 0x93, 0xc5, 0xbe, 0xc5,
435
      0xb8, 0xc2, 0xa0, 0xc2, 0xa1, 0xc2, 0xa2, 0xc2, 0xa3, 0xc2, 0xa4, 0xc2, 0xa5, 0xc2, 0xa6,
436
      0xc2, 0xa7, 0xc2, 0xa8, 0xc2, 0xa9, 0xc2, 0xaa, 0xc2, 0xab, 0xc2, 0xac, 0xc2, 0xad, 0xc2,
437
      0xae, 0xc2, 0xaf, 0xc2, 0xb0, 0xc2, 0xb1, 0xc2, 0xb2, 0xc2, 0xb3, 0xc2, 0xb4, 0xc2, 0xb5,
438
      0xc2, 0xb6, 0xc2, 0xb7, 0xc2, 0xb8, 0xc2, 0xb9, 0xc2, 0xba, 0xc2, 0xbb, 0xc2, 0xbc, 0xc2,
439
      0xbd, 0xc2, 0xbe, 0xc2, 0xbf, 0xc3, 0x80, 0xc3, 0x81, 0xc3, 0x82, 0xc3, 0x83, 0xc3, 0x84,
440
      0xc3, 0x85, 0xc3, 0x86, 0xc3, 0x87, 0xc3, 0x88, 0xc3, 0x89, 0xc3, 0x8a, 0xc3, 0x8b, 0xc3,
441
      0x8c, 0xc3, 0x8d, 0xc3, 0x8e, 0xc3, 0x8f, 0xc3, 0x90, 0xc3, 0x91, 0xc3, 0x92, 0xc3, 0x93,
442
      0xc3, 0x94, 0xc3, 0x95, 0xc3, 0x96, 0xc3, 0x97, 0xc3, 0x98, 0xc3, 0x99, 0xc3, 0x9a, 0xc3,
443
      0x9b, 0xc3, 0x9c, 0xc3, 0x9d, 0xc3, 0x9e, 0xc3, 0x9f, 0xc3, 0xa0, 0xc3, 0xa1, 0xc3, 0xa2,
444
      0xc3, 0xa3, 0xc3, 0xa4, 0xc3, 0xa5, 0xc3, 0xa6, 0xc3, 0xa7, 0xc3, 0xa8, 0xc3, 0xa9, 0xc3,
445
      0xaa, 0xc3, 0xab, 0xc3, 0xac, 0xc3, 0xad, 0xc3, 0xae, 0xc3, 0xaf, 0xc3, 0xb0, 0xc3, 0xb1,
446
      0xc3, 0xb2, 0xc3, 0xb3, 0xc3, 0xb4, 0xc3, 0xb5, 0xc3, 0xb6, 0xc3, 0xb7, 0xc3, 0xb8, 0xc3,
447
      0xb9, 0xc3, 0xba, 0xc3, 0xbb, 0xc3, 0xbc, 0xc3, 0xbd, 0xc3, 0xbe, 0xc3, 0xbf };
448

449
  std::string cp1252string( reinterpret_cast<const char*>( cp1252data ), sizeof( cp1252data ) );
1✔
450
  std::string utf8string( reinterpret_cast<const char*>( utf8data ), sizeof( utf8data ) );
1✔
451

452
  test_cp1252ToUtf8( cp1252string, utf8string );
1✔
453
  test_utf8ToCp1252( utf8string, cp1252string );
1✔
454
}
1✔
455

456
void test_curlfeatures()
1✔
457
{
458
  bool http{ false };
1✔
459
  bool https{ false };
1✔
460
  curl_version_info_data* data = curl_version_info( CURLVERSION_NOW );
1✔
461
  for ( int i = 0; data->protocols[i]; ++i )
23✔
462
  {
463
    INFO_PRINT( "{} ", data->protocols[i] );
22✔
464
    if ( std::string( data->protocols[i] ) == "https" )
22✔
465
      https = true;
1✔
466
    else if ( std::string( data->protocols[i] ) == "http" )
21✔
467
      http = true;
1✔
468
  }
469
  INFO_PRINTLN( "" );
1✔
470
  if ( !https || !http )
1✔
471
  {
472
    INFO_PRINTLN( "http(s) is not supported" );
×
473
    UnitTest::inc_failures();
×
474
  }
475
  else
476
    UnitTest::inc_successes();
1✔
477
}
1✔
478

479
void caseinsensitive_compare_test()
1✔
480
{
481
  using namespace std::literals;
482
  auto less_cmp = std::less<std::string_view>{};
483
  auto icase_cmp = Clib::ci_cmp_pred{};
484

485
  UnitTest( [&]() { return icase_cmp( "test"sv, "test"sv ); }, less_cmp( "test"sv, "test"sv ),
2✔
486
            "test_sv < test_sv" );
2✔
487

488
  UnitTest( [&]() { return icase_cmp( "test1"sv, "test"sv ); }, less_cmp( "test1"sv, "test"sv ),
2✔
489
            "test1_sv < test_sv" );
2✔
490
  UnitTest( [&]() { return icase_cmp( "test"sv, "test1"sv ); }, less_cmp( "test"sv, "test1"sv ),
2✔
491
            "test_sv < test1_sv" );
2✔
492

493
  UnitTest( [&]() { return icase_cmp( "Test"sv, "test"sv ); }, less_cmp( "test"sv, "test"sv ),
2✔
494
            "Test_sv < test_sv" );
2✔
495
  UnitTest( [&]() { return icase_cmp( "test"sv, "Test"sv ); }, less_cmp( "test"sv, "test"sv ),
2✔
496
            "test_sv < Test_sv" );
2✔
497

498
  UnitTest( [&]() { return icase_cmp( "a test"sv, "test"sv ); }, less_cmp( "a test"sv, "test"sv ),
2✔
499
            "a test_sv < test_sv" );
2✔
500
  UnitTest( [&]() { return icase_cmp( "test"sv, "a test"sv ); }, less_cmp( "test"sv, "a test"sv ),
2✔
501
            "test_sv < a test_sv" );
2✔
502

503
  UnitTest( [&]() { return icase_cmp( "tes1"sv, "test"sv ); }, less_cmp( "tes1"sv, "test"sv ),
2✔
504
            "tes1_sv < test_sv" );
2✔
505
  UnitTest( [&]() { return icase_cmp( "test"sv, "tes1"sv ); }, less_cmp( "test"sv, "tes1"sv ),
2✔
506
            "test_sv < tes1_sv" );
2✔
507

508
  UnitTest( [&]() { return icase_cmp( "test"s, "test"s ); }, less_cmp( "test"sv, "test"sv ),
2✔
509
            "test_s < test_s" );
2✔
510
  UnitTest( [&]() { return icase_cmp( "test", "test" ); }, less_cmp( "test"sv, "test"sv ),
2✔
511
            "test < test" );
2✔
512
  UnitTest(
1✔
513
      [&]()
1✔
514
      {
515
        return icase_cmp( boost_utils::script_name_flystring{ "test" },
2✔
516
                          boost_utils::script_name_flystring{ "test" } );
3✔
517
      },
518
      less_cmp( "test"sv, "test"sv ), "test_boost < test_boost" );
2✔
519
}
1✔
520
}  // namespace Pol::Testing
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc