Skip to content

Commit 03e0efb

Browse files
committed
[test] Update attribute manager tests
1 parent 336d9f8 commit 03e0efb

File tree

1 file changed

+36
-35
lines changed

1 file changed

+36
-35
lines changed

Tests/AttributeManagerTests.cpp

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <SheenBidi/SBBase.h>
2424

2525
extern "C" {
26+
#include <Source/AttributeDictionary.h>
2627
#include <Source/AttributeManager.h>
2728
#include "Source/SBAttributeRegistry.h"
2829
#include <Source/SBText.h>
@@ -402,25 +403,25 @@ void AttributeManagerTests::testGetRunByIDBasic() {
402403
// Set attribute on first half
403404
SBTextSetAttribute(text, 0, 5, colorID, Color::purple());
404405

405-
AttributeItemList outputItems;
406-
ListInitialize(&outputItems, sizeof(SBAttributeItem));
406+
AttributeDictionary output;
407+
AttributeDictionaryInitialize(&output, nullptr);
407408

408409
SBUInteger startIndex = 0;
409410
SBUInteger endIndex = 10;
410411

411412
// First run (0-4 with color)
412413
assert(AttributeManagerGetOnwardRunByFilteringID(manager,
413-
&startIndex, endIndex, colorID, &outputItems));
414-
assert(outputItems.count == 1);
414+
&startIndex, endIndex, colorID, &output));
415+
assert(output._list.count == 1);
415416
assert(startIndex == 5);
416417

417418
// Second run (5-9 without color)
418-
assert(AttributeManagerGetOnwardRunByFilteringID(manager,
419-
&startIndex, endIndex, colorID, &outputItems));
420-
assert(outputItems.count == 0);
419+
assert(AttributeManagerGetOnwardRunByFilteringID(manager,
420+
&startIndex, endIndex, colorID, &output));
421+
assert(output._list.count == 0);
421422
assert(startIndex == 10);
422423

423-
ListFinalize(&outputItems);
424+
AttributeDictionaryFinalize(&output);
424425
SBTextRelease(text);
425426
}
426427

@@ -437,20 +438,20 @@ void AttributeManagerTests::testGetRunByFilteredCollection() {
437438
SBTextSetAttribute(text, 0, 3, fontID, Font::arial());
438439
SBTextSetAttribute(text, 3, 4, colorID, Color::blue());
439440

440-
AttributeItemList outputItems;
441-
ListInitialize(&outputItems, sizeof(SBAttributeItem));
441+
AttributeDictionary output;
442+
AttributeDictionaryInitialize(&output, nullptr);
442443

443444
SBUInteger startIndex = 0;
444445
SBUInteger endIndex = 10;
445446

446447
// Get runs filtered by character scope
447448
assert(AttributeManagerGetOnwardRunByFilteringCollection(manager,
448-
&startIndex, endIndex, SBAttributeScopeCharacter, SBAttributeGroupNone, &outputItems));
449+
&startIndex, endIndex, SBAttributeScopeCharacter, SBAttributeGroupNone, &output));
449450

450-
assert(outputItems.count == 2); // color and font
451+
assert(output._list.count == 2); // color and font
451452
assert(startIndex == 3);
452453

453-
ListFinalize(&outputItems);
454+
AttributeDictionaryFinalize(&output);
454455
SBTextRelease(text);
455456
}
456457

@@ -468,21 +469,21 @@ void AttributeManagerTests::testFilterByAttributeGroup() {
468469
SBTextSetAttribute(text, 0, 5, fontID, Font::arial());
469470
SBTextSetAttribute(text, 3, 5, langID, Language::english());
470471

471-
AttributeItemList outputItems;
472-
ListInitialize(&outputItems, sizeof(SBAttributeItem));
472+
AttributeDictionary output;
473+
AttributeDictionaryInitialize(&output, nullptr);
473474

474475
SBUInteger startIndex = 0;
475476
SBUInteger endIndex = 10;
476477

477478
// Filter by character group (group 1)
478479
assert(AttributeManagerGetOnwardRunByFilteringCollection(manager,
479-
&startIndex, endIndex, SBAttributeScopeCharacter, 1, &outputItems));
480+
&startIndex, endIndex, SBAttributeScopeCharacter, 1, &output));
480481

481482
// Should only get color and font (both group 1), not language (group 2)
482483
assert(startIndex == 5);
483-
assert(outputItems.count == 2);
484+
assert(output._list.count == 2);
484485

485-
ListFinalize(&outputItems);
486+
AttributeDictionaryFinalize(&output);
486487
SBTextRelease(text);
487488
}
488489

@@ -501,29 +502,29 @@ void AttributeManagerTests::testComplexRunDetectionScenarios() {
501502
SBTextSetAttribute(text, 10, 5, fontID, Font::arial()); // 10-14: both
502503
SBTextSetAttribute(text, 15, 5, fontID, Font::times()); // 15-19: font
503504

504-
AttributeItemList outputItems;
505-
ListInitialize(&outputItems, sizeof(SBAttributeItem));
505+
AttributeDictionary output;
506+
AttributeDictionaryInitialize(&output, nullptr);
506507

507508
SBUInteger startIndex = 0;
508509

509510
// Test run detection with mixed attributes
510511
AttributeManagerGetOnwardRunByFilteringCollection(manager,
511-
&startIndex, 20, SBAttributeScopeCharacter, SBAttributeGroupNone, &outputItems);
512+
&startIndex, 20, SBAttributeScopeCharacter, SBAttributeGroupNone, &output);
512513
assert(startIndex == 5); // First run: positions 0-4 (color only)
513514

514515
AttributeManagerGetOnwardRunByFilteringCollection(manager,
515-
&startIndex, 20, SBAttributeScopeCharacter, SBAttributeGroupNone, &outputItems);
516+
&startIndex, 20, SBAttributeScopeCharacter, SBAttributeGroupNone, &output);
516517
assert(startIndex == 10); // Second run: positions 5-9 (font only)
517518

518519
AttributeManagerGetOnwardRunByFilteringCollection(manager,
519-
&startIndex, 20, SBAttributeScopeCharacter, SBAttributeGroupNone, &outputItems);
520+
&startIndex, 20, SBAttributeScopeCharacter, SBAttributeGroupNone, &output);
520521
assert(startIndex == 15); // Third run: positions 10-14 (both color and font)
521522

522523
AttributeManagerGetOnwardRunByFilteringCollection(manager,
523-
&startIndex, 20, SBAttributeScopeCharacter, SBAttributeGroupNone, &outputItems);
524+
&startIndex, 20, SBAttributeScopeCharacter, SBAttributeGroupNone, &output);
524525
assert(startIndex == 20); // Fourth run: positions 15-19 (font only)
525526

526-
ListFinalize(&outputItems);
527+
AttributeDictionaryFinalize(&output);
527528
SBTextRelease(text);
528529
}
529530

@@ -597,19 +598,19 @@ void AttributeManagerTests::testEmptyRuns() {
597598
auto manager = &text->attributeManager;
598599
auto colorID = SBAttributeRegistryGetAttributeID(text->attributeRegistry, Attribute::Color);
599600

600-
AttributeItemList outputItems;
601-
ListInitialize(&outputItems, sizeof(SBAttributeItem));
601+
AttributeDictionary output;
602+
AttributeDictionaryInitialize(&output, nullptr);
602603

603604
SBUInteger startIndex = 0;
604605
SBUInteger endIndex = 5;
605606

606607
// Should find a run with no attributes
607608
assert(AttributeManagerGetOnwardRunByFilteringID(manager,
608-
&startIndex, endIndex, colorID, &outputItems));
609-
assert(outputItems.count == 0);
609+
&startIndex, endIndex, colorID, &output));
610+
assert(output._list.count == 0);
610611
assert(startIndex == 5);
611612

612-
ListFinalize(&outputItems);
613+
AttributeDictionaryFinalize(&output);
613614
SBTextRelease(text);
614615
}
615616

@@ -747,23 +748,23 @@ void AttributeManagerTests::testRunBoundariesWithMixedAttributes() {
747748
SBTextSetAttribute(text, 10, 5, fontID, Font::arial());
748749
// 15-30: no attributes
749750

750-
AttributeItemList outputItems;
751-
ListInitialize(&outputItems, sizeof(SBAttributeItem));
751+
AttributeDictionary output;
752+
AttributeDictionaryInitialize(&output, nullptr);
752753

753754
SBUInteger startIndex = 0;
754755
SBUInteger endIndex = 30;
755756

756757
// Get runs for the color
757758
assert(AttributeManagerGetOnwardRunByFilteringID(manager,
758-
&startIndex, endIndex, colorID, &outputItems));
759+
&startIndex, endIndex, colorID, &output));
759760
assert(startIndex == 10); // color ends at 10
760761

761762
// Continue to the next run (no color)
762763
assert(AttributeManagerGetOnwardRunByFilteringID(manager,
763-
&startIndex, endIndex, colorID, &outputItems));
764+
&startIndex, endIndex, colorID, &output));
764765
assert(startIndex == 30); // no color from 10-30
765766

766-
ListFinalize(&outputItems);
767+
AttributeDictionaryFinalize(&output);
767768
SBTextRelease(text);
768769
}
769770

0 commit comments

Comments
 (0)