@@ -291,3 +291,201 @@ TEST(ProtocolTypesTest, Capabilities) {
291
291
EXPECT_EQ (capabilities.lldbExtVersion ,
292
292
deserialized_capabilities->lldbExtVersion );
293
293
}
294
+
295
+ TEST (ProtocolTypesTest, PresentationHint) {
296
+ // Test all PresentationHint values.
297
+ std::vector<std::pair<PresentationHint, llvm::StringRef>> test_cases = {
298
+ {ePresentationHintNormal, " normal" },
299
+ {ePresentationHintEmphasize, " emphasize" },
300
+ {ePresentationHintDeemphasize, " deemphasize" }};
301
+
302
+ for (const auto &test_case : test_cases) {
303
+ // Serialize the PresentationHint to JSON.
304
+ llvm::json::Value serialized = toJSON (test_case.first );
305
+ ASSERT_EQ (serialized.kind (), llvm::json::Value::Kind::String);
306
+ EXPECT_EQ (serialized.getAsString (), test_case.second );
307
+
308
+ // Deserialize the JSON back to PresentationHint.
309
+ PresentationHint deserialized;
310
+ llvm::json::Path::Root root;
311
+ ASSERT_TRUE (fromJSON (serialized, deserialized, root))
312
+ << llvm::toString (root.getError ());
313
+ EXPECT_EQ (deserialized, test_case.first );
314
+ }
315
+
316
+ // Test invalid value.
317
+ llvm::json::Value invalid_value = " invalid_hint" ;
318
+ PresentationHint deserialized_invalid;
319
+ llvm::json::Path::Root root;
320
+ EXPECT_FALSE (fromJSON (invalid_value, deserialized_invalid, root));
321
+ }
322
+
323
+ TEST (ProtocolTypesTest, SteppingGranularity) {
324
+ // Test all SteppingGranularity values.
325
+ std::vector<std::pair<SteppingGranularity, llvm::StringRef>> test_cases = {
326
+ {eSteppingGranularityStatement, " statement" },
327
+ {eSteppingGranularityLine, " line" },
328
+ {eSteppingGranularityInstruction, " instruction" }};
329
+
330
+ for (const auto &test_case : test_cases) {
331
+ // Serialize the SteppingGranularity to JSON.
332
+ llvm::json::Value serialized = toJSON (test_case.first );
333
+ ASSERT_EQ (serialized.kind (), llvm::json::Value::Kind::String);
334
+ EXPECT_EQ (serialized.getAsString (), test_case.second );
335
+
336
+ // Deserialize the JSON back to SteppingGranularity.
337
+ SteppingGranularity deserialized;
338
+ llvm::json::Path::Root root;
339
+ ASSERT_TRUE (fromJSON (serialized, deserialized, root))
340
+ << llvm::toString (root.getError ());
341
+ EXPECT_EQ (deserialized, test_case.first );
342
+ }
343
+
344
+ // Test invalid value.
345
+ llvm::json::Value invalid_value = " invalid_granularity" ;
346
+ SteppingGranularity deserialized_invalid;
347
+ llvm::json::Path::Root root;
348
+ EXPECT_FALSE (fromJSON (invalid_value, deserialized_invalid, root));
349
+ }
350
+
351
+ TEST (ProtocolTypesTest, BreakpointReason) {
352
+ // Test all BreakpointReason values.
353
+ std::vector<std::pair<BreakpointReason, llvm::StringRef>> test_cases = {
354
+ {BreakpointReason::eBreakpointReasonPending, " pending" },
355
+ {BreakpointReason::eBreakpointReasonFailed, " failed" }};
356
+
357
+ for (const auto &test_case : test_cases) {
358
+ // Serialize the BreakpointReason to JSON.
359
+ llvm::json::Value serialized = toJSON (test_case.first );
360
+ ASSERT_EQ (serialized.kind (), llvm::json::Value::Kind::String);
361
+ EXPECT_EQ (serialized.getAsString (), test_case.second );
362
+
363
+ // Deserialize the JSON back to BreakpointReason.
364
+ BreakpointReason deserialized;
365
+ llvm::json::Path::Root root;
366
+ ASSERT_TRUE (fromJSON (serialized, deserialized, root))
367
+ << llvm::toString (root.getError ());
368
+ EXPECT_EQ (deserialized, test_case.first );
369
+ }
370
+
371
+ // Test invalid value.
372
+ llvm::json::Value invalid_value = " invalid_reason" ;
373
+ BreakpointReason deserialized_invalid;
374
+ llvm::json::Path::Root root;
375
+ EXPECT_FALSE (fromJSON (invalid_value, deserialized_invalid, root));
376
+ }
377
+
378
+ TEST (ProtocolTypesTest, DataBreakpointAccessType) {
379
+ // Test all DataBreakpointAccessType values.
380
+ std::vector<std::pair<DataBreakpointAccessType, llvm::StringRef>> test_cases =
381
+ {{eDataBreakpointAccessTypeRead, " read" },
382
+ {eDataBreakpointAccessTypeWrite, " write" },
383
+ {eDataBreakpointAccessTypeReadWrite, " readWrite" }};
384
+
385
+ for (const auto &test_case : test_cases) {
386
+ // Serialize the DataBreakpointAccessType to JSON.
387
+ llvm::json::Value serialized = toJSON (test_case.first );
388
+ ASSERT_EQ (serialized.kind (), llvm::json::Value::Kind::String);
389
+ EXPECT_EQ (serialized.getAsString (), test_case.second );
390
+
391
+ // Deserialize the JSON back to DataBreakpointAccessType.
392
+ DataBreakpointAccessType deserialized;
393
+ llvm::json::Path::Root root;
394
+ ASSERT_TRUE (fromJSON (serialized, deserialized, root))
395
+ << llvm::toString (root.getError ());
396
+ EXPECT_EQ (deserialized, test_case.first );
397
+ }
398
+
399
+ // Test invalid value
400
+ llvm::json::Value invalid_value = " invalid_access_type" ;
401
+ DataBreakpointAccessType deserialized_invalid;
402
+ llvm::json::Path::Root root;
403
+ EXPECT_FALSE (fromJSON (invalid_value, deserialized_invalid, root));
404
+ }
405
+
406
+ TEST (ProtocolTypesTest, ColumnType) {
407
+ // Test all ColumnType values.
408
+ std::vector<std::pair<ColumnType, llvm::StringRef>> test_cases = {
409
+ {eColumnTypeString, " string" },
410
+ {eColumnTypeNumber, " number" },
411
+ {eColumnTypeBoolean, " boolean" },
412
+ {eColumnTypeTimestamp, " unixTimestampUTC" }};
413
+
414
+ for (const auto &test_case : test_cases) {
415
+ // Serialize the ColumnType to JSON.
416
+ llvm::json::Value serialized = toJSON (test_case.first );
417
+ ASSERT_EQ (serialized.kind (), llvm::json::Value::Kind::String);
418
+ EXPECT_EQ (serialized.getAsString (), test_case.second );
419
+
420
+ // Deserialize the JSON back to ColumnType.
421
+ ColumnType deserialized;
422
+ llvm::json::Path::Root root;
423
+ ASSERT_TRUE (fromJSON (serialized, deserialized, root))
424
+ << llvm::toString (root.getError ());
425
+ EXPECT_EQ (deserialized, test_case.first );
426
+ }
427
+
428
+ // Test invalid value.
429
+ llvm::json::Value invalid_value = " invalid_column_type" ;
430
+ ColumnType deserialized_invalid;
431
+ llvm::json::Path::Root root;
432
+ EXPECT_FALSE (fromJSON (invalid_value, deserialized_invalid, root));
433
+ }
434
+
435
+ TEST (ProtocolTypesTest, BreakpointModeApplicability) {
436
+ // Test all BreakpointModeApplicability values.
437
+ std::vector<std::pair<BreakpointModeApplicability, llvm::StringRef>>
438
+ test_cases = {{eBreakpointModeApplicabilitySource, " source" },
439
+ {eBreakpointModeApplicabilityException, " exception" },
440
+ {eBreakpointModeApplicabilityData, " data" },
441
+ {eBreakpointModeApplicabilityInstruction, " instruction" }};
442
+
443
+ for (const auto &test_case : test_cases) {
444
+ // Serialize the BreakpointModeApplicability to JSON.
445
+ llvm::json::Value serialized = toJSON (test_case.first );
446
+ ASSERT_EQ (serialized.kind (), llvm::json::Value::Kind::String);
447
+ EXPECT_EQ (serialized.getAsString (), test_case.second );
448
+
449
+ // Deserialize the JSON back to BreakpointModeApplicability.
450
+ BreakpointModeApplicability deserialized;
451
+ llvm::json::Path::Root root;
452
+ ASSERT_TRUE (fromJSON (serialized, deserialized, root))
453
+ << llvm::toString (root.getError ());
454
+ EXPECT_EQ (deserialized, test_case.first );
455
+ }
456
+
457
+ // Test invalid value.
458
+ llvm::json::Value invalid_value = " invalid_applicability" ;
459
+ BreakpointModeApplicability deserialized_invalid;
460
+ llvm::json::Path::Root root;
461
+ EXPECT_FALSE (fromJSON (invalid_value, deserialized_invalid, root));
462
+ }
463
+
464
+ TEST (ProtocolTypesTest, ChecksumAlgorithm) {
465
+ // Test all ChecksumAlgorithm values.
466
+ std::vector<std::pair<ChecksumAlgorithm, llvm::StringRef>> test_cases = {
467
+ {eChecksumAlgorithmMD5, " MD5" },
468
+ {eChecksumAlgorithmSHA1, " SHA1" },
469
+ {eChecksumAlgorithmSHA256, " SHA256" },
470
+ {eChecksumAlgorithmTimestamp, " timestamp" }};
471
+
472
+ for (const auto &test_case : test_cases) {
473
+ // Serialize the ChecksumAlgorithm to JSON.
474
+ llvm::json::Value serialized = toJSON (test_case.first );
475
+ ASSERT_EQ (serialized.kind (), llvm::json::Value::Kind::String);
476
+ EXPECT_EQ (serialized.getAsString (), test_case.second );
477
+
478
+ // Deserialize the JSON back to ChecksumAlgorithm.
479
+ ChecksumAlgorithm deserialized;
480
+ llvm::json::Path::Root root;
481
+ ASSERT_TRUE (fromJSON (serialized, deserialized, root))
482
+ << llvm::toString (root.getError ());
483
+ EXPECT_EQ (deserialized, test_case.first );
484
+ }
485
+
486
+ // Test invalid value.
487
+ llvm::json::Value invalid_value = " invalid_algorithm" ;
488
+ ChecksumAlgorithm deserialized_invalid;
489
+ llvm::json::Path::Root root;
490
+ EXPECT_FALSE (fromJSON (invalid_value, deserialized_invalid, root));
491
+ }
0 commit comments