com.wallstop-studios.unity-helpers 2.0.0-rc81.6 → 2.0.0-rc81.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.config/dotnet-tools.json +10 -10
- package/.csharpierignore +1 -0
- package/.csharpierrc.json +3 -0
- package/.editorconfig +184 -184
- package/.gitattributes +87 -63
- package/.githooks/pre-commit +49 -0
- package/.github/dependabot.yml +9 -9
- package/.github/workflows/csharpier.yml +135 -0
- package/.github/workflows/lint-doc-links.yml +27 -0
- package/.github/workflows/markdown-json.yml +41 -0
- package/.github/workflows/npm-publish.yml +75 -75
- package/.lychee.toml +26 -0
- package/.markdownlint.json +21 -0
- package/.markdownlintignore +8 -0
- package/.pre-commit-config.yaml +39 -22
- package/.prettierignore +22 -0
- package/.prettierrc.json +20 -0
- package/AGENTS.md +52 -0
- package/{Third Party Notices.md.meta → AGENTS.md.meta} +7 -7
- package/CHANGELOG.md.meta +7 -7
- package/DATA_STRUCTURES.md +324 -0
- package/DATA_STRUCTURES.md.meta +7 -0
- package/Docs/Images/attribute_resolution.svg +40 -0
- package/Docs/Images/attribute_resolution.svg.meta +7 -0
- package/Docs/Images/bitset.svg +47 -0
- package/Docs/Images/bitset.svg.meta +7 -0
- package/Docs/Images/concave_hull.svg +30 -0
- package/Docs/Images/concave_hull.svg.meta +7 -0
- package/Docs/Images/convex_hull.svg +29 -0
- package/Docs/Images/convex_hull.svg.meta +7 -0
- package/Docs/Images/cyclic_buffer.svg +37 -0
- package/Docs/Images/cyclic_buffer.svg.meta +7 -0
- package/Docs/Images/data_distribution_decision.svg +88 -0
- package/Docs/Images/data_distribution_decision.svg.meta +7 -0
- package/Docs/Images/deque.svg +64 -0
- package/Docs/Images/deque.svg.meta +7 -0
- package/Docs/Images/deque_queue.svg +107 -0
- package/Docs/Images/deque_queue.svg.meta +7 -0
- package/Docs/Images/disjoint_set.svg +47 -0
- package/Docs/Images/disjoint_set.svg.meta +7 -0
- package/Docs/Images/effects_pipeline.svg +59 -0
- package/Docs/Images/effects_pipeline.svg.meta +7 -0
- package/Docs/Images/geometry_edge_cases.svg +61 -0
- package/Docs/Images/geometry_edge_cases.svg.meta +7 -0
- package/Docs/Images/heap.svg +56 -0
- package/Docs/Images/heap.svg.meta +7 -0
- package/Docs/Images/kdtree_2d.svg +38 -0
- package/Docs/Images/kdtree_2d.svg.meta +7 -0
- package/Docs/Images/kdtree_3d.svg +83 -0
- package/Docs/Images/kdtree_3d.svg.meta +7 -0
- package/Docs/Images/octree_3d.svg +79 -0
- package/Docs/Images/octree_3d.svg.meta +7 -0
- package/Docs/Images/polyline_simplify.svg +18 -0
- package/Docs/Images/polyline_simplify.svg.meta +7 -0
- package/Docs/Images/quadtree_2d.svg +37 -0
- package/Docs/Images/quadtree_2d.svg.meta +7 -0
- package/Docs/Images/query_boundaries.svg +38 -0
- package/Docs/Images/query_boundaries.svg.meta +7 -0
- package/Docs/Images/random_generators.svg +105 -0
- package/Docs/Images/random_generators.svg.meta +7 -0
- package/Docs/Images/reflection_scan.svg +33 -0
- package/Docs/Images/reflection_scan.svg.meta +7 -0
- package/Docs/Images/relational_wiring.svg +75 -0
- package/Docs/Images/relational_wiring.svg.meta +7 -0
- package/Docs/Images/rtree_2d.svg +27 -0
- package/Docs/Images/rtree_2d.svg.meta +7 -0
- package/Docs/Images/rtree_3d.svg +79 -0
- package/Docs/Images/rtree_3d.svg.meta +7 -0
- package/Docs/Images/serialization_flow.svg +50 -0
- package/Docs/Images/serialization_flow.svg.meta +7 -0
- package/Docs/Images/singletons_lifecycle.svg +54 -0
- package/Docs/Images/singletons_lifecycle.svg.meta +7 -0
- package/Docs/Images/sparse_set.svg +54 -0
- package/Docs/Images/sparse_set.svg.meta +7 -0
- package/Docs/Images/trie.svg +55 -0
- package/Docs/Images/trie.svg.meta +7 -0
- package/Docs/Images.meta +8 -0
- package/Docs.meta +8 -0
- package/EDITOR_TOOLS_GUIDE.md +1976 -0
- package/EDITOR_TOOLS_GUIDE.md.meta +7 -0
- package/EFFECTS_SYSTEM.md +242 -0
- package/EFFECTS_SYSTEM.md.meta +7 -0
- package/EFFECTS_SYSTEM_TUTORIAL.md +467 -0
- package/EFFECTS_SYSTEM_TUTORIAL.md.meta +7 -0
- package/Editor/AnimationEventEditor.cs +1393 -874
- package/Editor/AnimationEventEditor.cs.meta +11 -11
- package/Editor/AssemblyInfo.cs +4 -0
- package/Editor/AssemblyInfo.cs.meta +3 -0
- package/Editor/AssetProcessors/SpriteLabelProcessor.cs +138 -111
- package/Editor/AssetProcessors/SpriteLabelProcessor.cs.meta +2 -2
- package/Editor/AssetProcessors.meta +2 -2
- package/Editor/Core/Helper/AnimationEventHelpers.cs +204 -0
- package/{Runtime/Core/DataStructure/ISpatialTree.cs.meta → Editor/Core/Helper/AnimationEventHelpers.cs.meta} +11 -11
- package/Editor/Core/Helper.meta +8 -0
- package/Editor/Core.meta +8 -0
- package/Editor/CustomDrawers/IntDropdownDrawer.cs +46 -46
- package/Editor/CustomDrawers/IntDropdownDrawer.cs.meta +2 -2
- package/Editor/CustomDrawers/StringInListeDrawer.cs +135 -135
- package/Editor/CustomDrawers/StringInListeDrawer.cs.meta +2 -2
- package/Editor/CustomDrawers/WShowIfPropertyDrawer.cs +105 -105
- package/Editor/CustomDrawers/WShowIfPropertyDrawer.cs.meta +2 -2
- package/Editor/CustomDrawers.meta +2 -2
- package/Editor/CustomEditors/MatchColliderToSpriteEditor.cs +32 -32
- package/Editor/CustomEditors/MatchColliderToSpriteEditor.cs.meta +2 -2
- package/Editor/CustomEditors/PersistentDirectoryGUI.cs +799 -799
- package/Editor/CustomEditors/PersistentDirectoryGUI.cs.meta +2 -2
- package/Editor/CustomEditors/PolygonCollider2DOptimizerEditor.cs +38 -40
- package/Editor/CustomEditors/PolygonCollider2DOptimizerEditor.cs.meta +2 -2
- package/Editor/CustomEditors/SourceFolderEntryDrawer.cs +685 -413
- package/Editor/CustomEditors/SourceFolderEntryDrawer.cs.meta +2 -2
- package/Editor/CustomEditors/TexturePlatformOverrideEntryDrawer.cs +146 -0
- package/{Runtime/Core/DataStructure/KDTree.cs.meta → Editor/CustomEditors/TexturePlatformOverrideEntryDrawer.cs.meta} +11 -11
- package/Editor/CustomEditors.meta +2 -2
- package/Editor/Extensions/SerializedPropertyExtensions.cs +217 -190
- package/Editor/Extensions/SerializedPropertyExtensions.cs.meta +2 -2
- package/Editor/Extensions/UnityExtensions.cs +50 -26
- package/Editor/Extensions/UnityExtensions.cs.meta +2 -2
- package/Editor/Extensions.meta +2 -2
- package/Editor/FitTextureSizeWindow.cs +785 -332
- package/Editor/FitTextureSizeWindow.cs.meta +2 -2
- package/Editor/Persistence/MultiFileSelectorPersistenceManager.cs +62 -0
- package/{Runtime/Core/DataStructure/QuadTree.cs.meta → Editor/Persistence/MultiFileSelectorPersistenceManager.cs.meta} +11 -11
- package/Editor/Persistence/MultiFileSelectorPersistenceWindow.cs +65 -0
- package/Editor/Persistence/MultiFileSelectorPersistenceWindow.cs.meta +11 -0
- package/Editor/Persistence.meta +8 -0
- package/Editor/PersistentDirectorySettings.cs +529 -248
- package/Editor/PersistentDirectorySettings.cs.meta +2 -2
- package/Editor/PrefabChecker.cs +1329 -741
- package/Editor/PrefabChecker.cs.meta +11 -11
- package/Editor/Sprites/AnimationCopier.cs +1518 -789
- package/Editor/Sprites/AnimationCopier.cs.meta +2 -2
- package/Editor/Sprites/AnimationCreator.cs +1532 -881
- package/Editor/Sprites/AnimationCreator.cs.meta +11 -11
- package/Editor/Sprites/AnimationViewerWindow.cs +1634 -1522
- package/Editor/Sprites/AnimationViewerWindow.cs.meta +2 -2
- package/Editor/Sprites/ScriptableSpriteAtlas.cs +251 -178
- package/Editor/Sprites/ScriptableSpriteAtlas.cs.meta +2 -2
- package/Editor/Sprites/ScriptableSpriteAtlasEditor.cs +1470 -1026
- package/Editor/Sprites/ScriptableSpriteAtlasEditor.cs.meta +2 -2
- package/Editor/Sprites/SpriteCropper.cs +1013 -523
- package/Editor/Sprites/SpriteCropper.cs.meta +2 -2
- package/Editor/Sprites/SpritePivotAdjustor.cs +605 -265
- package/Editor/Sprites/SpritePivotAdjustor.cs.meta +2 -2
- package/Editor/Sprites/SpriteSettingsApplier.cs +942 -918
- package/Editor/Sprites/SpriteSettingsApplier.cs.meta +2 -2
- package/Editor/Sprites/SpriteSettingsApplierAPI.cs +441 -0
- package/Editor/Sprites/SpriteSettingsApplierAPI.cs.meta +11 -0
- package/Editor/Sprites/SpriteSettingsProfileCollection.cs +12 -0
- package/Editor/Sprites/SpriteSettingsProfileCollection.cs.meta +11 -0
- package/Editor/Sprites/SpriteSheetAnimationCreator.cs +1586 -1537
- package/Editor/Sprites/SpriteSheetAnimationCreator.cs.meta +2 -2
- package/Editor/Sprites/TexturePlatformNameHelper.cs +78 -0
- package/Editor/Sprites/TexturePlatformNameHelper.cs.meta +11 -0
- package/Editor/Sprites/TextureResizerWizard.cs +434 -175
- package/Editor/Sprites/TextureResizerWizard.cs.meta +2 -2
- package/Editor/Sprites/TextureSettingsApplierAPI.cs +359 -0
- package/Editor/Sprites/TextureSettingsApplierAPI.cs.meta +11 -0
- package/Editor/Sprites/TextureSettingsApplierWindow.cs +605 -0
- package/Editor/Sprites/TextureSettingsApplierWindow.cs.meta +11 -0
- package/Editor/Sprites.meta +2 -2
- package/Editor/Styles/AnimationViewer.uss +115 -115
- package/Editor/Styles/AnimationViewer.uss.meta +2 -2
- package/Editor/Styles/AnimationViewer.uxml +56 -56
- package/Editor/Styles/AnimationViewer.uxml.meta +2 -2
- package/Editor/Styles/SpriteSheetAnimationCreator.uss +10 -0
- package/Editor/Styles/SpriteSheetAnimationCreator.uss.meta +11 -0
- package/Editor/Styles.meta +2 -2
- package/Editor/Tags/AttributeMetadataCacheEditor.cs +46 -0
- package/Editor/Tags/AttributeMetadataCacheEditor.cs.meta +11 -0
- package/Editor/Tags/AttributeMetadataCacheGenerator.cs +258 -0
- package/Editor/Tags/AttributeMetadataCacheGenerator.cs.meta +11 -0
- package/Editor/Tags.meta +8 -0
- package/Editor/Tools/ImageBlurTool.cs +451 -409
- package/Editor/Tools/ImageBlurTool.cs.meta +2 -2
- package/Editor/Tools.meta +2 -2
- package/Editor/Utils/DxReadOnlyPropertyDrawer.cs +26 -26
- package/Editor/Utils/DxReadOnlyPropertyDrawer.cs.meta +11 -11
- package/Editor/Utils/EditorUi.cs +228 -0
- package/Editor/Utils/EditorUi.cs.meta +11 -0
- package/Editor/Utils/EditorUtilities.cs +22 -22
- package/Editor/Utils/EditorUtilities.cs.meta +11 -11
- package/Editor/Utils/ScriptableObjectSingletonCreator.cs +633 -52
- package/Editor/Utils/ScriptableObjectSingletonCreator.cs.meta +2 -2
- package/Editor/Utils.meta +8 -8
- package/Editor/Visuals/EnhancedImageEditor.cs +160 -160
- package/Editor/Visuals/EnhancedImageEditor.cs.meta +11 -11
- package/Editor/Visuals.meta +2 -2
- package/Editor/WallstopStudios.UnityHelpers.Editor.asmdef +14 -18
- package/Editor/WallstopStudios.UnityHelpers.Editor.asmdef.meta +7 -7
- package/Editor.meta +8 -8
- package/GETTING_STARTED.md +425 -0
- package/GETTING_STARTED.md.meta +7 -0
- package/GLOSSARY.md +313 -0
- package/GLOSSARY.md.meta +7 -0
- package/HULLS.md +45 -0
- package/HULLS.md.meta +7 -0
- package/INDEX.md +429 -0
- package/INDEX.md.meta +7 -0
- package/LICENSE +21 -21
- package/LICENSE.md +7 -7
- package/LICENSE.md.meta +7 -7
- package/LICENSE.meta +7 -7
- package/MATH_AND_EXTENSIONS.md +316 -0
- package/MATH_AND_EXTENSIONS.md.meta +7 -0
- package/RANDOM_PERFORMANCE.md +140 -0
- package/RANDOM_PERFORMANCE.md.meta +7 -0
- package/README.md +3195 -188
- package/README.md.meta +7 -7
- package/REFLECTION_HELPERS.md +272 -0
- package/REFLECTION_HELPERS.md.meta +7 -0
- package/RELATIONAL_COMPONENTS.md +543 -0
- package/RELATIONAL_COMPONENTS.md.meta +7 -0
- package/Runtime/AssemblyInfo.cs +7 -0
- package/Runtime/AssemblyInfo.cs.meta +11 -0
- package/Runtime/Binaries/Microsoft.Bcl.AsyncInterfaces.dll +0 -0
- package/Runtime/Binaries/Microsoft.Bcl.AsyncInterfaces.dll.meta +33 -33
- package/Runtime/Binaries/Microsoft.Bcl.AsyncInterfaces.xml +499 -278
- package/Runtime/Binaries/Microsoft.Bcl.AsyncInterfaces.xml.meta +7 -7
- package/Runtime/Binaries/System.IO.Pipelines.dll +0 -0
- package/Runtime/Binaries/System.IO.Pipelines.dll.meta +33 -0
- package/Runtime/Binaries/System.IO.Pipelines.xml +702 -0
- package/Runtime/Binaries/System.IO.Pipelines.xml.meta +7 -0
- package/Runtime/Binaries/System.Text.Encodings.Web.dll +0 -0
- package/Runtime/Binaries/System.Text.Encodings.Web.dll.meta +33 -33
- package/Runtime/Binaries/System.Text.Encodings.Web.xml +1084 -1079
- package/Runtime/Binaries/System.Text.Encodings.Web.xml.meta +7 -7
- package/Runtime/Binaries/System.Text.Json.dll +0 -0
- package/Runtime/Binaries/System.Text.Json.dll.meta +33 -33
- package/Runtime/Binaries/System.Text.Json.xml +10217 -8116
- package/Runtime/Binaries/System.Text.Json.xml.meta +7 -7
- package/Runtime/Binaries.meta +8 -8
- package/Runtime/Core/Attributes/AnimationEventAttribute.cs +10 -138
- package/Runtime/Core/Attributes/AnimationEventAttribute.cs.meta +11 -11
- package/Runtime/Core/Attributes/BaseRelationalComponentAttribute.cs +841 -0
- package/Runtime/Core/Attributes/BaseRelationalComponentAttribute.cs.meta +11 -0
- package/Runtime/Core/Attributes/ChildComponentAttribute.cs +284 -226
- package/Runtime/Core/Attributes/ChildComponentAttribute.cs.meta +11 -11
- package/Runtime/Core/Attributes/DxReadOnlyAttribute.cs +6 -6
- package/Runtime/Core/Attributes/DxReadOnlyAttribute.cs.meta +11 -11
- package/Runtime/Core/Attributes/EnumDisplayNameAttribute.cs +15 -15
- package/Runtime/Core/Attributes/EnumDisplayNameAttribute.cs.meta +2 -2
- package/Runtime/Core/Attributes/IRelationalComponentAssigner.cs +36 -0
- package/Runtime/Core/Attributes/IRelationalComponentAssigner.cs.meta +11 -0
- package/Runtime/Core/Attributes/IntDropdownAttribute.cs +14 -14
- package/Runtime/Core/Attributes/IntDropdownAttribute.cs.meta +2 -2
- package/Runtime/Core/Attributes/KSerializableAttribute.cs +19 -19
- package/Runtime/Core/Attributes/KSerializableAttribute.cs.meta +11 -11
- package/Runtime/Core/Attributes/NotNullAttribute.cs +32 -32
- package/Runtime/Core/Attributes/NotNullAttribute.cs.meta +11 -11
- package/Runtime/Core/Attributes/ParentComponentAttribute.cs +376 -0
- package/Runtime/Core/Attributes/{ParentComponent.cs.meta → ParentComponentAttribute.cs.meta} +11 -11
- package/Runtime/Core/Attributes/RelationalComponentAssigner.cs +107 -0
- package/Runtime/Core/Attributes/RelationalComponentAssigner.cs.meta +11 -0
- package/Runtime/Core/Attributes/RelationalComponentExtensions.cs +61 -14
- package/Runtime/Core/Attributes/RelationalComponentExtensions.cs.meta +11 -11
- package/Runtime/Core/Attributes/RelationalComponentInitializer.cs +331 -0
- package/Runtime/Core/Attributes/RelationalComponentInitializer.cs.meta +11 -0
- package/Runtime/Core/Attributes/ScriptableSingletonPathAttribute.cs +15 -15
- package/Runtime/Core/Attributes/ScriptableSingletonPathAttribute.cs.meta +2 -2
- package/Runtime/Core/Attributes/SiblingComponentAttribute.cs +264 -137
- package/Runtime/Core/Attributes/SiblingComponentAttribute.cs.meta +11 -11
- package/Runtime/Core/Attributes/ValidateAssignmentAttribute.cs +115 -106
- package/Runtime/Core/Attributes/ValidateAssignmentAttribute.cs.meta +11 -11
- package/Runtime/Core/Attributes/ValueHelpers.cs +10 -0
- package/Runtime/Core/Attributes/ValueHelpers.cs.meta +3 -0
- package/Runtime/Core/Attributes/WShowIfAttribute.cs +24 -24
- package/Runtime/Core/Attributes/WShowIfAttribute.cs.meta +2 -2
- package/Runtime/Core/Attributes.meta +8 -8
- package/Runtime/Core/DataStructure/Adapters/FastVector2Int.cs +192 -92
- package/Runtime/Core/DataStructure/Adapters/FastVector2Int.cs.meta +11 -11
- package/Runtime/Core/DataStructure/Adapters/FastVector3Int.cs +268 -185
- package/Runtime/Core/DataStructure/Adapters/FastVector3Int.cs.meta +11 -11
- package/Runtime/Core/DataStructure/Adapters/KGuid.cs +360 -305
- package/Runtime/Core/DataStructure/Adapters/KGuid.cs.meta +11 -11
- package/Runtime/Core/DataStructure/Adapters/KVector2.cs +146 -80
- package/Runtime/Core/DataStructure/Adapters/KVector2.cs.meta +11 -11
- package/Runtime/Core/DataStructure/Adapters.meta +8 -8
- package/Runtime/Core/DataStructure/BitSet.cs +626 -0
- package/Runtime/Core/DataStructure/BitSet.cs.meta +11 -0
- package/Runtime/Core/DataStructure/BoundingBox3D.cs +405 -0
- package/Runtime/Core/DataStructure/BoundingBox3D.cs.meta +11 -0
- package/Runtime/Core/DataStructure/Circle.cs +203 -50
- package/Runtime/Core/DataStructure/Circle.cs.meta +11 -11
- package/Runtime/Core/DataStructure/CyclicBuffer.cs +489 -266
- package/Runtime/Core/DataStructure/CyclicBuffer.cs.meta +11 -11
- package/Runtime/Core/DataStructure/Deque.cs +561 -0
- package/Runtime/Core/DataStructure/Deque.cs.meta +11 -0
- package/Runtime/Core/DataStructure/DisjointSet.cs +483 -0
- package/Runtime/Core/DataStructure/DisjointSet.cs.meta +11 -0
- package/Runtime/Core/DataStructure/Heap.cs +514 -0
- package/Runtime/Core/DataStructure/Heap.cs.meta +11 -0
- package/Runtime/Core/DataStructure/{ISpatialTree.cs → ISpatialTree2D.cs} +25 -21
- package/Runtime/Core/DataStructure/ISpatialTree2D.cs.meta +11 -0
- package/Runtime/Core/DataStructure/ISpatialTree3D.cs +33 -0
- package/Runtime/Core/DataStructure/ISpatialTree3D.cs.meta +11 -0
- package/Runtime/Core/DataStructure/ImmutableBitSet.cs +398 -0
- package/Runtime/Core/DataStructure/ImmutableBitSet.cs.meta +3 -0
- package/Runtime/Core/DataStructure/KDTree2D.cs +852 -0
- package/Runtime/Core/DataStructure/KDTree2D.cs.meta +11 -0
- package/Runtime/Core/DataStructure/KDTree3D.cs +911 -0
- package/Runtime/Core/DataStructure/KDTree3D.cs.meta +11 -0
- package/Runtime/Core/DataStructure/OctTree3D.cs +983 -0
- package/Runtime/Core/DataStructure/OctTree3D.cs.meta +11 -0
- package/Runtime/Core/DataStructure/PriorityQueue.cs +194 -0
- package/Runtime/Core/DataStructure/PriorityQueue.cs.meta +11 -0
- package/Runtime/Core/DataStructure/QuadTree2D.cs +722 -0
- package/Runtime/Core/DataStructure/QuadTree2D.cs.meta +11 -0
- package/Runtime/Core/DataStructure/RTree2D.cs +704 -0
- package/Runtime/Core/DataStructure/{RTree.cs.meta → RTree2D.cs.meta} +11 -11
- package/Runtime/Core/DataStructure/RTree3D.cs +775 -0
- package/Runtime/Core/DataStructure/RTree3D.cs.meta +11 -0
- package/Runtime/Core/DataStructure/SparseSet.cs +597 -0
- package/Runtime/Core/DataStructure/SparseSet.cs.meta +11 -0
- package/Runtime/Core/DataStructure/SpatialHash2D.cs +312 -0
- package/Runtime/Core/DataStructure/SpatialHash2D.cs.meta +3 -0
- package/Runtime/Core/DataStructure/SpatialHash3D.cs +341 -0
- package/Runtime/Core/DataStructure/SpatialHash3D.cs.meta +11 -0
- package/Runtime/Core/DataStructure/Sphere.cs +264 -0
- package/Runtime/Core/DataStructure/Sphere.cs.meta +11 -0
- package/Runtime/Core/DataStructure/StringWrapper.cs +115 -91
- package/Runtime/Core/DataStructure/StringWrapper.cs.meta +11 -11
- package/Runtime/Core/DataStructure/TimedCache.cs +88 -66
- package/Runtime/Core/DataStructure/TimedCache.cs.meta +11 -11
- package/Runtime/Core/DataStructure/Trie.cs +660 -359
- package/Runtime/Core/DataStructure/Trie.cs.meta +2 -2
- package/Runtime/Core/DataStructure.meta +8 -8
- package/Runtime/Core/Extension/AnimatorExtensions.cs +40 -25
- package/Runtime/Core/Extension/AnimatorExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/AsyncOperationExtensions.cs +404 -110
- package/Runtime/Core/Extension/AsyncOperationExtensions.cs.meta +2 -2
- package/Runtime/Core/Extension/CircleExtensions.cs +125 -25
- package/Runtime/Core/Extension/CircleExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/ColorExtensions.cs +983 -644
- package/Runtime/Core/Extension/ColorExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/DictionaryExtensions.cs +606 -299
- package/Runtime/Core/Extension/DictionaryExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/DirectionExtensions.cs +377 -213
- package/Runtime/Core/Extension/DirectionExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/EnumExtensions.cs +535 -137
- package/Runtime/Core/Extension/EnumExtensions.cs.meta +2 -2
- package/Runtime/Core/Extension/IEnumerableExtensions.cs +341 -124
- package/Runtime/Core/Extension/IEnumerableExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/IListExtensions.cs +767 -248
- package/Runtime/Core/Extension/IListExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/IReadonlyListExtensions.cs +687 -37
- package/Runtime/Core/Extension/IReadonlyListExtensions.cs.meta +2 -2
- package/Runtime/Core/Extension/ProtoEqualityExtensions.cs +292 -0
- package/Runtime/Core/Extension/ProtoEqualityExtensions.cs.meta +3 -0
- package/Runtime/Core/Extension/RandomExtensions.cs +938 -109
- package/Runtime/Core/Extension/RandomExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/StringExtensions.cs +1635 -239
- package/Runtime/Core/Extension/StringExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/UnityExtensions.cs +4555 -1689
- package/Runtime/Core/Extension/UnityExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/WallstopStudiosLogger.cs +271 -245
- package/Runtime/Core/Extension/WallstopStudiosLogger.cs.meta +11 -11
- package/Runtime/Core/Extension.meta +8 -8
- package/Runtime/Core/Helper/ArrayConverter.cs +73 -39
- package/Runtime/Core/Helper/ArrayConverter.cs.meta +2 -2
- package/Runtime/Core/Helper/AssignUtilities.cs +33 -14
- package/Runtime/Core/Helper/AssignUtilities.cs.meta +11 -11
- package/Runtime/Core/Helper/DirectoryHelper.cs +210 -196
- package/Runtime/Core/Helper/DirectoryHelper.cs.meta +2 -2
- package/Runtime/Core/Helper/Enumerables.cs +51 -17
- package/Runtime/Core/Helper/Enumerables.cs.meta +11 -11
- package/Runtime/Core/Helper/FileHelper.cs +97 -77
- package/Runtime/Core/Helper/FileHelper.cs.meta +2 -2
- package/Runtime/Core/Helper/FormattingHelpers.cs +49 -38
- package/Runtime/Core/Helper/FormattingHelpers.cs.meta +2 -2
- package/Runtime/Core/Helper/FuncBasedComparer.cs +29 -0
- package/Runtime/Core/Helper/FuncBasedComparer.cs.meta +3 -0
- package/Runtime/Core/Helper/Geometry.cs +65 -43
- package/Runtime/Core/Helper/Geometry.cs.meta +11 -11
- package/Runtime/Core/Helper/Helpers.cs +1271 -831
- package/Runtime/Core/Helper/Helpers.cs.meta +11 -11
- package/Runtime/Core/Helper/IterationHelpers.cs +83 -32
- package/Runtime/Core/Helper/IterationHelpers.cs.meta +11 -11
- package/Runtime/Core/Helper/LifetimeHelpers.cs +20 -13
- package/Runtime/Core/Helper/LifetimeHelpers.cs.meta +11 -11
- package/Runtime/Core/Helper/LineHelper.cs +259 -194
- package/Runtime/Core/Helper/LineHelper.cs.meta +2 -2
- package/Runtime/Core/Helper/Logging/UnityLogTagFormatter.cs +549 -539
- package/Runtime/Core/Helper/Logging/UnityLogTagFormatter.cs.meta +2 -2
- package/Runtime/Core/Helper/Logging.meta +2 -2
- package/Runtime/Core/Helper/Objects.cs +477 -769
- package/Runtime/Core/Helper/Objects.cs.meta +11 -11
- package/Runtime/Core/Helper/Partials/LogHelpers.cs +13 -13
- package/Runtime/Core/Helper/Partials/LogHelpers.cs.meta +2 -2
- package/Runtime/Core/Helper/Partials/MathHelpers.cs +45 -30
- package/Runtime/Core/Helper/Partials/MathHelpers.cs.meta +2 -2
- package/Runtime/Core/Helper/Partials/ObjectHelpers.cs +506 -400
- package/Runtime/Core/Helper/Partials/ObjectHelpers.cs.meta +2 -2
- package/Runtime/Core/Helper/Partials/TransformHelpers.cs +393 -377
- package/Runtime/Core/Helper/Partials/TransformHelpers.cs.meta +2 -2
- package/Runtime/Core/Helper/Partials.meta +2 -2
- package/Runtime/Core/Helper/PathHelper.cs +42 -15
- package/Runtime/Core/Helper/PathHelper.cs.meta +2 -2
- package/Runtime/Core/Helper/ReflectionHelpers.cs +5287 -1963
- package/Runtime/Core/Helper/ReflectionHelpers.cs.meta +2 -2
- package/Runtime/Core/Helper/ReverseComparer.cs +33 -0
- package/Runtime/Core/Helper/ReverseComparer.cs.meta +3 -0
- package/Runtime/Core/Helper/SceneHelper.cs +251 -224
- package/Runtime/Core/Helper/SceneHelper.cs.meta +2 -2
- package/Runtime/Core/Helper/SpriteHelpers.cs +50 -41
- package/Runtime/Core/Helper/SpriteHelpers.cs.meta +11 -11
- package/Runtime/Core/Helper/StringInList.cs +61 -35
- package/Runtime/Core/Helper/StringInList.cs.meta +11 -11
- package/Runtime/Core/Helper/TestAssemblyHelper.cs +134 -0
- package/Runtime/Core/Helper/TestAssemblyHelper.cs.meta +11 -0
- package/Runtime/Core/Helper/UnityMainThreadDispatcher.cs +100 -82
- package/Runtime/Core/Helper/UnityMainThreadDispatcher.cs.meta +2 -2
- package/Runtime/Core/Helper/WallMath.cs +672 -166
- package/Runtime/Core/Helper/WallMath.cs.meta +11 -11
- package/Runtime/Core/Helper.meta +8 -8
- package/Runtime/Core/Math/Line2D.cs +263 -0
- package/Runtime/Core/Math/Line2D.cs.meta +11 -0
- package/Runtime/Core/Math/Line3D.cs +452 -0
- package/Runtime/Core/Math/Line3D.cs.meta +11 -0
- package/Runtime/Core/Math/Parabola.cs +241 -47
- package/Runtime/Core/Math/Parabola.cs.meta +11 -11
- package/Runtime/Core/Math/PointPolygonCheck.cs +175 -36
- package/Runtime/Core/Math/PointPolygonCheck.cs.meta +11 -11
- package/Runtime/Core/Math/Range.cs +157 -92
- package/Runtime/Core/Math/Range.cs.meta +11 -11
- package/Runtime/Core/Math.meta +8 -8
- package/Runtime/Core/Model/Direction.cs +25 -43
- package/Runtime/Core/Model/Direction.cs.meta +11 -11
- package/Runtime/Core/Model.meta +8 -8
- package/Runtime/Core/OneOf/FastOneOf.cs +252 -152
- package/Runtime/Core/OneOf/FastOneOf.cs.meta +11 -11
- package/Runtime/Core/OneOf/FastOneOf2.cs +198 -0
- package/Runtime/Core/OneOf/FastOneOf2.cs.meta +11 -0
- package/Runtime/Core/OneOf/FastOneOf4.cs +324 -0
- package/Runtime/Core/OneOf/FastOneOf4.cs.meta +11 -0
- package/Runtime/Core/OneOf/None.cs +30 -4
- package/Runtime/Core/OneOf/None.cs.meta +11 -11
- package/Runtime/Core/OneOf.meta +8 -8
- package/Runtime/Core/Random/AbstractRandom.cs +1318 -655
- package/Runtime/Core/Random/AbstractRandom.cs.meta +11 -11
- package/Runtime/Core/Random/DotNetRandom.cs +118 -54
- package/Runtime/Core/Random/DotNetRandom.cs.meta +2 -2
- package/Runtime/Core/Random/IRandom.cs +203 -161
- package/Runtime/Core/Random/IRandom.cs.meta +11 -11
- package/Runtime/Core/Random/IllusionFlow.cs +171 -107
- package/Runtime/Core/Random/IllusionFlow.cs.meta +2 -2
- package/Runtime/Core/Random/LinearCongruentialGenerator.cs +90 -49
- package/Runtime/Core/Random/LinearCongruentialGenerator.cs.meta +2 -2
- package/Runtime/Core/Random/NativePcgRandom.cs +139 -97
- package/Runtime/Core/Random/NativePcgRandom.cs.meta +11 -11
- package/Runtime/Core/Random/PRNG.cs +21 -7
- package/Runtime/Core/Random/PRNG.cs.meta +2 -2
- package/Runtime/Core/Random/PcgRandom.cs +243 -149
- package/Runtime/Core/Random/PcgRandom.cs.meta +11 -11
- package/Runtime/Core/Random/PerlinNoise.cs +369 -369
- package/Runtime/Core/Random/PerlinNoise.cs.meta +2 -2
- package/Runtime/Core/Random/RandomComparer.cs +34 -0
- package/Runtime/Core/Random/RandomComparer.cs.meta +3 -0
- package/Runtime/Core/Random/RandomState.cs +206 -131
- package/Runtime/Core/Random/RandomState.cs.meta +11 -11
- package/Runtime/Core/Random/RandomUtilities.cs +55 -26
- package/Runtime/Core/Random/RandomUtilities.cs.meta +11 -11
- package/Runtime/Core/Random/RomuDuo.cs +171 -116
- package/Runtime/Core/Random/RomuDuo.cs.meta +2 -2
- package/Runtime/Core/Random/SplitMix64.cs +134 -94
- package/Runtime/Core/Random/SplitMix64.cs.meta +2 -2
- package/Runtime/Core/Random/SquirrelRandom.cs +127 -84
- package/Runtime/Core/Random/SquirrelRandom.cs.meta +11 -11
- package/Runtime/Core/Random/SystemRandom.cs +203 -162
- package/Runtime/Core/Random/SystemRandom.cs.meta +11 -11
- package/Runtime/Core/Random/ThreadLocalRandom.cs +25 -12
- package/Runtime/Core/Random/ThreadLocalRandom.cs.meta +11 -11
- package/Runtime/Core/Random/UnityRandom.cs +109 -57
- package/Runtime/Core/Random/UnityRandom.cs.meta +11 -11
- package/Runtime/Core/Random/WyRandom.cs +158 -121
- package/Runtime/Core/Random/WyRandom.cs.meta +2 -2
- package/Runtime/Core/Random/XorShiftRandom.cs +106 -52
- package/Runtime/Core/Random/XorShiftRandom.cs.meta +11 -11
- package/Runtime/Core/Random/XoroShiroRandom.cs +184 -119
- package/Runtime/Core/Random/XoroShiroRandom.cs.meta +2 -2
- package/Runtime/Core/Random.meta +8 -8
- package/Runtime/Core/Serialization/JsonConverters/AnimationCurveConverter.cs +248 -0
- package/Runtime/Core/Serialization/JsonConverters/AnimationCurveConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/BitSetConverter.cs +119 -0
- package/Runtime/Core/Serialization/JsonConverters/BitSetConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/BoundingSphereConverter.cs +74 -0
- package/Runtime/Core/Serialization/JsonConverters/BoundingSphereConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/BoundsConverter.cs +132 -0
- package/Runtime/Core/Serialization/JsonConverters/BoundsConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/BoundsIntConverter.cs +135 -0
- package/Runtime/Core/Serialization/JsonConverters/BoundsIntConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/Color32Converter.cs +98 -0
- package/Runtime/Core/Serialization/JsonConverters/Color32Converter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/ColorBlockConverter.cs +123 -0
- package/Runtime/Core/Serialization/JsonConverters/ColorBlockConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/ColorConverter.cs +88 -88
- package/Runtime/Core/Serialization/JsonConverters/ColorConverter.cs.meta +2 -2
- package/Runtime/Core/Serialization/JsonConverters/CyclicBufferConverterFactory.cs +112 -0
- package/Runtime/Core/Serialization/JsonConverters/CyclicBufferConverterFactory.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/DequeConverterFactory.cs +62 -0
- package/Runtime/Core/Serialization/JsonConverters/DequeConverterFactory.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/FastVector2IntConverter.cs +72 -0
- package/Runtime/Core/Serialization/JsonConverters/FastVector2IntConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/FastVector3IntConverter.cs +80 -0
- package/Runtime/Core/Serialization/JsonConverters/FastVector3IntConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/GameObjectConverter.cs +36 -36
- package/Runtime/Core/Serialization/JsonConverters/GameObjectConverter.cs.meta +2 -2
- package/Runtime/Core/Serialization/JsonConverters/GradientConverter.cs +245 -0
- package/Runtime/Core/Serialization/JsonConverters/GradientConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/Hash128Converter.cs +92 -0
- package/Runtime/Core/Serialization/JsonConverters/Hash128Converter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/ImmutableBitSetConverter.cs +119 -0
- package/Runtime/Core/Serialization/JsonConverters/ImmutableBitSetConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/KVector2Converter.cs +72 -0
- package/Runtime/Core/Serialization/JsonConverters/KVector2Converter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/LayerMaskConverter.cs +95 -0
- package/Runtime/Core/Serialization/JsonConverters/LayerMaskConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/Matrix4x4Converter.cs +237 -218
- package/Runtime/Core/Serialization/JsonConverters/Matrix4x4Converter.cs.meta +2 -2
- package/Runtime/Core/Serialization/JsonConverters/MinMaxCurveConverter.cs +142 -0
- package/Runtime/Core/Serialization/JsonConverters/MinMaxCurveConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/MinMaxGradientConverter.cs +135 -0
- package/Runtime/Core/Serialization/JsonConverters/MinMaxGradientConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/PlaneConverter.cs +79 -0
- package/Runtime/Core/Serialization/JsonConverters/PlaneConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/PoseConverter.cs +76 -0
- package/Runtime/Core/Serialization/JsonConverters/PoseConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/QuaternionConverter.cs +88 -0
- package/Runtime/Core/Serialization/JsonConverters/QuaternionConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/RangeConverterFactory.cs +106 -0
- package/Runtime/Core/Serialization/JsonConverters/RangeConverterFactory.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/RangeIntConverter.cs +71 -0
- package/Runtime/Core/Serialization/JsonConverters/RangeIntConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/Ray2DConverter.cs +80 -0
- package/Runtime/Core/Serialization/JsonConverters/Ray2DConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/RayConverter.cs +76 -0
- package/Runtime/Core/Serialization/JsonConverters/RayConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/RaycastHitConverter.cs +115 -0
- package/Runtime/Core/Serialization/JsonConverters/RaycastHitConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/RectConverter.cs +84 -0
- package/Runtime/Core/Serialization/JsonConverters/RectConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/RectIntConverter.cs +88 -0
- package/Runtime/Core/Serialization/JsonConverters/RectIntConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/RectOffsetConverter.cs +87 -0
- package/Runtime/Core/Serialization/JsonConverters/RectOffsetConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/RenderTextureDescriptorConverter.cs +264 -0
- package/Runtime/Core/Serialization/JsonConverters/RenderTextureDescriptorConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/ResolutionConverter.cs +158 -0
- package/Runtime/Core/Serialization/JsonConverters/ResolutionConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/SceneConverter.cs +103 -0
- package/Runtime/Core/Serialization/JsonConverters/SceneConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/SphericalHarmonicsL2Converter.cs +121 -0
- package/Runtime/Core/Serialization/JsonConverters/SphericalHarmonicsL2Converter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/TouchConverter.cs +54 -0
- package/Runtime/Core/Serialization/JsonConverters/TouchConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/TypeConverter.cs +30 -28
- package/Runtime/Core/Serialization/JsonConverters/TypeConverter.cs.meta +2 -2
- package/Runtime/Core/Serialization/JsonConverters/Vector2Converter.cs +72 -74
- package/Runtime/Core/Serialization/JsonConverters/Vector2Converter.cs.meta +11 -11
- package/Runtime/Core/Serialization/JsonConverters/Vector2IntConverter.cs +72 -0
- package/Runtime/Core/Serialization/JsonConverters/Vector2IntConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/Vector3Converter.cs +80 -81
- package/Runtime/Core/Serialization/JsonConverters/Vector3Converter.cs.meta +11 -11
- package/Runtime/Core/Serialization/JsonConverters/Vector3IntConverter.cs +80 -0
- package/Runtime/Core/Serialization/JsonConverters/Vector3IntConverter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/Vector4Converter.cs +88 -88
- package/Runtime/Core/Serialization/JsonConverters/Vector4Converter.cs.meta +2 -2
- package/Runtime/Core/Serialization/JsonConverters.meta +8 -8
- package/Runtime/Core/Serialization/ProtobufUnitySurrogates.cs +383 -0
- package/Runtime/Core/Serialization/ProtobufUnitySurrogates.cs.meta +11 -0
- package/Runtime/Core/Serialization/Serializer.cs +2020 -195
- package/Runtime/Core/Serialization/Serializer.cs.meta +11 -11
- package/Runtime/Core/Serialization.meta +8 -8
- package/Runtime/Core/Threading/SingleThreadedThreadPool.cs +228 -228
- package/Runtime/Core/Threading/SingleThreadedThreadPool.cs.meta +11 -11
- package/Runtime/Core/Threading.meta +8 -8
- package/Runtime/Core.meta +8 -8
- package/Runtime/Integrations/VContainer/ObjectResolverRelationalExtensions.cs +185 -0
- package/Runtime/Integrations/VContainer/ObjectResolverRelationalExtensions.cs.meta +11 -0
- package/Runtime/Integrations/VContainer/RelationalComponentEntryPoint.cs +109 -0
- package/Runtime/Integrations/VContainer/RelationalComponentEntryPoint.cs.meta +11 -0
- package/Runtime/Integrations/VContainer/RelationalComponentsBuilderExtensions.cs +78 -0
- package/Runtime/Integrations/VContainer/RelationalComponentsBuilderExtensions.cs.meta +11 -0
- package/Runtime/Integrations/VContainer/RelationalSceneAssignmentOptions.cs +83 -0
- package/Runtime/Integrations/VContainer/RelationalSceneAssignmentOptions.cs.meta +11 -0
- package/Runtime/Integrations/VContainer/WallstopStudios.UnityHelpers.Integration.VContainer.asmdef +30 -0
- package/Runtime/Integrations/VContainer/WallstopStudios.UnityHelpers.Integration.VContainer.asmdef.meta +7 -0
- package/Runtime/Integrations/VContainer.meta +8 -0
- package/Runtime/Integrations/Zenject/DiContainerRelationalExtensions.cs +180 -0
- package/Runtime/Integrations/Zenject/DiContainerRelationalExtensions.cs.meta +11 -0
- package/Runtime/Integrations/Zenject/RelationalComponentSceneInitializer.cs +105 -0
- package/Runtime/Integrations/Zenject/RelationalComponentSceneInitializer.cs.meta +11 -0
- package/Runtime/Integrations/Zenject/RelationalComponentsInstaller.cs +72 -0
- package/Runtime/Integrations/Zenject/RelationalComponentsInstaller.cs.meta +11 -0
- package/Runtime/Integrations/Zenject/RelationalSceneAssignmentOptions.cs +87 -0
- package/Runtime/Integrations/Zenject/RelationalSceneAssignmentOptions.cs.meta +11 -0
- package/Runtime/Integrations/Zenject/WallstopStudios.UnityHelpers.Integration.Zenject.asmdef +30 -0
- package/Runtime/Integrations/Zenject/WallstopStudios.UnityHelpers.Integration.Zenject.asmdef.meta +7 -0
- package/Runtime/Integrations/Zenject.meta +8 -0
- package/Runtime/Integrations.meta +8 -0
- package/Runtime/Protobuf-Net/System.Collections.Immutable.dll.meta +33 -33
- package/Runtime/Protobuf-Net/System.Runtime.CompilerServices.Unsafe.dll.meta +33 -33
- package/Runtime/Protobuf-Net/protobuf-net.Core.dll.meta +33 -33
- package/Runtime/Protobuf-Net/protobuf-net.dll.meta +33 -33
- package/Runtime/Protobuf-Net.meta +8 -8
- package/Runtime/Tags/AlwaysIncludeInAttributeMetadataCacheAttribute.cs +11 -0
- package/Runtime/Tags/AlwaysIncludeInAttributeMetadataCacheAttribute.cs.meta +11 -0
- package/Runtime/Tags/Attribute.cs +399 -205
- package/Runtime/Tags/Attribute.cs.meta +2 -2
- package/Runtime/Tags/AttributeEffect.cs +372 -281
- package/Runtime/Tags/AttributeEffect.cs.meta +2 -2
- package/Runtime/Tags/AttributeMetadataCache.cs +503 -0
- package/Runtime/Tags/AttributeMetadataCache.cs.meta +11 -0
- package/Runtime/Tags/AttributeMetadataFilters.cs +108 -0
- package/Runtime/Tags/AttributeMetadataFilters.cs.meta +11 -0
- package/Runtime/Tags/AttributeModification.cs +132 -48
- package/Runtime/Tags/AttributeModification.cs.meta +2 -2
- package/Runtime/Tags/AttributeUtilities.cs +376 -209
- package/Runtime/Tags/AttributeUtilities.cs.meta +2 -2
- package/Runtime/Tags/AttributesComponent.cs +237 -163
- package/Runtime/Tags/AttributesComponent.cs.meta +2 -2
- package/Runtime/Tags/CollisionSenses.cs +117 -91
- package/Runtime/Tags/CollisionSenses.cs.meta +2 -2
- package/Runtime/Tags/CosmeticEffectComponent.cs +112 -50
- package/Runtime/Tags/CosmeticEffectComponent.cs.meta +2 -2
- package/Runtime/Tags/CosmeticEffectData.cs +109 -63
- package/Runtime/Tags/CosmeticEffectData.cs.meta +2 -2
- package/Runtime/Tags/EffectHandle.cs +150 -65
- package/Runtime/Tags/EffectHandle.cs.meta +2 -2
- package/Runtime/Tags/EffectHandler.cs +470 -393
- package/Runtime/Tags/EffectHandler.cs.meta +2 -2
- package/Runtime/Tags/ModificationAction.cs +60 -9
- package/Runtime/Tags/ModificationAction.cs.meta +2 -2
- package/Runtime/Tags/ModifierDurationType.cs +71 -13
- package/Runtime/Tags/ModifierDurationType.cs.meta +2 -2
- package/Runtime/Tags/TagHandler.cs +373 -158
- package/Runtime/Tags/TagHandler.cs.meta +2 -2
- package/Runtime/Tags.meta +2 -2
- package/Runtime/Utils/AnimationEventEqualityComparer.cs +198 -161
- package/Runtime/Utils/AnimationEventEqualityComparer.cs.meta +11 -11
- package/Runtime/Utils/AnimatorEnumStateMachine.cs +110 -88
- package/Runtime/Utils/AnimatorEnumStateMachine.cs.meta +11 -11
- package/Runtime/Utils/Ascii85.cs +132 -115
- package/Runtime/Utils/Ascii85.cs.meta +2 -2
- package/Runtime/Utils/Buffers.cs +1151 -550
- package/Runtime/Utils/Buffers.cs.meta +11 -11
- package/Runtime/Utils/CenterPointOffset.cs +35 -30
- package/Runtime/Utils/CenterPointOffset.cs.meta +2 -2
- package/Runtime/Utils/ChildSpawner.cs +250 -157
- package/Runtime/Utils/ChildSpawner.cs.meta +2 -2
- package/Runtime/Utils/CircleLineRenderer.cs +142 -142
- package/Runtime/Utils/CircleLineRenderer.cs.meta +11 -11
- package/Runtime/Utils/CollisionProxy.cs +48 -48
- package/Runtime/Utils/CollisionProxy.cs.meta +2 -2
- package/Runtime/Utils/CoroutineHandler.cs +4 -4
- package/Runtime/Utils/CoroutineHandler.cs.meta +2 -2
- package/Runtime/Utils/DeferredDisposalResult.cs +20 -23
- package/Runtime/Utils/DeferredDisposalResult.cs.meta +2 -2
- package/Runtime/Utils/LZMA.cs +276 -53
- package/Runtime/Utils/LZMA.cs.meta +2 -2
- package/Runtime/Utils/MatchColliderToSprite.cs +104 -104
- package/Runtime/Utils/MatchColliderToSprite.cs.meta +2 -2
- package/Runtime/Utils/MatchTransform.cs +99 -82
- package/Runtime/Utils/MatchTransform.cs.meta +2 -2
- package/Runtime/Utils/Oscillator.cs +27 -27
- package/Runtime/Utils/Oscillator.cs.meta +11 -11
- package/Runtime/Utils/PolygonCollider2DOptimizer.cs +104 -83
- package/Runtime/Utils/PolygonCollider2DOptimizer.cs.meta +2 -2
- package/Runtime/Utils/RuntimeSingleton.cs +139 -88
- package/Runtime/Utils/RuntimeSingleton.cs.meta +11 -11
- package/Runtime/Utils/ScriptableObjectSingleton.cs +226 -85
- package/Runtime/Utils/ScriptableObjectSingleton.cs.meta +2 -2
- package/Runtime/Utils/SerializedStringComparer.cs +107 -107
- package/Runtime/Utils/SerializedStringComparer.cs.meta +2 -2
- package/Runtime/Utils/SetTextureImportData.cs +69 -69
- package/Runtime/Utils/SetTextureImportData.cs.meta +11 -11
- package/Runtime/Utils/SevenZip/Common/CRC.cs +70 -70
- package/Runtime/Utils/SevenZip/Common/CRC.cs.meta +11 -11
- package/Runtime/Utils/SevenZip/Common/InBuffer.cs +84 -84
- package/Runtime/Utils/SevenZip/Common/InBuffer.cs.meta +11 -11
- package/Runtime/Utils/SevenZip/Common/OutBuffer.cs +70 -70
- package/Runtime/Utils/SevenZip/Common/OutBuffer.cs.meta +11 -11
- package/Runtime/Utils/SevenZip/Common.meta +2 -2
- package/Runtime/Utils/SevenZip/Compress/LZ/IMatchFinder.cs +28 -28
- package/Runtime/Utils/SevenZip/Compress/LZ/IMatchFinder.cs.meta +11 -11
- package/Runtime/Utils/SevenZip/Compress/LZ/LzBinTree.cs +454 -454
- package/Runtime/Utils/SevenZip/Compress/LZ/LzBinTree.cs.meta +11 -11
- package/Runtime/Utils/SevenZip/Compress/LZ/LzInWindow.cs +179 -179
- package/Runtime/Utils/SevenZip/Compress/LZ/LzInWindow.cs.meta +11 -11
- package/Runtime/Utils/SevenZip/Compress/LZ/LzOutWindow.cs +137 -137
- package/Runtime/Utils/SevenZip/Compress/LZ/LzOutWindow.cs.meta +11 -11
- package/Runtime/Utils/SevenZip/Compress/LZ.meta +8 -8
- package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaBase.cs +110 -110
- package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaBase.cs.meta +11 -11
- package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaDecoder.cs +525 -527
- package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaDecoder.cs.meta +11 -11
- package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaEncoder.cs +1891 -1904
- package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaEncoder.cs.meta +11 -11
- package/Runtime/Utils/SevenZip/Compress/LZMA.meta +8 -8
- package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoder.cs +242 -242
- package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoder.cs.meta +11 -11
- package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoderBit.cs +146 -149
- package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoderBit.cs.meta +11 -11
- package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoderBitTree.cs +177 -177
- package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoderBitTree.cs.meta +11 -11
- package/Runtime/Utils/SevenZip/Compress/RangeCoder.meta +8 -8
- package/Runtime/Utils/SevenZip/Compress.meta +8 -8
- package/Runtime/Utils/SevenZip/ICoder.cs +177 -177
- package/Runtime/Utils/SevenZip/ICoder.cs.meta +11 -11
- package/Runtime/Utils/SevenZip.meta +2 -2
- package/Runtime/Utils/SpriteRendererMetadata.cs +346 -370
- package/Runtime/Utils/SpriteRendererMetadata.cs.meta +2 -2
- package/Runtime/Utils/SpriteRendererSyncer.cs +100 -100
- package/Runtime/Utils/SpriteRendererSyncer.cs.meta +2 -2
- package/Runtime/Utils/StartTracker.cs +15 -15
- package/Runtime/Utils/StartTracker.cs.meta +2 -2
- package/Runtime/Utils/TextureScale.cs +356 -179
- package/Runtime/Utils/TextureScale.cs.meta +2 -2
- package/Runtime/Utils/TypeNameSorter.cs +17 -17
- package/Runtime/Utils/TypeNameSorter.cs.meta +2 -2
- package/Runtime/Utils/UnityObjectNameComparer.cs +89 -89
- package/Runtime/Utils/UnityObjectNameComparer.cs.meta +2 -2
- package/Runtime/Utils.meta +8 -8
- package/Runtime/Visuals/AnimatedSpriteLayer.cs +217 -130
- package/Runtime/Visuals/AnimatedSpriteLayer.cs.meta +2 -2
- package/Runtime/Visuals/UGUI/EnhancedImage.cs +218 -85
- package/Runtime/Visuals/UGUI/EnhancedImage.cs.meta +2 -2
- package/Runtime/Visuals/UGUI.meta +2 -2
- package/Runtime/Visuals/UIToolkit/LayeredImage.cs +781 -484
- package/Runtime/Visuals/UIToolkit/LayeredImage.cs.meta +2 -2
- package/Runtime/Visuals/UIToolkit/MultiFileSelectorElement.cs +945 -322
- package/Runtime/Visuals/UIToolkit/MultiFileSelectorElement.cs.meta +2 -2
- package/Runtime/Visuals/UIToolkit.meta +2 -2
- package/Runtime/Visuals.meta +2 -2
- package/Runtime/WallstopStudios.UnityHelpers.asmdef +22 -14
- package/Runtime/WallstopStudios.UnityHelpers.asmdef.meta +7 -7
- package/Runtime.meta +8 -8
- package/SERIALIZATION.md +648 -0
- package/SERIALIZATION.md.meta +7 -0
- package/SINGLETONS.md +427 -0
- package/SINGLETONS.md.meta +7 -0
- package/SPATIAL_TREES_2D_GUIDE.md +261 -0
- package/SPATIAL_TREES_2D_GUIDE.md.meta +7 -0
- package/SPATIAL_TREES_3D_GUIDE.md +214 -0
- package/SPATIAL_TREES_3D_GUIDE.md.meta +7 -0
- package/SPATIAL_TREE_2D_PERFORMANCE.md +238 -0
- package/SPATIAL_TREE_2D_PERFORMANCE.md.meta +7 -0
- package/SPATIAL_TREE_3D_PERFORMANCE.md +240 -0
- package/SPATIAL_TREE_3D_PERFORMANCE.md.meta +7 -0
- package/SPATIAL_TREE_SEMANTICS.md +106 -0
- package/SPATIAL_TREE_SEMANTICS.md.meta +7 -0
- package/Samples~/DI - VContainer/Prefabs/RelationalConsumer.prefab +77 -0
- package/Samples~/DI - VContainer/Prefabs/RelationalConsumer.prefab.meta +8 -0
- package/Samples~/DI - VContainer/Prefabs/Spawner.prefab +47 -0
- package/Samples~/DI - VContainer/Prefabs/Spawner.prefab.meta +8 -0
- package/Samples~/DI - VContainer/Prefabs.meta +9 -0
- package/Samples~/DI - VContainer/README.md +334 -0
- package/Samples~/DI - VContainer/README.md.meta +8 -0
- package/Samples~/DI - VContainer/Scenes/VContainer_Sample.unity +120 -0
- package/Samples~/DI - VContainer/Scenes/VContainer_Sample.unity.meta +8 -0
- package/Samples~/DI - VContainer/Scenes.meta +9 -0
- package/Samples~/DI - VContainer/Scripts/GameLifetimeScope.cs +24 -0
- package/Samples~/DI - VContainer/Scripts/GameLifetimeScope.cs.meta +12 -0
- package/Samples~/DI - VContainer/Scripts/RelationalConsumer.cs +21 -0
- package/Samples~/DI - VContainer/Scripts/RelationalConsumer.cs.meta +12 -0
- package/Samples~/DI - VContainer/Scripts/Samples.UnityHelpers.DI.VContainer.asmdef +37 -0
- package/Samples~/DI - VContainer/Scripts/Samples.UnityHelpers.DI.VContainer.asmdef.meta +8 -0
- package/Samples~/DI - VContainer/Scripts/Spawner.cs +21 -0
- package/Samples~/DI - VContainer/Scripts/Spawner.cs.meta +12 -0
- package/Samples~/DI - VContainer/Scripts.meta +9 -0
- package/Samples~/DI - VContainer.meta +9 -0
- package/Samples~/DI - Zenject/Prefabs/RelationalConsumer.prefab +77 -0
- package/Samples~/DI - Zenject/Prefabs/RelationalConsumer.prefab.meta +8 -0
- package/Samples~/DI - Zenject/Prefabs/SpawnerZenject.prefab +47 -0
- package/Samples~/DI - Zenject/Prefabs/SpawnerZenject.prefab.meta +8 -0
- package/Samples~/DI - Zenject/Prefabs.meta +9 -0
- package/Samples~/DI - Zenject/README.md +389 -0
- package/Samples~/DI - Zenject/README.md.meta +7 -0
- package/Samples~/DI - Zenject/Scenes/Zenject_Sample.unity +164 -0
- package/Samples~/DI - Zenject/Scenes/Zenject_Sample.unity.meta +8 -0
- package/Samples~/DI - Zenject/Scenes.meta +9 -0
- package/Samples~/DI - Zenject/Scripts/RelationalConsumer.cs +19 -0
- package/Samples~/DI - Zenject/Scripts/RelationalConsumer.cs.meta +12 -0
- package/Samples~/DI - Zenject/Scripts/Samples.UnityHelpers.DI.Zenject.asmdef +36 -0
- package/Samples~/DI - Zenject/Scripts/Samples.UnityHelpers.DI.Zenject.asmdef.meta +8 -0
- package/Samples~/DI - Zenject/Scripts/SceneContextPlaceholder.cs +47 -0
- package/Samples~/DI - Zenject/Scripts/SceneContextPlaceholder.cs.meta +12 -0
- package/Samples~/DI - Zenject/Scripts/SpawnerZenject.cs +20 -0
- package/Samples~/DI - Zenject/Scripts/SpawnerZenject.cs.meta +12 -0
- package/Samples~/DI - Zenject/Scripts.meta +9 -0
- package/Samples~/DI - Zenject.meta +9 -0
- package/Samples~/Random - PRNG/README.md +12 -0
- package/Samples~/Random - PRNG/README.md.meta +8 -0
- package/Samples~/Random - PRNG/Scripts/RandomPrngDemo.cs +28 -0
- package/Samples~/Random - PRNG/Scripts/RandomPrngDemo.cs.meta +12 -0
- package/Samples~/Random - PRNG/Scripts/Samples.UnityHelpers.Random.Prng.asmdef +17 -0
- package/Samples~/Random - PRNG/Scripts/Samples.UnityHelpers.Random.Prng.asmdef.meta +8 -0
- package/Samples~/Random - PRNG/Scripts.meta +9 -0
- package/Samples~/Random - PRNG.meta +9 -0
- package/Samples~/Relational Components - Basic/README.md +19 -0
- package/Samples~/Relational Components - Basic/README.md.meta +8 -0
- package/Samples~/Relational Components - Basic/Scripts/RelationalBasicConsumer.cs +37 -0
- package/Samples~/Relational Components - Basic/Scripts/RelationalBasicConsumer.cs.meta +12 -0
- package/Samples~/Relational Components - Basic/Scripts/Samples.UnityHelpers.Relational.Basic.asmdef +17 -0
- package/Samples~/Relational Components - Basic/Scripts/Samples.UnityHelpers.Relational.Basic.asmdef.meta +8 -0
- package/Samples~/Relational Components - Basic/Scripts.meta +9 -0
- package/Samples~/Relational Components - Basic.meta +9 -0
- package/Samples~/Serialization - JSON/README.md +13 -0
- package/Samples~/Serialization - JSON/README.md.meta +8 -0
- package/Samples~/Serialization - JSON/Scripts/JsonSerializationDemo.cs +50 -0
- package/Samples~/Serialization - JSON/Scripts/JsonSerializationDemo.cs.meta +12 -0
- package/Samples~/Serialization - JSON/Scripts/Samples.UnityHelpers.Serialization.Json.asmdef +17 -0
- package/Samples~/Serialization - JSON/Scripts/Samples.UnityHelpers.Serialization.Json.asmdef.meta +8 -0
- package/Samples~/Serialization - JSON/Scripts.meta +9 -0
- package/Samples~/Serialization - JSON.meta +9 -0
- package/Samples~/Spatial Structures - 2D and 3D/README.md +13 -0
- package/Samples~/Spatial Structures - 2D and 3D/README.md.meta +8 -0
- package/Samples~/Spatial Structures - 2D and 3D/Scripts/Samples.UnityHelpers.SpatialStructures.asmdef +17 -0
- package/Samples~/Spatial Structures - 2D and 3D/Scripts/Samples.UnityHelpers.SpatialStructures.asmdef.meta +8 -0
- package/Samples~/Spatial Structures - 2D and 3D/Scripts/SpatialStructuresDemo.cs +62 -0
- package/Samples~/Spatial Structures - 2D and 3D/Scripts/SpatialStructuresDemo.cs.meta +12 -0
- package/Samples~/Spatial Structures - 2D and 3D/Scripts.meta +9 -0
- package/Samples~/Spatial Structures - 2D and 3D.meta +9 -0
- package/Samples~/UGUI - EnhancedImage/README.md +12 -0
- package/Samples~/UGUI - EnhancedImage/README.md.meta +8 -0
- package/Samples~/UGUI - EnhancedImage/Scripts/EnhancedImageDemo.cs +36 -0
- package/Samples~/UGUI - EnhancedImage/Scripts/EnhancedImageDemo.cs.meta +12 -0
- package/Samples~/UGUI - EnhancedImage/Scripts/Samples.UnityHelpers.UGUI.EnhancedImage.asmdef +17 -0
- package/Samples~/UGUI - EnhancedImage/Scripts/Samples.UnityHelpers.UGUI.EnhancedImage.asmdef.meta +8 -0
- package/Samples~/UGUI - EnhancedImage/Scripts.meta +9 -0
- package/Samples~/UGUI - EnhancedImage.meta +9 -0
- package/Samples~/UI Toolkit - MultiFile Selector (Editor)/README.md +12 -0
- package/Samples~/UI Toolkit - MultiFile Selector (Editor)/README.md.meta +8 -0
- package/Samples~/UI Toolkit - MultiFile Selector (Editor)/Scripts/Editor/MultiFileSelectorSampleWindow.cs +45 -0
- package/Samples~/UI Toolkit - MultiFile Selector (Editor)/Scripts/Editor/MultiFileSelectorSampleWindow.cs.meta +12 -0
- package/Samples~/UI Toolkit - MultiFile Selector (Editor)/Scripts/Editor/Samples.UnityHelpers.UIToolkit.Editor.asmdef +19 -0
- package/Samples~/UI Toolkit - MultiFile Selector (Editor)/Scripts/Editor/Samples.UnityHelpers.UIToolkit.Editor.asmdef.meta +8 -0
- package/Samples~/UI Toolkit - MultiFile Selector (Editor)/Scripts/Editor.meta +9 -0
- package/Samples~/UI Toolkit - MultiFile Selector (Editor)/Scripts.meta +9 -0
- package/Samples~/UI Toolkit - MultiFile Selector (Editor).meta +9 -0
- package/Shaders/Materials/BackgroundMask-Material.mat +59 -59
- package/Shaders/Materials/BackgroundMask-Material.mat.meta +8 -8
- package/Shaders/Materials.meta +8 -8
- package/Shaders/ShaderGraph/BackgroundMask.shadergraph +1653 -1653
- package/Shaders/ShaderGraph/BackgroundMask.shadergraph.meta +10 -10
- package/Shaders/ShaderGraph/DebugDisplayValue.shadersubgraph +835 -835
- package/Shaders/ShaderGraph/DebugDisplayValue.shadersubgraph.meta +10 -10
- package/Shaders/ShaderGraph.meta +8 -8
- package/Shaders/Support/EnhancedImageSupport.shader +64 -0
- package/Shaders/Support/EnhancedImageSupport.shader.meta +9 -0
- package/Shaders/Support.meta +8 -0
- package/Shaders.meta +8 -8
- package/Styles/Elements/Progress/ArcedProgressBar.cs +345 -345
- package/Styles/Elements/Progress/ArcedProgressBar.cs.meta +2 -2
- package/Styles/Elements/Progress/CircularProgressBar.cs +307 -307
- package/Styles/Elements/Progress/CircularProgressBar.cs.meta +2 -2
- package/Styles/Elements/Progress/GlitchProgressBar.cs +416 -416
- package/Styles/Elements/Progress/GlitchProgressBar.cs.meta +2 -2
- package/Styles/Elements/Progress/LiquidProgressBar.cs +632 -632
- package/Styles/Elements/Progress/LiquidProgressBar.cs.meta +2 -2
- package/Styles/Elements/Progress/MarchingAntsProgressBar.cs +722 -722
- package/Styles/Elements/Progress/MarchingAntsProgressBar.cs.meta +2 -2
- package/Styles/Elements/Progress/RegularProgressBar.cs +405 -405
- package/Styles/Elements/Progress/RegularProgressBar.cs.meta +2 -2
- package/Styles/Elements/Progress/WigglyProgressBar.cs +837 -837
- package/Styles/Elements/Progress/WigglyProgressBar.cs.meta +2 -2
- package/Styles/Elements/Progress.meta +2 -2
- package/Styles/Elements.meta +2 -2
- package/Styles/USS/ArcedProgressBar.uss +18 -18
- package/Styles/USS/ArcedProgressBar.uss.meta +2 -2
- package/Styles/USS/CirclularProgressBar.uss +17 -17
- package/Styles/USS/CirclularProgressBar.uss.meta +2 -2
- package/Styles/USS/RegularProgressBar.uss +32 -32
- package/Styles/USS/RegularProgressBar.uss.meta +2 -2
- package/Styles/USS/WigglyProgressBar.uss +16 -16
- package/Styles/USS/WigglyProgressBar.uss.meta +2 -2
- package/Styles/USS.meta +2 -2
- package/Styles/WallstopStudios.UnityHelpers.Styles.asmdef +14 -17
- package/Styles/WallstopStudios.UnityHelpers.Styles.asmdef.meta +7 -7
- package/Styles.meta +2 -2
- package/THIRD_PARTY_NOTICES.md +74 -0
- package/THIRD_PARTY_NOTICES.md.meta +7 -0
- package/Tests/Editor/Attributes/AnimationEventHelpersTests.cs +155 -0
- package/Tests/Editor/Attributes/AnimationEventHelpersTests.cs.meta +11 -0
- package/Tests/Editor/Attributes.meta +8 -0
- package/Tests/Editor/Core/Attributes/RelationalComponentAssignerTests.cs +118 -0
- package/Tests/Editor/Core/Attributes/RelationalComponentAssignerTests.cs.meta +11 -0
- package/Tests/Editor/Core/Attributes.meta +8 -0
- package/Tests/Editor/Core.meta +8 -0
- package/Tests/Editor/Extensions/SerializedPropertyExtensionsTests.cs +194 -0
- package/Tests/Editor/Extensions/SerializedPropertyExtensionsTests.cs.meta +3 -0
- package/Tests/Editor/Extensions.meta +3 -0
- package/Tests/Editor/Helper/DummyScriptableObject.cs +6 -0
- package/Tests/Editor/Helper/DummyScriptableObject.cs.meta +3 -0
- package/Tests/Editor/Helper/HelpersTests.cs +101 -0
- package/Tests/Editor/Helper/HelpersTests.cs.meta +3 -0
- package/Tests/Editor/Helper/ObjectHelpersEditorTests.cs +63 -0
- package/Tests/Editor/Helper/ObjectHelpersEditorTests.cs.meta +11 -0
- package/Tests/Editor/Helper/PromptScope.cs +28 -0
- package/Tests/Editor/Helper/PromptScope.cs.meta +11 -0
- package/Tests/Editor/Helper/ReflectionHelpersEditorTests.cs +105 -0
- package/Tests/Editor/Helper/ReflectionHelpersEditorTests.cs.meta +11 -0
- package/Tests/Editor/Helper/SpriteHelpersTests.cs +334 -0
- package/Tests/Editor/Helper/SpriteHelpersTests.cs.meta +3 -0
- package/Tests/Editor/Helper/SpriteSettingsApplierAdditionalTests.cs +183 -0
- package/Tests/Editor/Helper/SpriteSettingsApplierAdditionalTests.cs.meta +11 -0
- package/Tests/Editor/Helper/SpriteSettingsApplierTests.cs +161 -0
- package/Tests/Editor/Helper/SpriteSettingsApplierTests.cs.meta +11 -0
- package/Tests/Editor/Helper.meta +3 -0
- package/Tests/Editor/Integrations/VContainer/VContainerIntegrationCompilationTests.cs +40 -0
- package/Tests/Editor/Integrations/VContainer/VContainerIntegrationCompilationTests.cs.meta +11 -0
- package/Tests/Editor/Integrations/VContainer/VContainerRelationalEntryPointTests.cs +77 -0
- package/Tests/Editor/Integrations/VContainer/VContainerRelationalEntryPointTests.cs.meta +11 -0
- package/Tests/Editor/Integrations/VContainer/WallstopStudios.UnityHelpers.Tests.Editor.VContainer.asmdef +36 -0
- package/Tests/Editor/Integrations/VContainer/WallstopStudios.UnityHelpers.Tests.Editor.VContainer.asmdef.meta +7 -0
- package/Tests/Editor/Integrations/VContainer.meta +8 -0
- package/Tests/Editor/Integrations/Zenject/WallstopStudios.UnityHelpers.Tests.Editor.Zenject.asmdef +36 -0
- package/Tests/Editor/Integrations/Zenject/WallstopStudios.UnityHelpers.Tests.Editor.Zenject.asmdef.meta +7 -0
- package/Tests/Editor/Integrations/Zenject/ZenjectIntegrationCompilationTests.cs +40 -0
- package/Tests/Editor/Integrations/Zenject/ZenjectIntegrationCompilationTests.cs.meta +11 -0
- package/Tests/Editor/Integrations/Zenject/ZenjectRelationalInitializerTests.cs +76 -0
- package/Tests/Editor/Integrations/Zenject/ZenjectRelationalInitializerTests.cs.meta +11 -0
- package/Tests/Editor/Integrations/Zenject.meta +8 -0
- package/Tests/Editor/Integrations.meta +8 -0
- package/Tests/Editor/MultiFileSelectorElementTests.cs +265 -0
- package/Tests/Editor/MultiFileSelectorElementTests.cs.meta +11 -0
- package/Tests/Editor/MultiFileSelectorPersistenceManagerTests.cs +100 -0
- package/Tests/Editor/MultiFileSelectorPersistenceManagerTests.cs.meta +11 -0
- package/Tests/Editor/Sprites/AnimationCopierWindowTests.cs +199 -0
- package/Tests/Editor/Sprites/AnimationCopierWindowTests.cs.meta +11 -0
- package/Tests/Editor/Sprites/ScriptableSpriteAtlasEditorTests.cs +108 -0
- package/Tests/Editor/Sprites/ScriptableSpriteAtlasEditorTests.cs.meta +11 -0
- package/Tests/Editor/Sprites/SpriteCropperAdditionalTests.cs +323 -0
- package/Tests/Editor/Sprites/SpriteCropperAdditionalTests.cs.meta +11 -0
- package/Tests/Editor/Sprites/SpriteCropperTests.cs +162 -0
- package/Tests/Editor/Sprites/SpriteCropperTests.cs.meta +11 -0
- package/Tests/Editor/Sprites/SpritePivotAdjusterAdditionalTests.cs +227 -0
- package/Tests/Editor/Sprites/SpritePivotAdjusterAdditionalTests.cs.meta +11 -0
- package/Tests/Editor/Sprites/SpritePivotAdjusterTests.cs +113 -0
- package/Tests/Editor/Sprites/SpritePivotAdjusterTests.cs.meta +11 -0
- package/Tests/Editor/Sprites/TexturePlatformNameHelperTests.cs +28 -0
- package/Tests/Editor/Sprites/TexturePlatformNameHelperTests.cs.meta +11 -0
- package/Tests/Editor/Sprites/TextureResizerWizardTests.cs +248 -0
- package/Tests/Editor/Sprites/TextureResizerWizardTests.cs.meta +11 -0
- package/Tests/Editor/Sprites/TextureSettingsApplierAPITests.cs +180 -0
- package/Tests/Editor/Sprites/TextureSettingsApplierAPITests.cs.meta +11 -0
- package/Tests/Editor/Sprites/TextureSettingsApplierWizardAdditionalTests.cs +295 -0
- package/Tests/Editor/Sprites/TextureSettingsApplierWizardAdditionalTests.cs.meta +11 -0
- package/Tests/Editor/Sprites/TextureSettingsApplierWizardTests.cs +134 -0
- package/Tests/Editor/Sprites/TextureSettingsApplierWizardTests.cs.meta +11 -0
- package/Tests/Editor/Sprites.meta +8 -0
- package/Tests/Editor/TestComponents/PrewarmTesterComponent.cs +10 -0
- package/Tests/Editor/TestComponents/PrewarmTesterComponent.cs.meta +11 -0
- package/Tests/Editor/TestComponents.meta +8 -0
- package/Tests/Editor/Tools/ImageBlurToolTests.cs +135 -0
- package/Tests/Editor/Tools/ImageBlurToolTests.cs.meta +11 -0
- package/Tests/Editor/Tools.meta +8 -0
- package/Tests/Editor/Utils/CommonTestBase.cs +208 -0
- package/Tests/Editor/Utils/CommonTestBase.cs.meta +11 -0
- package/Tests/Editor/Utils/ScriptableObjectSingletonCreatorEditorTests.cs +306 -0
- package/Tests/Editor/Utils/ScriptableObjectSingletonCreatorEditorTests.cs.meta +9 -0
- package/Tests/Editor/Utils/ScriptableObjectSingletonCreatorTests.cs +183 -0
- package/Tests/Editor/Utils/ScriptableObjectSingletonCreatorTests.cs.meta +11 -0
- package/Tests/Editor/Utils/ScriptableObjectSingletonTests.cs +466 -0
- package/Tests/Editor/Utils/ScriptableObjectSingletonTests.cs.meta +11 -0
- package/Tests/Editor/Utils.meta +3 -0
- package/Tests/Editor/WallstopStudios.UnityHelpers.Tests.Editor.asmdef +19 -0
- package/Tests/Editor/WallstopStudios.UnityHelpers.Tests.Editor.asmdef.meta +7 -0
- package/Tests/Editor/Windows/FitTextureSizeWindowTests.cs +781 -0
- package/Tests/Editor/Windows/FitTextureSizeWindowTests.cs.meta +11 -0
- package/Tests/Editor/Windows/PrefabCheckerFolderAdditionTests.cs +96 -0
- package/Tests/Editor/Windows/PrefabCheckerFolderAdditionTests.cs.meta +11 -0
- package/Tests/Editor/Windows/PrefabCheckerTests.cs +81 -0
- package/Tests/Editor/Windows/PrefabCheckerTests.cs.meta +11 -0
- package/Tests/Editor/Windows.meta +8 -0
- package/Tests/Editor.meta +8 -0
- package/Tests/Runtime/AssemblyInfo.cs +4 -0
- package/Tests/Runtime/AssemblyInfo.cs.meta +3 -0
- package/Tests/Runtime/Attributes/ChildComponentTests.cs +766 -81
- package/Tests/Runtime/Attributes/ChildComponentTests.cs.meta +2 -2
- package/Tests/Runtime/Attributes/Components/ExpectChildSpriteRenderers.cs +28 -28
- package/Tests/Runtime/Attributes/Components/ExpectChildSpriteRenderers.cs.meta +2 -2
- package/Tests/Runtime/Attributes/Components/ExpectParentSpriteRenderers.cs +28 -28
- package/Tests/Runtime/Attributes/Components/ExpectParentSpriteRenderers.cs.meta +2 -2
- package/Tests/Runtime/{Components → Attributes/Components}/RelationalComponentTesterComplex.cs +34 -34
- package/Tests/Runtime/{Components → Attributes/Components}/RelationalComponentTesterComplex.cs.meta +2 -2
- package/Tests/Runtime/Attributes/Components/RelationalComponentsTesterSimple.cs +37 -0
- package/Tests/Runtime/{Components → Attributes/Components}/RelationalComponentsTesterSimple.cs.meta +2 -2
- package/Tests/Runtime/Attributes/Components.meta +2 -2
- package/Tests/Runtime/Attributes/MiscRuntimeAttributeTests.cs +75 -0
- package/Tests/Runtime/Attributes/MiscRuntimeAttributeTests.cs.meta +11 -0
- package/Tests/Runtime/Attributes/NotNullAttributeTests.cs +26 -0
- package/Tests/Runtime/Attributes/NotNullAttributeTests.cs.meta +3 -0
- package/Tests/Runtime/Attributes/ParentComponentTests.cs +565 -68
- package/Tests/Runtime/Attributes/ParentComponentTests.cs.meta +2 -2
- package/Tests/Runtime/Attributes/RelationalComponentAdvancedTests.cs +614 -0
- package/Tests/Runtime/Attributes/RelationalComponentAdvancedTests.cs.meta +11 -0
- package/Tests/Runtime/Attributes/RelationalComponentBackwardCompatibilityTests.cs +478 -0
- package/Tests/Runtime/Attributes/RelationalComponentBackwardCompatibilityTests.cs.meta +11 -0
- package/Tests/Runtime/Attributes/RelationalComponentExtensionsTests.cs +56 -0
- package/Tests/Runtime/Attributes/RelationalComponentExtensionsTests.cs.meta +11 -0
- package/Tests/Runtime/Attributes/RelationalComponentHashSetTests.cs +226 -0
- package/Tests/Runtime/Attributes/RelationalComponentHashSetTests.cs.meta +11 -0
- package/Tests/Runtime/Attributes/RelationalComponentInitializerTests.cs +109 -0
- package/Tests/Runtime/Attributes/RelationalComponentInitializerTests.cs.meta +11 -0
- package/Tests/Runtime/Attributes/RelationalComponentTagAndNameFilterEdgeTests.cs +234 -0
- package/Tests/Runtime/Attributes/RelationalComponentTagAndNameFilterEdgeTests.cs.meta +11 -0
- package/Tests/Runtime/Attributes/SiblingComponentTests.cs +721 -0
- package/Tests/Runtime/Attributes/SiblingComponentTests.cs.meta +11 -0
- package/Tests/Runtime/Attributes/ValidateAssignmentAttributeTests.cs +96 -0
- package/Tests/Runtime/Attributes/ValidateAssignmentAttributeTests.cs.meta +11 -0
- package/Tests/Runtime/Attributes.meta +2 -2
- package/Tests/Runtime/Core/Random/RandomComparerTests.cs +166 -0
- package/Tests/Runtime/Core/Random/RandomComparerTests.cs.meta +11 -0
- package/Tests/Runtime/Core/Random.meta +8 -0
- package/Tests/Runtime/Core/Threading/SingleThreadedThreadPoolTests.cs +56 -56
- package/Tests/Runtime/Core/Threading/SingleThreadedThreadPoolTests.cs.meta +2 -2
- package/Tests/Runtime/Core/Threading.meta +2 -2
- package/Tests/Runtime/Core.meta +2 -2
- package/Tests/Runtime/DataStructures/BalancedKDTree2DTests.cs +562 -0
- package/Tests/Runtime/DataStructures/{BalancedKDTreeTests.cs.meta → BalancedKDTree2DTests.cs.meta} +11 -11
- package/Tests/Runtime/DataStructures/BalancedKDTree3DTests.cs +10 -0
- package/Tests/Runtime/DataStructures/BalancedKDTree3DTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/BitSetTests.cs +1400 -0
- package/Tests/Runtime/DataStructures/BitSetTests.cs.meta +3 -0
- package/Tests/Runtime/DataStructures/BoundingBox3DTests.cs +1215 -0
- package/Tests/Runtime/DataStructures/BoundingBox3DTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/CircleTests.cs +965 -0
- package/Tests/Runtime/DataStructures/CircleTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/CyclicBufferTests.cs +2083 -324
- package/Tests/Runtime/DataStructures/CyclicBufferTests.cs.meta +2 -2
- package/Tests/Runtime/DataStructures/DequeTests.cs +790 -0
- package/Tests/Runtime/DataStructures/DequeTests.cs.meta +3 -0
- package/Tests/Runtime/DataStructures/DisjointSetTests.cs +1114 -0
- package/Tests/Runtime/DataStructures/DisjointSetTests.cs.meta +3 -0
- package/Tests/Runtime/DataStructures/FastOneOfTests.cs +966 -0
- package/Tests/Runtime/DataStructures/FastOneOfTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/FastVector2IntTests.cs +286 -0
- package/Tests/Runtime/DataStructures/FastVector2IntTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/FastVector3IntTests.cs +414 -0
- package/Tests/Runtime/DataStructures/FastVector3IntTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/HeapTests.cs +1953 -0
- package/Tests/Runtime/DataStructures/HeapTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/ImmutableBitSetTests.cs +833 -0
- package/Tests/Runtime/DataStructures/ImmutableBitSetTests.cs.meta +3 -0
- package/Tests/Runtime/DataStructures/KDTree3DTestsBase.cs +297 -0
- package/Tests/Runtime/DataStructures/KDTree3DTestsBase.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/OctTree3DTests.cs +351 -0
- package/Tests/Runtime/DataStructures/OctTree3DTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/PriorityQueueTests.cs +71 -0
- package/Tests/Runtime/DataStructures/PriorityQueueTests.cs.meta +3 -0
- package/Tests/Runtime/DataStructures/ProtobufSerializationTests.cs +475 -0
- package/Tests/Runtime/DataStructures/ProtobufSerializationTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/QuadTree2DTests.cs +660 -0
- package/Tests/Runtime/DataStructures/QuadTree2DTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/RTree2DTests.cs +823 -0
- package/Tests/Runtime/DataStructures/RTree2DTests.cs.meta +3 -0
- package/Tests/Runtime/DataStructures/RTree3DTests.cs +270 -0
- package/Tests/Runtime/DataStructures/RTree3DTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/SparseSetTests.cs +1146 -0
- package/Tests/Runtime/DataStructures/SparseSetTests.cs.meta +3 -0
- package/Tests/Runtime/DataStructures/SpatialHashTests.cs +992 -0
- package/Tests/Runtime/DataStructures/SpatialHashTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/SpatialTree2DBoundsConsistencyTests.cs +351 -0
- package/Tests/Runtime/DataStructures/SpatialTree2DBoundsConsistencyTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/SpatialTree2DBoundsEdgeTests.cs +127 -0
- package/Tests/Runtime/DataStructures/SpatialTree2DBoundsEdgeTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/SpatialTree2DBoundsFuzzTests.cs +218 -0
- package/Tests/Runtime/DataStructures/SpatialTree2DBoundsFuzzTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/SpatialTree2DTests.cs +396 -0
- package/Tests/Runtime/DataStructures/SpatialTree2DTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/SpatialTree3DBoundsConsistencyTests.cs +281 -0
- package/Tests/Runtime/DataStructures/SpatialTree3DBoundsConsistencyTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/SpatialTree3DBoundsEdgeTests.cs +127 -0
- package/Tests/Runtime/DataStructures/SpatialTree3DBoundsEdgeTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/SpatialTree3DBoundsFuzzTests.cs +170 -0
- package/Tests/Runtime/DataStructures/SpatialTree3DBoundsFuzzTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/SpatialTree3DTests.cs +474 -0
- package/Tests/Runtime/DataStructures/SpatialTree3DTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/SphereTests.cs +806 -0
- package/Tests/Runtime/DataStructures/SphereTests.cs.meta +3 -0
- package/Tests/Runtime/DataStructures/StringWrapperTests.cs +333 -0
- package/Tests/Runtime/DataStructures/StringWrapperTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/TimedCacheTests.cs +669 -0
- package/Tests/Runtime/DataStructures/TimedCacheTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/TrieTests.cs +3385 -0
- package/Tests/Runtime/DataStructures/TrieTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/UnbalancedKDTree2DTests.cs +565 -0
- package/Tests/Runtime/DataStructures/{UnbalancedKDTreeTests.cs.meta → UnbalancedKDTree2DTests.cs.meta} +11 -11
- package/Tests/Runtime/DataStructures/UnbalancedKDTree3DTests.cs +10 -0
- package/Tests/Runtime/DataStructures/UnbalancedKDTree3DTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures.meta +8 -8
- package/Tests/Runtime/Extensions/AnimatorExtensionsTests.cs +28 -0
- package/Tests/Runtime/Extensions/AnimatorExtensionsTests.cs.meta +11 -0
- package/Tests/Runtime/Extensions/AsyncOperationExtensionsTests.cs +667 -0
- package/Tests/Runtime/Extensions/AsyncOperationExtensionsTests.cs.meta +11 -0
- package/Tests/Runtime/Extensions/CircleExtensionsTests.cs +230 -0
- package/Tests/Runtime/Extensions/CircleExtensionsTests.cs.meta +11 -0
- package/Tests/Runtime/Extensions/ColorExtensionsTests.cs +55 -0
- package/Tests/Runtime/Extensions/ColorExtensionsTests.cs.meta +11 -0
- package/Tests/Runtime/Extensions/DictionaryExtensionTests.cs +724 -438
- package/Tests/Runtime/Extensions/DictionaryExtensionTests.cs.meta +2 -2
- package/Tests/Runtime/Extensions/DirectionExtensionsComprehensiveTests.cs +403 -0
- package/Tests/Runtime/Extensions/DirectionExtensionsComprehensiveTests.cs.meta +11 -0
- package/Tests/Runtime/Extensions/DirectionExtensionsTests.cs +69 -0
- package/Tests/Runtime/Extensions/DirectionExtensionsTests.cs.meta +11 -0
- package/Tests/Runtime/Extensions/EnumExtensionTests.cs +809 -153
- package/Tests/Runtime/Extensions/EnumExtensionTests.cs.meta +2 -2
- package/Tests/Runtime/Extensions/IEnumerableExtensionsTests.cs +191 -0
- package/Tests/Runtime/Extensions/IEnumerableExtensionsTests.cs.meta +11 -0
- package/Tests/Runtime/Extensions/IListExtensionTests.cs +955 -169
- package/Tests/Runtime/Extensions/IListExtensionTests.cs.meta +2 -2
- package/Tests/Runtime/Extensions/IReadonlyListExtensionTests.cs +266 -58
- package/Tests/Runtime/Extensions/IReadonlyListExtensionTests.cs.meta +2 -2
- package/Tests/Runtime/Extensions/LoggingExtensionTests.cs +721 -718
- package/Tests/Runtime/Extensions/LoggingExtensionTests.cs.meta +2 -2
- package/Tests/Runtime/Extensions/ProtoEqualityExtensionsTests.cs +565 -0
- package/Tests/Runtime/Extensions/ProtoEqualityExtensionsTests.cs.meta +3 -0
- package/Tests/Runtime/Extensions/ProtoEqualityPolymorphismTests.cs +100 -0
- package/Tests/Runtime/Extensions/ProtoEqualityPolymorphismTests.cs.meta +11 -0
- package/Tests/Runtime/Extensions/RandomExtensionTests.cs +719 -27
- package/Tests/Runtime/Extensions/RandomExtensionTests.cs.meta +2 -2
- package/Tests/Runtime/Extensions/StringExtensionTests.cs +2592 -31
- package/Tests/Runtime/Extensions/StringExtensionTests.cs.meta +2 -2
- package/Tests/Runtime/Extensions/UnityExtensionsBasicTests.cs +166 -0
- package/Tests/Runtime/Extensions/UnityExtensionsBasicTests.cs.meta +11 -0
- package/Tests/Runtime/Extensions/UnityExtensionsComprehensiveTests.cs +1446 -0
- package/Tests/Runtime/Extensions/UnityExtensionsComprehensiveTests.cs.meta +11 -0
- package/Tests/Runtime/Extensions/UnityExtensionsMathTests.cs +1779 -0
- package/Tests/Runtime/Extensions/UnityExtensionsMathTests.cs.meta +11 -0
- package/Tests/Runtime/Extensions/UnityExtensionsVector2HullTests.cs +292 -0
- package/Tests/Runtime/Extensions/UnityExtensionsVector2HullTests.cs.meta +11 -0
- package/Tests/Runtime/Extensions/UnityLogTagFormatterEdgeTests.cs +260 -0
- package/Tests/Runtime/Extensions/UnityLogTagFormatterEdgeTests.cs.meta +11 -0
- package/Tests/Runtime/Extensions.meta +2 -2
- package/Tests/Runtime/Helper/ArrayConverterTests.cs +19 -19
- package/Tests/Runtime/Helper/ArrayConverterTests.cs.meta +2 -2
- package/Tests/Runtime/Helper/AssignUtilitiesTests.cs +38 -0
- package/Tests/Runtime/Helper/AssignUtilitiesTests.cs.meta +11 -0
- package/Tests/Runtime/Helper/DirectoryHelperTests.cs +347 -0
- package/Tests/Runtime/Helper/DirectoryHelperTests.cs.meta +11 -0
- package/Tests/Runtime/Helper/EnumerablesTests.cs +45 -0
- package/Tests/Runtime/Helper/EnumerablesTests.cs.meta +11 -0
- package/Tests/Runtime/Helper/FileHelperTests.cs +481 -0
- package/Tests/Runtime/Helper/FileHelperTests.cs.meta +11 -0
- package/Tests/Runtime/Helper/FormattingHelpersTests.cs +353 -0
- package/Tests/Runtime/Helper/FormattingHelpersTests.cs.meta +11 -0
- package/Tests/Runtime/Helper/FuncBasedComparerTests.cs +27 -0
- package/Tests/Runtime/Helper/FuncBasedComparerTests.cs.meta +11 -0
- package/Tests/Runtime/Helper/GeometryTests.cs +517 -0
- package/Tests/Runtime/Helper/GeometryTests.cs.meta +3 -0
- package/Tests/Runtime/Helper/HelpersTests.cs +749 -0
- package/Tests/Runtime/Helper/HelpersTests.cs.meta +11 -0
- package/Tests/Runtime/Helper/IterationHelpersTests.cs +173 -0
- package/Tests/Runtime/Helper/IterationHelpersTests.cs.meta +11 -0
- package/Tests/Runtime/Helper/LineHelperTests.cs +662 -0
- package/Tests/Runtime/Helper/LineHelperTests.cs.meta +11 -0
- package/Tests/Runtime/Helper/ObjectHelperTests.cs +444 -432
- package/Tests/Runtime/Helper/ObjectHelperTests.cs.meta +2 -2
- package/Tests/Runtime/Helper/ObjectsTests.cs +363 -0
- package/Tests/Runtime/Helper/ObjectsTests.cs.meta +3 -0
- package/Tests/Runtime/Helper/PathHelperTests.cs +183 -0
- package/Tests/Runtime/Helper/PathHelperTests.cs.meta +11 -0
- package/Tests/Runtime/Helper/ReflectionHelperTests.cs +2199 -1493
- package/Tests/Runtime/Helper/ReflectionHelperTests.cs.meta +2 -2
- package/Tests/Runtime/Helper/ReflectionHelpersMemberLookupTests.cs +192 -0
- package/Tests/Runtime/Helper/ReflectionHelpersMemberLookupTests.cs.meta +11 -0
- package/Tests/Runtime/Helper/ReflectionHelpersTypeScanningTests.cs +58 -0
- package/Tests/Runtime/Helper/ReflectionHelpersTypeScanningTests.cs.meta +11 -0
- package/Tests/Runtime/Helper/SceneHelperTests.cs +77 -94
- package/Tests/Runtime/Helper/SceneHelperTests.cs.meta +2 -2
- package/Tests/Runtime/Helper/UnityMainThreadDispatcherTests.cs +45 -0
- package/Tests/Runtime/Helper/UnityMainThreadDispatcherTests.cs.meta +11 -0
- package/Tests/Runtime/Helper/WallMathTests.cs +1884 -233
- package/Tests/Runtime/Helper/WallMathTests.cs.meta +2 -2
- package/Tests/Runtime/Helper.meta +2 -2
- package/Tests/Runtime/Integrations/VContainer/RelationalComponentsVContainerTests.cs +560 -0
- package/Tests/Runtime/Integrations/VContainer/RelationalComponentsVContainerTests.cs.meta +11 -0
- package/Tests/Runtime/Integrations/VContainer/WallstopStudios.UnityHelpers.Tests.Runtime.VContainer.asmdef +38 -0
- package/Tests/Runtime/Integrations/VContainer/WallstopStudios.UnityHelpers.Tests.Runtime.VContainer.asmdef.meta +7 -0
- package/Tests/Runtime/Integrations/VContainer.meta +8 -0
- package/Tests/Runtime/Integrations/Zenject/RelationalComponentsZenjectTests.cs +591 -0
- package/Tests/Runtime/Integrations/Zenject/RelationalComponentsZenjectTests.cs.meta +11 -0
- package/Tests/Runtime/Integrations/Zenject/WallstopStudios.UnityHelpers.Tests.Runtime.Zenject.asmdef +38 -0
- package/Tests/Runtime/Integrations/Zenject/WallstopStudios.UnityHelpers.Tests.Runtime.Zenject.asmdef.meta +7 -0
- package/Tests/Runtime/Integrations/Zenject.meta +8 -0
- package/Tests/Runtime/Integrations.meta +8 -0
- package/Tests/Runtime/Math/Line2DTests.cs +594 -0
- package/Tests/Runtime/Math/Line2DTests.cs.meta +11 -0
- package/Tests/Runtime/Math/Line3DTests.cs +655 -0
- package/Tests/Runtime/Math/Line3DTests.cs.meta +11 -0
- package/Tests/Runtime/Math/LineTests.cs +480 -0
- package/Tests/Runtime/Math/LineTests.cs.meta +11 -0
- package/Tests/Runtime/Math/ParabolaTests.cs +477 -0
- package/Tests/Runtime/Math/ParabolaTests.cs.meta +11 -0
- package/Tests/Runtime/Math/PointPolygonCheckTests.cs +939 -0
- package/Tests/Runtime/Math/PointPolygonCheckTests.cs.meta +11 -0
- package/Tests/Runtime/Math/RangeTests.cs +197 -0
- package/Tests/Runtime/Math/RangeTests.cs.meta +11 -0
- package/Tests/Runtime/Math.meta +8 -0
- package/Tests/Runtime/Performance/BenchmarkReadmeUpdater.cs +81 -0
- package/Tests/Runtime/Performance/BenchmarkReadmeUpdater.cs.meta +11 -0
- package/Tests/Runtime/Performance/JsonSerializationPerformanceTests.cs +421 -0
- package/Tests/Runtime/Performance/JsonSerializationPerformanceTests.cs.meta +3 -0
- package/Tests/Runtime/Performance/ListExtensionPerformanceTests.cs +76 -76
- package/Tests/Runtime/Performance/ListExtensionPerformanceTests.cs.meta +2 -2
- package/Tests/Runtime/Performance/ProtoEqualsPerformanceTests.cs +161 -0
- package/Tests/Runtime/Performance/ProtoEqualsPerformanceTests.cs.meta +11 -0
- package/Tests/Runtime/Performance/ProtoSerializationPerformanceTests.cs +207 -0
- package/Tests/Runtime/Performance/ProtoSerializationPerformanceTests.cs.meta +3 -0
- package/Tests/Runtime/Performance/RandomPerformanceTests.cs +195 -181
- package/Tests/Runtime/Performance/RandomPerformanceTests.cs.meta +11 -11
- package/Tests/Runtime/Performance/RelationComponentPerformanceTests.cs +60 -61
- package/Tests/Runtime/Performance/RelationComponentPerformanceTests.cs.meta +2 -2
- package/Tests/Runtime/Performance/SpatialTree2DPerformanceTests.cs +692 -0
- package/Tests/Runtime/Performance/SpatialTree2DPerformanceTests.cs.meta +11 -0
- package/Tests/Runtime/Performance/SpatialTree3DPerformanceTests.cs +650 -0
- package/Tests/Runtime/Performance/SpatialTree3DPerformanceTests.cs.meta +11 -0
- package/Tests/Runtime/Performance.meta +8 -8
- package/Tests/Runtime/Random/DotNetRandomTests.cs +9 -9
- package/Tests/Runtime/Random/DotNetRandomTests.cs.meta +2 -2
- package/Tests/Runtime/Random/IllusionFlowTests.cs +12 -12
- package/Tests/Runtime/Random/IllusionFlowTests.cs.meta +2 -2
- package/Tests/Runtime/Random/LinearCongruentialGeneratorTests.cs +12 -12
- package/Tests/Runtime/Random/LinearCongruentialGeneratorTests.cs.meta +2 -2
- package/Tests/Runtime/Random/PcgRandomTests.cs +9 -9
- package/Tests/Runtime/Random/PcgRandomTests.cs.meta +11 -11
- package/Tests/Runtime/Random/RandomProtoSerializationTests.cs +494 -0
- package/Tests/Runtime/Random/RandomProtoSerializationTests.cs.meta +3 -0
- package/Tests/Runtime/Random/RandomStateSerializationTests.cs +304 -0
- package/Tests/Runtime/Random/RandomStateSerializationTests.cs.meta +4 -0
- package/Tests/Runtime/Random/RandomTestBase.cs +836 -787
- package/Tests/Runtime/Random/RandomTestBase.cs.meta +11 -11
- package/Tests/Runtime/Random/RomuDuoRandomTests.cs +9 -9
- package/Tests/Runtime/Random/RomuDuoRandomTests.cs.meta +2 -2
- package/Tests/Runtime/Random/SplitMix64RandomTests.cs +9 -9
- package/Tests/Runtime/Random/SplitMix64RandomTests.cs.meta +2 -2
- package/Tests/Runtime/Random/SquirrelRandomTests.cs +14 -14
- package/Tests/Runtime/Random/SquirrelRandomTests.cs.meta +11 -11
- package/Tests/Runtime/Random/SystemRandomTests.cs +10 -10
- package/Tests/Runtime/Random/SystemRandomTests.cs.meta +11 -11
- package/Tests/Runtime/Random/UnityRandomTests.cs +9 -9
- package/Tests/Runtime/Random/UnityRandomTests.cs.meta +11 -11
- package/Tests/Runtime/Random/WyRandomTests.cs +9 -9
- package/Tests/Runtime/Random/WyRandomTests.cs.meta +2 -2
- package/Tests/Runtime/Random/XorShiftRandomTests.cs +9 -9
- package/Tests/Runtime/Random/XorShiftRandomTests.cs.meta +11 -11
- package/Tests/Runtime/Random/XoroShiroRandomTests.cs +9 -9
- package/Tests/Runtime/Random/XoroShiroRandomTests.cs.meta +2 -2
- package/Tests/Runtime/Random.meta +8 -8
- package/Tests/Runtime/RuntimeTestTimeouts.cs +3 -0
- package/Tests/Runtime/RuntimeTestTimeouts.cs.meta +11 -0
- package/Tests/Runtime/Scenes/Test1.unity +723 -723
- package/Tests/Runtime/Scenes/Test1.unity.meta +7 -7
- package/Tests/Runtime/Scenes/Test2.unity +723 -723
- package/Tests/Runtime/Scenes/Test2.unity.meta +7 -7
- package/Tests/Runtime/Scenes.meta +2 -2
- package/Tests/Runtime/Serialization/AdaptersJsonTests.cs +67 -0
- package/Tests/Runtime/Serialization/AdaptersJsonTests.cs.meta +11 -0
- package/Tests/Runtime/Serialization/BitSetJsonTests.cs +50 -0
- package/Tests/Runtime/Serialization/BitSetJsonTests.cs.meta +11 -0
- package/Tests/Runtime/Serialization/CyclicBufferJsonTests.cs +67 -0
- package/Tests/Runtime/Serialization/CyclicBufferJsonTests.cs.meta +11 -0
- package/Tests/Runtime/Serialization/DequeJsonTests.cs +70 -0
- package/Tests/Runtime/Serialization/DequeJsonTests.cs.meta +11 -0
- package/Tests/Runtime/Serialization/ImmutableBitSetJsonTests.cs +25 -0
- package/Tests/Runtime/Serialization/ImmutableBitSetJsonTests.cs.meta +11 -0
- package/Tests/Runtime/Serialization/JsonConverterTests.cs +1157 -0
- package/Tests/Runtime/Serialization/JsonConverterTests.cs.meta +11 -0
- package/Tests/Runtime/Serialization/JsonRoundtripComprehensiveTests.cs +239 -0
- package/Tests/Runtime/Serialization/JsonRoundtripComprehensiveTests.cs.meta +11 -0
- package/Tests/Runtime/Serialization/JsonSerializationCorrectnessTests.cs +458 -0
- package/Tests/Runtime/Serialization/JsonSerializationCorrectnessTests.cs.meta +3 -0
- package/Tests/Runtime/Serialization/JsonSerializationTest.cs +156 -156
- package/Tests/Runtime/Serialization/JsonSerializationTest.cs.meta +2 -2
- package/Tests/Runtime/Serialization/MathJsonTests.cs +79 -0
- package/Tests/Runtime/Serialization/MathJsonTests.cs.meta +11 -0
- package/Tests/Runtime/Serialization/ProtoInterfaceResolutionEdgeTests.cs +76 -0
- package/Tests/Runtime/Serialization/ProtoInterfaceResolutionEdgeTests.cs.meta +11 -0
- package/Tests/Runtime/Serialization/ProtoRootRegistrationTests.cs +80 -0
- package/Tests/Runtime/Serialization/ProtoRootRegistrationTests.cs.meta +11 -0
- package/Tests/Runtime/Serialization/ProtoRoundtripComprehensiveTests.cs +257 -0
- package/Tests/Runtime/Serialization/ProtoRoundtripComprehensiveTests.cs.meta +11 -0
- package/Tests/Runtime/Serialization/ProtoSerializationCorrectnessTests.cs +471 -0
- package/Tests/Runtime/Serialization/ProtoSerializationCorrectnessTests.cs.meta +3 -0
- package/Tests/Runtime/Serialization/ProtoSerializationTests.cs +169 -0
- package/Tests/Runtime/Serialization/ProtoSerializationTests.cs.meta +11 -0
- package/Tests/Runtime/Serialization/ProtoSerializeBehaviorTests.cs +62 -0
- package/Tests/Runtime/Serialization/ProtoSerializeBehaviorTests.cs.meta +11 -0
- package/Tests/Runtime/Serialization/SerializerAdditionalTests.cs +895 -0
- package/Tests/Runtime/Serialization/SerializerAdditionalTests.cs.meta +3 -0
- package/Tests/Runtime/Serialization/TypeConverterTests.cs +34 -0
- package/Tests/Runtime/Serialization/TypeConverterTests.cs.meta +11 -0
- package/Tests/Runtime/Serialization.meta +2 -2
- package/Tests/Runtime/Tags/AttributeComponentTests.cs +174 -0
- package/Tests/Runtime/Tags/AttributeComponentTests.cs.meta +3 -0
- package/Tests/Runtime/Tags/AttributeDataTests.cs +312 -0
- package/Tests/Runtime/Tags/AttributeDataTests.cs.meta +11 -0
- package/Tests/Runtime/Tags/AttributeUtilitiesTests.cs +405 -0
- package/Tests/Runtime/Tags/AttributeUtilitiesTests.cs.meta +3 -0
- package/Tests/Runtime/Tags/CosmeticAndCollisionTests.cs +147 -0
- package/Tests/Runtime/Tags/CosmeticAndCollisionTests.cs.meta +11 -0
- package/Tests/Runtime/Tags/CosmeticEffectDataTests.cs +60 -0
- package/Tests/Runtime/Tags/CosmeticEffectDataTests.cs.meta +3 -0
- package/Tests/Runtime/Tags/EffectHandleTests.cs +61 -0
- package/Tests/Runtime/Tags/EffectHandleTests.cs.meta +3 -0
- package/Tests/Runtime/Tags/EffectHandlerTests.cs +270 -0
- package/Tests/Runtime/Tags/EffectHandlerTests.cs.meta +3 -0
- package/Tests/Runtime/Tags/Helpers/RecordingCosmeticComponent.cs +39 -0
- package/Tests/Runtime/Tags/Helpers/RecordingCosmeticComponent.cs.meta +3 -0
- package/Tests/Runtime/Tags/Helpers/TagTestBase.cs +49 -0
- package/Tests/Runtime/Tags/Helpers/TagTestBase.cs.meta +3 -0
- package/Tests/Runtime/Tags/Helpers/TestAttributesComponent.cs +28 -0
- package/Tests/Runtime/Tags/Helpers/TestAttributesComponent.cs.meta +3 -0
- package/Tests/Runtime/Tags/Helpers.meta +3 -0
- package/Tests/Runtime/Tags/TagHandlerTests.cs +108 -0
- package/Tests/Runtime/Tags/TagHandlerTests.cs.meta +3 -0
- package/Tests/Runtime/Tags.meta +8 -0
- package/Tests/Runtime/TestUtils/CommonTestBase.cs +213 -0
- package/Tests/Runtime/TestUtils/CommonTestBase.cs.meta +11 -0
- package/Tests/Runtime/TestUtils/GCAssert.cs +55 -0
- package/Tests/Runtime/TestUtils/GCAssert.cs.meta +11 -0
- package/Tests/Runtime/TestUtils/SpatialAssert.cs +33 -0
- package/Tests/Runtime/TestUtils/SpatialAssert.cs.meta +11 -0
- package/Tests/Runtime/TestUtils/SpatialDiagnostics.cs +195 -0
- package/Tests/Runtime/TestUtils/SpatialDiagnostics.cs.meta +11 -0
- package/Tests/Runtime/TestUtils.meta +8 -0
- package/Tests/Runtime/Utils/AnimationEventEqualityComparerTests.cs +144 -0
- package/Tests/Runtime/Utils/AnimationEventEqualityComparerTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/Ascii85Tests.cs +56 -0
- package/Tests/Runtime/Utils/Ascii85Tests.cs.meta +11 -0
- package/Tests/Runtime/Utils/BuffersTests.cs +1148 -741
- package/Tests/Runtime/Utils/BuffersTests.cs.meta +2 -2
- package/Tests/Runtime/Utils/BuffersWaitInstructionTests.cs +31 -0
- package/Tests/Runtime/Utils/BuffersWaitInstructionTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/CenterPointOffsetTests.cs +67 -0
- package/Tests/Runtime/Utils/CenterPointOffsetTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/ChildSpawnerTests.cs +490 -0
- package/Tests/Runtime/Utils/ChildSpawnerTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/CircleLineRendererTests.cs +80 -0
- package/Tests/Runtime/Utils/CircleLineRendererTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/CollisionProxyTests.cs +442 -0
- package/Tests/Runtime/Utils/CollisionProxyTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/CoroutineHandlerTests.cs +353 -0
- package/Tests/Runtime/Utils/CoroutineHandlerTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/DeferredDisposalResultTests.cs +44 -0
- package/Tests/Runtime/Utils/DeferredDisposalResultTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/LZMAComprehensiveTests.cs +249 -0
- package/Tests/Runtime/Utils/LZMAComprehensiveTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/LZMATests.cs +31 -0
- package/Tests/Runtime/Utils/LZMATests.cs.meta +11 -0
- package/Tests/Runtime/Utils/MatchColliderToSpriteAdditionalTests.cs +86 -0
- package/Tests/Runtime/Utils/MatchColliderToSpriteAdditionalTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/MatchColliderToSpriteTests.cs +503 -0
- package/Tests/Runtime/Utils/MatchColliderToSpriteTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/MatchTransformEdgeTests.cs +34 -0
- package/Tests/Runtime/Utils/MatchTransformEdgeTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/MatchTransformTests.cs +495 -0
- package/Tests/Runtime/Utils/MatchTransformTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/OscillatorTests.cs +540 -0
- package/Tests/Runtime/Utils/OscillatorTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/PolygonCollider2DOptimizerTests.cs +52 -0
- package/Tests/Runtime/Utils/PolygonCollider2DOptimizerTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/RuntimeSingletonTests.cs +766 -0
- package/Tests/Runtime/Utils/RuntimeSingletonTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/SerializedStringComparerEdgeTests.cs +47 -0
- package/Tests/Runtime/Utils/SerializedStringComparerEdgeTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/SerializedStringComparerTests.cs +361 -0
- package/Tests/Runtime/Utils/SerializedStringComparerTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/SpriteRendererMetadataTests.cs +383 -398
- package/Tests/Runtime/Utils/SpriteRendererMetadataTests.cs.meta +2 -2
- package/Tests/Runtime/Utils/SpriteRendererSyncTests.cs +134 -0
- package/Tests/Runtime/Utils/SpriteRendererSyncTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/StartTrackerTests.cs +24 -0
- package/Tests/Runtime/Utils/StartTrackerTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/TextureScaleEdgeTests.cs +114 -0
- package/Tests/Runtime/Utils/TextureScaleEdgeTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/TextureScaleTests.cs +298 -0
- package/Tests/Runtime/Utils/TextureScaleTests.cs.meta +3 -0
- package/Tests/Runtime/Utils/TypeNameSorterAdditionalTests.cs +36 -0
- package/Tests/Runtime/Utils/TypeNameSorterAdditionalTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/TypeNameSorterTests.cs +34 -0
- package/Tests/Runtime/Utils/TypeNameSorterTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/UnityObjectNameComparerEdgeTests.cs +63 -0
- package/Tests/Runtime/Utils/UnityObjectNameComparerEdgeTests.cs.meta +11 -0
- package/Tests/Runtime/Utils/UnityObjectNameComparerTests.cs +59 -0
- package/Tests/Runtime/Utils/UnityObjectNameComparerTests.cs.meta +11 -0
- package/Tests/Runtime/Utils.meta +2 -2
- package/Tests/Runtime/Visuals/AnimatedSpriteLayerTests.cs +266 -0
- package/Tests/Runtime/Visuals/AnimatedSpriteLayerTests.cs.meta +11 -0
- package/Tests/Runtime/Visuals/EnhancedImageTests.cs +184 -0
- package/Tests/Runtime/Visuals/EnhancedImageTests.cs.meta +11 -0
- package/Tests/Runtime/Visuals/LayeredImageTests.cs +422 -0
- package/Tests/Runtime/Visuals/LayeredImageTests.cs.meta +11 -0
- package/Tests/Runtime/Visuals/VisualsTestHelpers.cs +132 -0
- package/Tests/Runtime/Visuals/VisualsTestHelpers.cs.meta +11 -0
- package/Tests/Runtime/Visuals.meta +3 -0
- package/Tests/Runtime/WallstopStudios.UnityHelpers.Tests.Runtime.asmdef +24 -23
- package/Tests/Runtime/WallstopStudios.UnityHelpers.Tests.Runtime.asmdef.meta +7 -7
- package/Tests/Runtime.meta +8 -8
- package/Tests.meta +8 -8
- package/URP/VolumeProfiles/Post Processing Bloom Profile(URP).asset +63 -63
- package/URP/VolumeProfiles/Post Processing Bloom Profile(URP).asset.meta +8 -8
- package/URP/VolumeProfiles.meta +8 -8
- package/URP.meta +8 -8
- package/node_modules.meta +8 -0
- package/package.json +95 -38
- package/package.json.meta +7 -7
- package/scripts/check-eol.ps1 +52 -0
- package/scripts/check-eol.ps1.meta +7 -0
- package/scripts/clean-nul.ps1 +29 -0
- package/scripts/clean-nul.ps1.meta +7 -0
- package/scripts/lint-doc-links.ps1 +80 -0
- package/scripts/lint-doc-links.ps1.meta +7 -0
- package/scripts/normalize-eol.ps1 +71 -0
- package/scripts/normalize-eol.ps1.meta +7 -0
- package/scripts.meta +8 -0
- package/Editor/Sprites/ProjectAnimationSettings.cs +0 -50
- package/Editor/Sprites/ProjectAnimationSettings.cs.meta +0 -3
- package/Editor/Sprites/TextureSettingsApplier.cs +0 -178
- package/Editor/Sprites/TextureSettingsApplier.cs.meta +0 -3
- package/Runtime/Core/Attributes/ParentComponent.cs +0 -189
- package/Runtime/Core/DataStructure/KDTree.cs +0 -434
- package/Runtime/Core/DataStructure/QuadTree.cs +0 -431
- package/Runtime/Core/DataStructure/RTree.cs +0 -356
- package/Runtime/Core/Extension/HashSetExtensions.cs +0 -12
- package/Runtime/Core/Extension/HashSetExtensions.cs.meta +0 -11
- package/Runtime/Core/Math/Line.cs +0 -55
- package/Runtime/Core/Math/Line.cs.meta +0 -11
- package/Runtime/Core/Math/XXHash.cs +0 -310
- package/Runtime/Core/Math/XXHash.cs.meta +0 -11
- package/Tests/Runtime/Components/RelationalComponentsTesterSimple.cs +0 -40
- package/Tests/Runtime/Components.meta +0 -3
- package/Tests/Runtime/DataStructures/BalancedKDTreeTests.cs +0 -14
- package/Tests/Runtime/DataStructures/QuadTreeTests.cs +0 -14
- package/Tests/Runtime/DataStructures/QuadTreeTests.cs.meta +0 -11
- package/Tests/Runtime/DataStructures/SpatialTreeTests.cs +0 -130
- package/Tests/Runtime/DataStructures/SpatialTreeTests.cs.meta +0 -11
- package/Tests/Runtime/DataStructures/UnbalancedKDTreeTests.cs +0 -14
- package/Tests/Runtime/Helper/FormattingHelperTests.cs +0 -129
- package/Tests/Runtime/Helper/FormattingHelperTests.cs.meta +0 -3
- package/Tests/Runtime/Performance/KDTreePerformanceTests.cs +0 -14
- package/Tests/Runtime/Performance/KDTreePerformanceTests.cs.meta +0 -11
- package/Tests/Runtime/Performance/QuadTreePerformanceTests.cs +0 -14
- package/Tests/Runtime/Performance/QuadTreePerformanceTests.cs.meta +0 -11
- package/Tests/Runtime/Performance/SpatialTreePerformanceTest.cs +0 -158
- package/Tests/Runtime/Performance/SpatialTreePerformanceTest.cs.meta +0 -11
- package/Tests/Runtime/Performance/UnbalancedKDTreeTests.cs +0 -14
- package/Tests/Runtime/Performance/UnbalancedKDTreeTests.cs.meta +0 -11
- package/Third Party Notices.md +0 -1
|
@@ -0,0 +1,3385 @@
|
|
|
1
|
+
namespace WallstopStudios.UnityHelpers.Tests.DataStructures
|
|
2
|
+
{
|
|
3
|
+
using System;
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
using System.Linq;
|
|
6
|
+
using NUnit.Framework;
|
|
7
|
+
using WallstopStudios.UnityHelpers.Core.DataStructure;
|
|
8
|
+
|
|
9
|
+
public sealed class TrieTests
|
|
10
|
+
{
|
|
11
|
+
[Test]
|
|
12
|
+
public void ConstructorWithEmptyListCreatesValidTrie()
|
|
13
|
+
{
|
|
14
|
+
Trie trie = new(Array.Empty<string>());
|
|
15
|
+
Assert.IsFalse(trie.Contains("test"));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
[Test]
|
|
19
|
+
public void ConstructorWithSingleWordCreatesValidTrie()
|
|
20
|
+
{
|
|
21
|
+
Trie trie = new(new[] { "test" });
|
|
22
|
+
Assert.IsTrue(trie.Contains("test"));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[Test]
|
|
26
|
+
public void ConstructorWithMultipleWordsCreatesValidTrie()
|
|
27
|
+
{
|
|
28
|
+
string[] words = { "apple", "banana", "cherry" };
|
|
29
|
+
Trie trie = new(words);
|
|
30
|
+
|
|
31
|
+
foreach (string word in words)
|
|
32
|
+
{
|
|
33
|
+
Assert.IsTrue(trie.Contains(word));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
[Test]
|
|
38
|
+
public void ContainsReturnsFalseForNonExistentWord()
|
|
39
|
+
{
|
|
40
|
+
Trie trie = new(new[] { "test", "testing" });
|
|
41
|
+
Assert.IsFalse(trie.Contains("nonexistent"));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
[Test]
|
|
45
|
+
public void ContainsReturnsFalseForPrefix()
|
|
46
|
+
{
|
|
47
|
+
Trie trie = new(new[] { "testing" });
|
|
48
|
+
Assert.IsFalse(trie.Contains("test"));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
[Test]
|
|
52
|
+
public void ContainsReturnsTrueForExactWord()
|
|
53
|
+
{
|
|
54
|
+
Trie trie = new(new[] { "test", "testing" });
|
|
55
|
+
Assert.IsTrue(trie.Contains("test"));
|
|
56
|
+
Assert.IsTrue(trie.Contains("testing"));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
[Test]
|
|
60
|
+
public void ContainsReturnsFalseForEmptyString()
|
|
61
|
+
{
|
|
62
|
+
Trie trie = new(new[] { "test" });
|
|
63
|
+
Assert.IsFalse(trie.Contains(""));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
[Test]
|
|
67
|
+
public void ContainsHandlesEmptyStringInWordList()
|
|
68
|
+
{
|
|
69
|
+
Trie trie = new(new[] { "", "test" });
|
|
70
|
+
Assert.IsTrue(trie.Contains(""));
|
|
71
|
+
Assert.IsTrue(trie.Contains("test"));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
[Test]
|
|
75
|
+
public void ContainsCaseSensitive()
|
|
76
|
+
{
|
|
77
|
+
Trie trie = new(new[] { "test" });
|
|
78
|
+
Assert.IsTrue(trie.Contains("test"));
|
|
79
|
+
Assert.IsFalse(trie.Contains("TEST"));
|
|
80
|
+
Assert.IsFalse(trie.Contains("Test"));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
[Test]
|
|
84
|
+
public void GetWordsWithPrefixReturnsEmptyForNonMatchingPrefix()
|
|
85
|
+
{
|
|
86
|
+
Trie trie = new(new[] { "apple", "banana", "cherry" });
|
|
87
|
+
List<string> results = new();
|
|
88
|
+
int count = trie.GetWordsWithPrefix("xyz", results).Count;
|
|
89
|
+
|
|
90
|
+
Assert.AreEqual(0, count);
|
|
91
|
+
Assert.AreEqual(0, results.Count);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
[Test]
|
|
95
|
+
public void GetWordsWithPrefixReturnsMatchingWords()
|
|
96
|
+
{
|
|
97
|
+
Trie trie = new(new[] { "apple", "application", "apply", "banana" });
|
|
98
|
+
List<string> results = new();
|
|
99
|
+
int count = trie.GetWordsWithPrefix("app", results).Count;
|
|
100
|
+
|
|
101
|
+
Assert.AreEqual(3, count);
|
|
102
|
+
Assert.AreEqual(3, results.Count);
|
|
103
|
+
CollectionAssert.AreEquivalent(new[] { "apple", "application", "apply" }, results);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
[Test]
|
|
107
|
+
public void GetWordsWithPrefixReturnsAllWordsForEmptyPrefix()
|
|
108
|
+
{
|
|
109
|
+
string[] words = { "apple", "banana", "cherry" };
|
|
110
|
+
Trie trie = new(words);
|
|
111
|
+
List<string> results = new();
|
|
112
|
+
int count = trie.GetWordsWithPrefix("", results).Count;
|
|
113
|
+
|
|
114
|
+
Assert.AreEqual(3, count);
|
|
115
|
+
CollectionAssert.AreEquivalent(words, results);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
[Test]
|
|
119
|
+
public void GetWordsWithPrefixRespectsMaxResults()
|
|
120
|
+
{
|
|
121
|
+
Trie trie = new(new[] { "apple", "application", "apply", "approach" });
|
|
122
|
+
List<string> results = new();
|
|
123
|
+
int count = trie.GetWordsWithPrefix("app", results, maxResults: 2).Count;
|
|
124
|
+
|
|
125
|
+
Assert.AreEqual(2, count);
|
|
126
|
+
Assert.AreEqual(2, results.Count);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
[Test]
|
|
130
|
+
public void GetWordsWithPrefixClearsResultsList()
|
|
131
|
+
{
|
|
132
|
+
Trie trie = new(new[] { "apple", "banana" });
|
|
133
|
+
List<string> results = new() { "old1", "old2" };
|
|
134
|
+
trie.GetWordsWithPrefix("app", results);
|
|
135
|
+
|
|
136
|
+
Assert.AreEqual(1, results.Count);
|
|
137
|
+
Assert.AreEqual("apple", results[0]);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
[Test]
|
|
141
|
+
public void GetWordsWithPrefixHandlesExactMatch()
|
|
142
|
+
{
|
|
143
|
+
Trie trie = new(new[] { "test", "testing", "tester" });
|
|
144
|
+
List<string> results = new();
|
|
145
|
+
trie.GetWordsWithPrefix("test", results);
|
|
146
|
+
|
|
147
|
+
Assert.AreEqual(3, results.Count);
|
|
148
|
+
CollectionAssert.Contains(results, "test");
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
[Test]
|
|
152
|
+
public void GetWordsWithPrefixHandlesLongPrefix()
|
|
153
|
+
{
|
|
154
|
+
Trie trie = new(new[] { "testing" });
|
|
155
|
+
List<string> results = new();
|
|
156
|
+
int count = trie.GetWordsWithPrefix("testing", results).Count;
|
|
157
|
+
|
|
158
|
+
Assert.AreEqual(1, count);
|
|
159
|
+
Assert.AreEqual("testing", results[0]);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
[Test]
|
|
163
|
+
public void GetWordsWithPrefixHandlesPrefixLongerThanAnyWord()
|
|
164
|
+
{
|
|
165
|
+
Trie trie = new(new[] { "test" });
|
|
166
|
+
List<string> results = new();
|
|
167
|
+
int count = trie.GetWordsWithPrefix("testingextra", results).Count;
|
|
168
|
+
|
|
169
|
+
Assert.AreEqual(0, count);
|
|
170
|
+
Assert.AreEqual(0, results.Count);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
[Test]
|
|
174
|
+
public void TrieHandlesWordsWithCommonPrefixes()
|
|
175
|
+
{
|
|
176
|
+
string[] words = { "car", "card", "care", "careful", "carefully" };
|
|
177
|
+
Trie trie = new(words);
|
|
178
|
+
|
|
179
|
+
foreach (string word in words)
|
|
180
|
+
{
|
|
181
|
+
Assert.IsTrue(trie.Contains(word), $"Word '{word}' should be in trie");
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
List<string> results = new();
|
|
185
|
+
trie.GetWordsWithPrefix("car", results);
|
|
186
|
+
Assert.AreEqual(5, results.Count);
|
|
187
|
+
CollectionAssert.AreEquivalent(words, results);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
[Test]
|
|
191
|
+
public void TrieHandlesSingleCharacterWords()
|
|
192
|
+
{
|
|
193
|
+
Trie trie = new(new[] { "a", "b", "c" });
|
|
194
|
+
Assert.IsTrue(trie.Contains("a"));
|
|
195
|
+
Assert.IsTrue(trie.Contains("b"));
|
|
196
|
+
Assert.IsTrue(trie.Contains("c"));
|
|
197
|
+
Assert.IsFalse(trie.Contains("d"));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
[Test]
|
|
201
|
+
public void TrieHandlesUnicodeCharacters()
|
|
202
|
+
{
|
|
203
|
+
string[] words = { "世界", "世", "世界和平" };
|
|
204
|
+
Trie trie = new(words);
|
|
205
|
+
|
|
206
|
+
Assert.IsTrue(trie.Contains("世界"));
|
|
207
|
+
Assert.IsTrue(trie.Contains("世"));
|
|
208
|
+
Assert.IsTrue(trie.Contains("世界和平"));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
[Test]
|
|
212
|
+
public void TrieHandlesSpecialCharacters()
|
|
213
|
+
{
|
|
214
|
+
string[] words = { "hello-world", "hello_world", "hello.world" };
|
|
215
|
+
Trie trie = new(words);
|
|
216
|
+
|
|
217
|
+
foreach (string word in words)
|
|
218
|
+
{
|
|
219
|
+
Assert.IsTrue(trie.Contains(word));
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
[Test]
|
|
224
|
+
public void TrieHandlesDuplicateWords()
|
|
225
|
+
{
|
|
226
|
+
Trie trie = new(new[] { "test", "test", "test" });
|
|
227
|
+
Assert.IsTrue(trie.Contains("test"));
|
|
228
|
+
|
|
229
|
+
List<string> results = new();
|
|
230
|
+
trie.GetWordsWithPrefix("test", results);
|
|
231
|
+
Assert.AreEqual(1, results.Count);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
[Test]
|
|
235
|
+
public void TrieHandlesVeryLongWords()
|
|
236
|
+
{
|
|
237
|
+
string longWord = new('a', 1000);
|
|
238
|
+
Trie trie = new(new[] { longWord });
|
|
239
|
+
Assert.IsTrue(trie.Contains(longWord));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
[Test]
|
|
243
|
+
public void TrieHandlesManyWords()
|
|
244
|
+
{
|
|
245
|
+
string[] words = Enumerable.Range(0, 1000).Select(i => $"word{i}").ToArray();
|
|
246
|
+
Trie trie = new(words);
|
|
247
|
+
|
|
248
|
+
foreach (string word in words)
|
|
249
|
+
{
|
|
250
|
+
Assert.IsTrue(trie.Contains(word));
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
[Test]
|
|
255
|
+
public void ContainsReturnsFalseForSuperstring()
|
|
256
|
+
{
|
|
257
|
+
Trie trie = new(new[] { "test" });
|
|
258
|
+
Assert.IsFalse(trie.Contains("testing"));
|
|
259
|
+
Assert.IsFalse(trie.Contains("test1"));
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
[Test]
|
|
263
|
+
public void ContainsWithNullStringThrows()
|
|
264
|
+
{
|
|
265
|
+
Trie trie = new(new[] { "test" });
|
|
266
|
+
Assert.Throws<NullReferenceException>(() => trie.Contains(null));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
[Test]
|
|
270
|
+
public void GetWordsWithPrefixWithNullPrefixThrows()
|
|
271
|
+
{
|
|
272
|
+
Trie trie = new(new[] { "test" });
|
|
273
|
+
List<string> results = new();
|
|
274
|
+
Assert.Throws<NullReferenceException>(() => trie.GetWordsWithPrefix(null, results));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
[Test]
|
|
278
|
+
public void GetWordsWithPrefixWithNullListThrows()
|
|
279
|
+
{
|
|
280
|
+
Trie trie = new(new[] { "test" });
|
|
281
|
+
Assert.Throws<NullReferenceException>(() => trie.GetWordsWithPrefix("test", null));
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
[Test]
|
|
285
|
+
public void GetWordsWithPrefixWithZeroMaxResults()
|
|
286
|
+
{
|
|
287
|
+
Trie trie = new(new[] { "apple", "application", "apply" });
|
|
288
|
+
List<string> results = new();
|
|
289
|
+
int count = trie.GetWordsWithPrefix("app", results, maxResults: 0).Count;
|
|
290
|
+
|
|
291
|
+
Assert.AreEqual(0, count);
|
|
292
|
+
Assert.AreEqual(0, results.Count);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
[Test]
|
|
296
|
+
public void GetWordsWithPrefixWithNegativeMaxResults()
|
|
297
|
+
{
|
|
298
|
+
Trie trie = new(new[] { "apple", "application", "apply" });
|
|
299
|
+
List<string> results = new();
|
|
300
|
+
int count = trie.GetWordsWithPrefix("app", results, maxResults: -1).Count;
|
|
301
|
+
|
|
302
|
+
Assert.AreEqual(0, count);
|
|
303
|
+
Assert.AreEqual(0, results.Count);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
[Test]
|
|
307
|
+
public void GetWordsWithPrefixWithOneMaxResult()
|
|
308
|
+
{
|
|
309
|
+
Trie trie = new(new[] { "apple", "application", "apply" });
|
|
310
|
+
List<string> results = new();
|
|
311
|
+
int count = trie.GetWordsWithPrefix("app", results, maxResults: 1).Count;
|
|
312
|
+
|
|
313
|
+
Assert.AreEqual(1, count);
|
|
314
|
+
Assert.AreEqual(1, results.Count);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
[Test]
|
|
318
|
+
public void TrieHandlesWordsWhereOneIsCompleteSubstringOfAnother()
|
|
319
|
+
{
|
|
320
|
+
string[] words = { "a", "ab", "abc", "abcd", "abcde" };
|
|
321
|
+
Trie trie = new(words);
|
|
322
|
+
|
|
323
|
+
foreach (string word in words)
|
|
324
|
+
{
|
|
325
|
+
Assert.IsTrue(trie.Contains(word), $"Word '{word}' should be in trie");
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
Assert.IsFalse(trie.Contains("abcdef"));
|
|
329
|
+
Assert.IsFalse(trie.Contains(""));
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
[Test]
|
|
333
|
+
public void TrieHandlesWordsThatShareNoCommonPrefix()
|
|
334
|
+
{
|
|
335
|
+
string[] words = { "apple", "banana", "cherry", "date", "elderberry" };
|
|
336
|
+
Trie trie = new(words);
|
|
337
|
+
|
|
338
|
+
foreach (string word in words)
|
|
339
|
+
{
|
|
340
|
+
Assert.IsTrue(trie.Contains(word));
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
[Test]
|
|
345
|
+
public void TrieHandlesBranchingAtEachLevel()
|
|
346
|
+
{
|
|
347
|
+
string[] words = { "a", "b", "aa", "ab", "ba", "bb", "aaa", "aab", "aba", "abb" };
|
|
348
|
+
Trie trie = new(words);
|
|
349
|
+
|
|
350
|
+
foreach (string word in words)
|
|
351
|
+
{
|
|
352
|
+
Assert.IsTrue(trie.Contains(word), $"Word '{word}' should be in trie");
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
Assert.IsFalse(trie.Contains("baa"));
|
|
356
|
+
Assert.IsFalse(trie.Contains("c"));
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
[Test]
|
|
360
|
+
public void GetWordsWithPrefixReturnsWordInCorrectOrderForNestedWords()
|
|
361
|
+
{
|
|
362
|
+
Trie trie = new(new[] { "test", "tester", "testing" });
|
|
363
|
+
List<string> results = new();
|
|
364
|
+
trie.GetWordsWithPrefix("test", results);
|
|
365
|
+
|
|
366
|
+
Assert.AreEqual(3, results.Count);
|
|
367
|
+
CollectionAssert.Contains(results, "test");
|
|
368
|
+
CollectionAssert.Contains(results, "tester");
|
|
369
|
+
CollectionAssert.Contains(results, "testing");
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
[Test]
|
|
373
|
+
public void GetWordsWithPrefixWithSingleCharacterPrefix()
|
|
374
|
+
{
|
|
375
|
+
Trie trie = new(new[] { "apple", "application", "banana", "apply" });
|
|
376
|
+
List<string> results = new();
|
|
377
|
+
int count = trie.GetWordsWithPrefix("a", results).Count;
|
|
378
|
+
|
|
379
|
+
Assert.AreEqual(3, count);
|
|
380
|
+
CollectionAssert.AreEquivalent(new[] { "apple", "application", "apply" }, results);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
[Test]
|
|
384
|
+
public void GetWordsWithPrefixHandlesDeepNesting()
|
|
385
|
+
{
|
|
386
|
+
string[] words = { "a", "ab", "abc", "abcd", "abcde", "abcdef" };
|
|
387
|
+
Trie trie = new(words);
|
|
388
|
+
List<string> results = new();
|
|
389
|
+
|
|
390
|
+
trie.GetWordsWithPrefix("abc", results);
|
|
391
|
+
Assert.AreEqual(4, results.Count);
|
|
392
|
+
CollectionAssert.AreEquivalent(new[] { "abc", "abcd", "abcde", "abcdef" }, results);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
[Test]
|
|
396
|
+
public void ContainsHandlesRepeatingCharacters()
|
|
397
|
+
{
|
|
398
|
+
Trie trie = new(new[] { "aaa", "aaaa", "aaaaa" });
|
|
399
|
+
Assert.IsTrue(trie.Contains("aaa"));
|
|
400
|
+
Assert.IsTrue(trie.Contains("aaaa"));
|
|
401
|
+
Assert.IsTrue(trie.Contains("aaaaa"));
|
|
402
|
+
Assert.IsFalse(trie.Contains("aa"));
|
|
403
|
+
Assert.IsFalse(trie.Contains("aaaaaa"));
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
[Test]
|
|
407
|
+
public void TrieHandlesAllSameCharacterWords()
|
|
408
|
+
{
|
|
409
|
+
string[] words = { "a", "aa", "aaa", "aaaa" };
|
|
410
|
+
Trie trie = new(words);
|
|
411
|
+
|
|
412
|
+
foreach (string word in words)
|
|
413
|
+
{
|
|
414
|
+
Assert.IsTrue(trie.Contains(word));
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
List<string> results = new();
|
|
418
|
+
trie.GetWordsWithPrefix("aa", results);
|
|
419
|
+
Assert.AreEqual(3, results.Count);
|
|
420
|
+
CollectionAssert.AreEquivalent(new[] { "aa", "aaa", "aaaa" }, results);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
[Test]
|
|
424
|
+
public void GetWordsWithPrefixWhenPrefixIsNotAWord()
|
|
425
|
+
{
|
|
426
|
+
Trie trie = new(new[] { "testing", "tester" });
|
|
427
|
+
List<string> results = new();
|
|
428
|
+
int count = trie.GetWordsWithPrefix("test", results).Count;
|
|
429
|
+
|
|
430
|
+
Assert.AreEqual(2, count);
|
|
431
|
+
Assert.IsFalse(trie.Contains("test"));
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
[Test]
|
|
435
|
+
public void TrieHandlesWhitespaceInWords()
|
|
436
|
+
{
|
|
437
|
+
string[] words = { "hello world", "hello world", "hello\tworld", "hello\nworld" };
|
|
438
|
+
Trie trie = new(words);
|
|
439
|
+
|
|
440
|
+
foreach (string word in words)
|
|
441
|
+
{
|
|
442
|
+
Assert.IsTrue(trie.Contains(word), $"Word should be in trie: '{word}'");
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
Assert.IsFalse(trie.Contains("hello"));
|
|
446
|
+
Assert.IsFalse(trie.Contains("world"));
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
[Test]
|
|
450
|
+
public void TrieHandlesNumericStrings()
|
|
451
|
+
{
|
|
452
|
+
string[] words = { "123", "1234", "12345", "234", "345" };
|
|
453
|
+
Trie trie = new(words);
|
|
454
|
+
|
|
455
|
+
foreach (string word in words)
|
|
456
|
+
{
|
|
457
|
+
Assert.IsTrue(trie.Contains(word));
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
List<string> results = new();
|
|
461
|
+
trie.GetWordsWithPrefix("123", results);
|
|
462
|
+
Assert.AreEqual(3, results.Count);
|
|
463
|
+
CollectionAssert.AreEquivalent(new[] { "123", "1234", "12345" }, results);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
[Test]
|
|
467
|
+
public void TrieHandlesMixedAlphanumeric()
|
|
468
|
+
{
|
|
469
|
+
string[] words = { "a1b2c3", "a1b2", "a1", "1a2b3c" };
|
|
470
|
+
Trie trie = new(words);
|
|
471
|
+
|
|
472
|
+
foreach (string word in words)
|
|
473
|
+
{
|
|
474
|
+
Assert.IsTrue(trie.Contains(word));
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
[Test]
|
|
479
|
+
public void GetWordsWithPrefixReturnsCorrectCountWhenMaxResultsExceedsAvailable()
|
|
480
|
+
{
|
|
481
|
+
Trie trie = new(new[] { "apple", "application" });
|
|
482
|
+
List<string> results = new();
|
|
483
|
+
int count = trie.GetWordsWithPrefix("app", results, maxResults: 100).Count;
|
|
484
|
+
|
|
485
|
+
Assert.AreEqual(2, count);
|
|
486
|
+
Assert.AreEqual(2, results.Count);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
[Test]
|
|
490
|
+
public void ContainsMultipleCallsAreIndependent()
|
|
491
|
+
{
|
|
492
|
+
Trie trie = new(new[] { "test", "testing" });
|
|
493
|
+
Assert.IsTrue(trie.Contains("test"));
|
|
494
|
+
Assert.IsTrue(trie.Contains("testing"));
|
|
495
|
+
Assert.IsFalse(trie.Contains("tested"));
|
|
496
|
+
Assert.IsTrue(trie.Contains("test"));
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
[Test]
|
|
500
|
+
public void GetWordsWithPrefixMultipleCallsAreIndependent()
|
|
501
|
+
{
|
|
502
|
+
Trie trie = new(new[] { "apple", "application", "apply", "banana" });
|
|
503
|
+
List<string> results = new();
|
|
504
|
+
|
|
505
|
+
trie.GetWordsWithPrefix("app", results);
|
|
506
|
+
Assert.AreEqual(3, results.Count);
|
|
507
|
+
|
|
508
|
+
trie.GetWordsWithPrefix("ban", results);
|
|
509
|
+
Assert.AreEqual(1, results.Count);
|
|
510
|
+
Assert.AreEqual("banana", results[0]);
|
|
511
|
+
|
|
512
|
+
trie.GetWordsWithPrefix("app", results);
|
|
513
|
+
Assert.AreEqual(3, results.Count);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
[Test]
|
|
517
|
+
public void TrieHandlesWordsWithOnlySpecialCharacters()
|
|
518
|
+
{
|
|
519
|
+
string[] words = { "!!!", "@@@", "###", "$$$" };
|
|
520
|
+
Trie trie = new(words);
|
|
521
|
+
|
|
522
|
+
foreach (string word in words)
|
|
523
|
+
{
|
|
524
|
+
Assert.IsTrue(trie.Contains(word));
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
[Test]
|
|
529
|
+
public void GetWordsWithPrefixWithSpecialCharacterPrefix()
|
|
530
|
+
{
|
|
531
|
+
Trie trie = new(new[] { "!test", "!testing", "!tester", "#test" });
|
|
532
|
+
List<string> results = new();
|
|
533
|
+
int count = trie.GetWordsWithPrefix("!", results).Count;
|
|
534
|
+
|
|
535
|
+
Assert.AreEqual(3, count);
|
|
536
|
+
CollectionAssert.AreEquivalent(new[] { "!test", "!testing", "!tester" }, results);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
[Test]
|
|
540
|
+
public void TrieHandlesEmojiCharacters()
|
|
541
|
+
{
|
|
542
|
+
string[] words = { "😀", "😀😀", "😁", "test😀" };
|
|
543
|
+
Trie trie = new(words);
|
|
544
|
+
|
|
545
|
+
foreach (string word in words)
|
|
546
|
+
{
|
|
547
|
+
Assert.IsTrue(trie.Contains(word), $"Word should be in trie: '{word}'");
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
[Test]
|
|
552
|
+
public void TrieHandlesSurrogatePairs()
|
|
553
|
+
{
|
|
554
|
+
string[] words = { "𝕳𝖊𝖑𝖑𝖔", "𝕳𝖊𝖑", "test" };
|
|
555
|
+
Trie trie = new(words);
|
|
556
|
+
|
|
557
|
+
foreach (string word in words)
|
|
558
|
+
{
|
|
559
|
+
Assert.IsTrue(trie.Contains(word));
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
[Test]
|
|
564
|
+
public void GetWordsWithPrefixHandlesLargeMaxResults()
|
|
565
|
+
{
|
|
566
|
+
Trie trie = new(new[] { "apple", "application" });
|
|
567
|
+
List<string> results = new();
|
|
568
|
+
int count = trie.GetWordsWithPrefix("app", results, maxResults: int.MaxValue).Count;
|
|
569
|
+
|
|
570
|
+
Assert.AreEqual(2, count);
|
|
571
|
+
Assert.AreEqual(2, results.Count);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
[Test]
|
|
575
|
+
public void TrieHandlesWordsStartingWithSameCharacterButDifferentSecondChar()
|
|
576
|
+
{
|
|
577
|
+
string[] words = { "aa", "ab", "ac", "ad", "ae" };
|
|
578
|
+
Trie trie = new(words);
|
|
579
|
+
|
|
580
|
+
foreach (string word in words)
|
|
581
|
+
{
|
|
582
|
+
Assert.IsTrue(trie.Contains(word));
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
List<string> results = new();
|
|
586
|
+
trie.GetWordsWithPrefix("a", results);
|
|
587
|
+
Assert.AreEqual(5, results.Count);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
[Test]
|
|
591
|
+
public void ContainsAfterConstructingWithEmptyTrie()
|
|
592
|
+
{
|
|
593
|
+
Trie trie = new(Array.Empty<string>());
|
|
594
|
+
Assert.IsFalse(trie.Contains("anything"));
|
|
595
|
+
Assert.IsFalse(trie.Contains(""));
|
|
596
|
+
Assert.IsFalse(trie.Contains("a"));
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
[Test]
|
|
600
|
+
public void GetWordsWithPrefixOnEmptyTrie()
|
|
601
|
+
{
|
|
602
|
+
Trie trie = new(Array.Empty<string>());
|
|
603
|
+
List<string> results = new();
|
|
604
|
+
int count = trie.GetWordsWithPrefix("test", results).Count;
|
|
605
|
+
|
|
606
|
+
Assert.AreEqual(0, count);
|
|
607
|
+
Assert.AreEqual(0, results.Count);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
[Test]
|
|
611
|
+
public void GetWordsWithPrefixEmptyPrefixOnEmptyTrie()
|
|
612
|
+
{
|
|
613
|
+
Trie trie = new(Array.Empty<string>());
|
|
614
|
+
List<string> results = new();
|
|
615
|
+
int count = trie.GetWordsWithPrefix("", results).Count;
|
|
616
|
+
|
|
617
|
+
Assert.AreEqual(0, count);
|
|
618
|
+
Assert.AreEqual(0, results.Count);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
[Test]
|
|
622
|
+
public void TrieHandlesOnlyEmptyString()
|
|
623
|
+
{
|
|
624
|
+
Trie trie = new(new[] { "" });
|
|
625
|
+
Assert.IsTrue(trie.Contains(""));
|
|
626
|
+
Assert.IsFalse(trie.Contains("a"));
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
[Test]
|
|
630
|
+
public void GetWordsWithPrefixReturnsEmptyStringWhenPresent()
|
|
631
|
+
{
|
|
632
|
+
Trie trie = new(new[] { "", "test" });
|
|
633
|
+
List<string> results = new();
|
|
634
|
+
trie.GetWordsWithPrefix("", results);
|
|
635
|
+
|
|
636
|
+
Assert.AreEqual(2, results.Count);
|
|
637
|
+
CollectionAssert.Contains(results, "");
|
|
638
|
+
CollectionAssert.Contains(results, "test");
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
[Test]
|
|
642
|
+
public void TrieHandlesMultipleEmptyStrings()
|
|
643
|
+
{
|
|
644
|
+
Trie trie = new(new[] { "", "", "" });
|
|
645
|
+
Assert.IsTrue(trie.Contains(""));
|
|
646
|
+
|
|
647
|
+
List<string> results = new();
|
|
648
|
+
trie.GetWordsWithPrefix("", results);
|
|
649
|
+
Assert.AreEqual(1, results.Count);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
[Test]
|
|
653
|
+
public void ContainsDistinguishesBetweenSimilarWords()
|
|
654
|
+
{
|
|
655
|
+
Trie trie = new(new[] { "car", "cart", "card", "care" });
|
|
656
|
+
Assert.IsTrue(trie.Contains("car"));
|
|
657
|
+
Assert.IsTrue(trie.Contains("cart"));
|
|
658
|
+
Assert.IsTrue(trie.Contains("card"));
|
|
659
|
+
Assert.IsTrue(trie.Contains("care"));
|
|
660
|
+
Assert.IsFalse(trie.Contains("ca"));
|
|
661
|
+
Assert.IsFalse(trie.Contains("cars"));
|
|
662
|
+
Assert.IsFalse(trie.Contains("carts"));
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
[Test]
|
|
666
|
+
public void TrieConstructorWithNullEnumerableThrows()
|
|
667
|
+
{
|
|
668
|
+
Assert.Throws<ArgumentNullException>(() => new Trie(null));
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
[Test]
|
|
672
|
+
public void TrieHandlesWordsWithControlCharacters()
|
|
673
|
+
{
|
|
674
|
+
string[] words = { "test\r\nline", "test\r", "test\n", "test\t" };
|
|
675
|
+
Trie trie = new(words);
|
|
676
|
+
|
|
677
|
+
foreach (string word in words)
|
|
678
|
+
{
|
|
679
|
+
Assert.IsTrue(trie.Contains(word), $"Word should be in trie: '{word}'");
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
[Test]
|
|
684
|
+
public void GetWordsWithPrefixStopsAtMaxResultsInMiddleOfTraversal()
|
|
685
|
+
{
|
|
686
|
+
string[] words = { "a", "aa", "aaa", "aaaa", "aaaaa", "aaaaaa" };
|
|
687
|
+
Trie trie = new(words);
|
|
688
|
+
List<string> results = new();
|
|
689
|
+
int count = trie.GetWordsWithPrefix("a", results, maxResults: 3).Count;
|
|
690
|
+
|
|
691
|
+
Assert.AreEqual(3, count);
|
|
692
|
+
Assert.AreEqual(3, results.Count);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
[Test]
|
|
696
|
+
public void TrieHandlesWordsWithLeadingAndTrailingSpaces()
|
|
697
|
+
{
|
|
698
|
+
string[] words = { " test", "test ", " test " };
|
|
699
|
+
Trie trie = new(words);
|
|
700
|
+
|
|
701
|
+
Assert.IsTrue(trie.Contains(" test"));
|
|
702
|
+
Assert.IsTrue(trie.Contains("test "));
|
|
703
|
+
Assert.IsTrue(trie.Contains(" test "));
|
|
704
|
+
Assert.IsFalse(trie.Contains("test"));
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
[Test]
|
|
708
|
+
public void GetWordsWithPrefixWithPrefixMatchingCompleteWord()
|
|
709
|
+
{
|
|
710
|
+
Trie trie = new(new[] { "test" });
|
|
711
|
+
List<string> results = new();
|
|
712
|
+
int count = trie.GetWordsWithPrefix("test", results).Count;
|
|
713
|
+
|
|
714
|
+
Assert.AreEqual(1, count);
|
|
715
|
+
Assert.AreEqual("test", results[0]);
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
[Test]
|
|
719
|
+
public void TrieHandlesIdenticalWordsInDifferentCase()
|
|
720
|
+
{
|
|
721
|
+
string[] words = { "test", "Test", "TEST", "TeSt" };
|
|
722
|
+
Trie trie = new(words);
|
|
723
|
+
|
|
724
|
+
foreach (string word in words)
|
|
725
|
+
{
|
|
726
|
+
Assert.IsTrue(trie.Contains(word));
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
List<string> results = new();
|
|
730
|
+
trie.GetWordsWithPrefix("T", results);
|
|
731
|
+
Assert.AreEqual(3, results.Count);
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
[Test]
|
|
735
|
+
public void EnumeratorIteratesAllWords()
|
|
736
|
+
{
|
|
737
|
+
string[] words = { "apple", "banana", "cherry" };
|
|
738
|
+
Trie trie = new(words);
|
|
739
|
+
|
|
740
|
+
List<string> enumerated = new();
|
|
741
|
+
foreach (string word in trie)
|
|
742
|
+
{
|
|
743
|
+
enumerated.Add(word);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
Assert.AreEqual(3, enumerated.Count);
|
|
747
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
[Test]
|
|
751
|
+
public void EnumeratorWorksWithEmptyTrie()
|
|
752
|
+
{
|
|
753
|
+
Trie trie = new(Array.Empty<string>());
|
|
754
|
+
|
|
755
|
+
int count = 0;
|
|
756
|
+
foreach (string word in trie)
|
|
757
|
+
{
|
|
758
|
+
count++;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
Assert.AreEqual(0, count);
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
[Test]
|
|
765
|
+
public void EnumeratorHandlesSingleWord()
|
|
766
|
+
{
|
|
767
|
+
Trie trie = new(new[] { "test" });
|
|
768
|
+
|
|
769
|
+
List<string> enumerated = new();
|
|
770
|
+
foreach (string word in trie)
|
|
771
|
+
{
|
|
772
|
+
enumerated.Add(word);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
Assert.AreEqual(1, enumerated.Count);
|
|
776
|
+
Assert.AreEqual("test", enumerated[0]);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
[Test]
|
|
780
|
+
public void EnumeratorHandlesWordsWithCommonPrefixes()
|
|
781
|
+
{
|
|
782
|
+
string[] words = { "test", "testing", "tester", "tea" };
|
|
783
|
+
Trie trie = new(words);
|
|
784
|
+
|
|
785
|
+
List<string> enumerated = new();
|
|
786
|
+
foreach (string word in trie)
|
|
787
|
+
{
|
|
788
|
+
enumerated.Add(word);
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
Assert.AreEqual(4, enumerated.Count);
|
|
792
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
[Test]
|
|
796
|
+
public void EnumeratorCanBeUsedMultipleTimes()
|
|
797
|
+
{
|
|
798
|
+
string[] words = { "apple", "banana", "cherry" };
|
|
799
|
+
Trie trie = new(words);
|
|
800
|
+
|
|
801
|
+
List<string> firstEnumeration = new();
|
|
802
|
+
foreach (string word in trie)
|
|
803
|
+
{
|
|
804
|
+
firstEnumeration.Add(word);
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
List<string> secondEnumeration = new();
|
|
808
|
+
foreach (string word in trie)
|
|
809
|
+
{
|
|
810
|
+
secondEnumeration.Add(word);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
Assert.AreEqual(3, firstEnumeration.Count);
|
|
814
|
+
Assert.AreEqual(3, secondEnumeration.Count);
|
|
815
|
+
CollectionAssert.AreEquivalent(firstEnumeration, secondEnumeration);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
[Test]
|
|
819
|
+
public void EnumeratorHandlesComplexTrieStructure()
|
|
820
|
+
{
|
|
821
|
+
string[] words = { "a", "ab", "abc", "b", "bc", "c" };
|
|
822
|
+
Trie trie = new(words);
|
|
823
|
+
|
|
824
|
+
List<string> enumerated = new();
|
|
825
|
+
foreach (string word in trie)
|
|
826
|
+
{
|
|
827
|
+
enumerated.Add(word);
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
Assert.AreEqual(6, enumerated.Count);
|
|
831
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
[Test]
|
|
835
|
+
public void EnumeratorHandlesUnicodeWords()
|
|
836
|
+
{
|
|
837
|
+
string[] words = { "café", "naïve", "résumé" };
|
|
838
|
+
Trie trie = new(words);
|
|
839
|
+
|
|
840
|
+
List<string> enumerated = new();
|
|
841
|
+
foreach (string word in trie)
|
|
842
|
+
{
|
|
843
|
+
enumerated.Add(word);
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
Assert.AreEqual(3, enumerated.Count);
|
|
847
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
[Test]
|
|
851
|
+
public void EnumeratorHandlesEmptyString()
|
|
852
|
+
{
|
|
853
|
+
string[] words = { "", "a", "ab" };
|
|
854
|
+
Trie trie = new(words);
|
|
855
|
+
|
|
856
|
+
List<string> enumerated = new();
|
|
857
|
+
foreach (string word in trie)
|
|
858
|
+
{
|
|
859
|
+
enumerated.Add(word);
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
Assert.AreEqual(3, enumerated.Count);
|
|
863
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
[Test]
|
|
867
|
+
public void EnumeratorHandlesLongWords()
|
|
868
|
+
{
|
|
869
|
+
string longWord = new('a', 1000);
|
|
870
|
+
string[] words = { "short", longWord, "medium" };
|
|
871
|
+
Trie trie = new(words);
|
|
872
|
+
|
|
873
|
+
List<string> enumerated = new();
|
|
874
|
+
foreach (string word in trie)
|
|
875
|
+
{
|
|
876
|
+
enumerated.Add(word);
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
Assert.AreEqual(3, enumerated.Count);
|
|
880
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
[Test]
|
|
884
|
+
public void EnumeratorHandlesManyWords()
|
|
885
|
+
{
|
|
886
|
+
List<string> words = new();
|
|
887
|
+
for (int i = 0; i < 1000; i++)
|
|
888
|
+
{
|
|
889
|
+
words.Add($"word{i}");
|
|
890
|
+
}
|
|
891
|
+
Trie trie = new(words);
|
|
892
|
+
|
|
893
|
+
List<string> enumerated = new();
|
|
894
|
+
foreach (string word in trie)
|
|
895
|
+
{
|
|
896
|
+
enumerated.Add(word);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
Assert.AreEqual(1000, enumerated.Count);
|
|
900
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
[Test]
|
|
904
|
+
public void EnumeratorUsesValueTypeForEfficiency()
|
|
905
|
+
{
|
|
906
|
+
string[] words = { "test" };
|
|
907
|
+
Trie trie = new(words);
|
|
908
|
+
|
|
909
|
+
// Get the enumerator directly to verify it's a value type
|
|
910
|
+
using Trie.Enumerator enumerator = trie.GetEnumerator();
|
|
911
|
+
Assert.IsTrue(enumerator.GetType().IsValueType);
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
[Test]
|
|
915
|
+
public void EnumeratorCanBreakEarly()
|
|
916
|
+
{
|
|
917
|
+
string[] words = { "apple", "banana", "cherry", "date", "elderberry" };
|
|
918
|
+
Trie trie = new(words);
|
|
919
|
+
|
|
920
|
+
int count = 0;
|
|
921
|
+
foreach (string word in trie)
|
|
922
|
+
{
|
|
923
|
+
count++;
|
|
924
|
+
if (count == 3)
|
|
925
|
+
{
|
|
926
|
+
break;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
Assert.AreEqual(3, count);
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
[Test]
|
|
934
|
+
public void EnumeratorWorksWithLinq()
|
|
935
|
+
{
|
|
936
|
+
string[] words = { "apple", "apricot", "banana", "cherry" };
|
|
937
|
+
Trie trie = new(words);
|
|
938
|
+
|
|
939
|
+
List<string> filtered = trie.Where(w => w.StartsWith("a")).ToList();
|
|
940
|
+
|
|
941
|
+
Assert.AreEqual(2, filtered.Count);
|
|
942
|
+
Assert.IsTrue(filtered.Contains("apple"));
|
|
943
|
+
Assert.IsTrue(filtered.Contains("apricot"));
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
[Test]
|
|
947
|
+
public void EnumeratorHandlesDuplicateWords()
|
|
948
|
+
{
|
|
949
|
+
string[] words = { "test", "test", "unique" };
|
|
950
|
+
Trie trie = new(words);
|
|
951
|
+
|
|
952
|
+
List<string> enumerated = new();
|
|
953
|
+
foreach (string word in trie)
|
|
954
|
+
{
|
|
955
|
+
enumerated.Add(word);
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
// Trie should deduplicate
|
|
959
|
+
Assert.AreEqual(2, enumerated.Count);
|
|
960
|
+
Assert.IsTrue(enumerated.Contains("test"));
|
|
961
|
+
Assert.IsTrue(enumerated.Contains("unique"));
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
[Test]
|
|
965
|
+
public void EnumeratorHandlesSpecialCharacters()
|
|
966
|
+
{
|
|
967
|
+
string[] words = { "hello!", "world?", "test@123" };
|
|
968
|
+
Trie trie = new(words);
|
|
969
|
+
|
|
970
|
+
List<string> enumerated = new();
|
|
971
|
+
foreach (string word in trie)
|
|
972
|
+
{
|
|
973
|
+
enumerated.Add(word);
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
Assert.AreEqual(3, enumerated.Count);
|
|
977
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
[Test]
|
|
981
|
+
public void EnumeratorHandlesOnlyEmptyString()
|
|
982
|
+
{
|
|
983
|
+
string[] words = { "" };
|
|
984
|
+
Trie trie = new(words);
|
|
985
|
+
|
|
986
|
+
List<string> enumerated = new();
|
|
987
|
+
foreach (string word in trie)
|
|
988
|
+
{
|
|
989
|
+
enumerated.Add(word);
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
Assert.AreEqual(1, enumerated.Count);
|
|
993
|
+
Assert.AreEqual("", enumerated[0]);
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
[Test]
|
|
997
|
+
public void EnumeratorHandlesMultipleEmptyStrings()
|
|
998
|
+
{
|
|
999
|
+
string[] words = { "", "", "" };
|
|
1000
|
+
Trie trie = new(words);
|
|
1001
|
+
|
|
1002
|
+
List<string> enumerated = new();
|
|
1003
|
+
foreach (string word in trie)
|
|
1004
|
+
{
|
|
1005
|
+
enumerated.Add(word);
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
// Trie should deduplicate
|
|
1009
|
+
Assert.AreEqual(1, enumerated.Count);
|
|
1010
|
+
Assert.AreEqual("", enumerated[0]);
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
[Test]
|
|
1014
|
+
public void EnumeratorHandlesWordsAsCompleteSubsets()
|
|
1015
|
+
{
|
|
1016
|
+
string[] words = { "a", "aa", "aaa", "aaaa" };
|
|
1017
|
+
Trie trie = new(words);
|
|
1018
|
+
|
|
1019
|
+
List<string> enumerated = new();
|
|
1020
|
+
foreach (string word in trie)
|
|
1021
|
+
{
|
|
1022
|
+
enumerated.Add(word);
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
Assert.AreEqual(4, enumerated.Count);
|
|
1026
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
[Test]
|
|
1030
|
+
public void MultipleEnumeratorsCanRunSimultaneously()
|
|
1031
|
+
{
|
|
1032
|
+
string[] words = { "apple", "banana", "cherry", "date" };
|
|
1033
|
+
Trie trie = new(words);
|
|
1034
|
+
|
|
1035
|
+
using Trie.Enumerator enumerator1 = trie.GetEnumerator();
|
|
1036
|
+
using Trie.Enumerator enumerator2 = trie.GetEnumerator();
|
|
1037
|
+
|
|
1038
|
+
List<string> list1 = new();
|
|
1039
|
+
List<string> list2 = new();
|
|
1040
|
+
|
|
1041
|
+
// Interleave enumeration
|
|
1042
|
+
Assert.IsTrue(enumerator1.MoveNext());
|
|
1043
|
+
list1.Add(enumerator1.Current);
|
|
1044
|
+
|
|
1045
|
+
Assert.IsTrue(enumerator2.MoveNext());
|
|
1046
|
+
list2.Add(enumerator2.Current);
|
|
1047
|
+
|
|
1048
|
+
Assert.IsTrue(enumerator1.MoveNext());
|
|
1049
|
+
list1.Add(enumerator1.Current);
|
|
1050
|
+
|
|
1051
|
+
while (enumerator1.MoveNext())
|
|
1052
|
+
{
|
|
1053
|
+
list1.Add(enumerator1.Current);
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
while (enumerator2.MoveNext())
|
|
1057
|
+
{
|
|
1058
|
+
list2.Add(enumerator2.Current);
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
Assert.AreEqual(4, list1.Count);
|
|
1062
|
+
Assert.AreEqual(4, list2.Count);
|
|
1063
|
+
CollectionAssert.AreEquivalent(words, list1);
|
|
1064
|
+
CollectionAssert.AreEquivalent(words, list2);
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
[Test]
|
|
1068
|
+
public void EnumeratorHandlesNestedPrefixesWithEmptyString()
|
|
1069
|
+
{
|
|
1070
|
+
string[] words = { "", "a", "ab", "abc", "abcd" };
|
|
1071
|
+
Trie trie = new(words);
|
|
1072
|
+
|
|
1073
|
+
List<string> enumerated = new();
|
|
1074
|
+
foreach (string word in trie)
|
|
1075
|
+
{
|
|
1076
|
+
enumerated.Add(word);
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
Assert.AreEqual(5, enumerated.Count);
|
|
1080
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
[Test]
|
|
1084
|
+
public void EnumeratorHandlesDeeplyNestedSingleBranch()
|
|
1085
|
+
{
|
|
1086
|
+
List<string> words = new();
|
|
1087
|
+
for (int i = 1; i <= 100; i++)
|
|
1088
|
+
{
|
|
1089
|
+
words.Add(new string('a', i));
|
|
1090
|
+
}
|
|
1091
|
+
Trie trie = new(words);
|
|
1092
|
+
|
|
1093
|
+
List<string> enumerated = new();
|
|
1094
|
+
foreach (string word in trie)
|
|
1095
|
+
{
|
|
1096
|
+
enumerated.Add(word);
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
Assert.AreEqual(100, enumerated.Count);
|
|
1100
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
[Test]
|
|
1104
|
+
public void EnumeratorHandlesWideBranching()
|
|
1105
|
+
{
|
|
1106
|
+
List<string> words = new();
|
|
1107
|
+
for (char c = 'a'; c <= 'z'; c++)
|
|
1108
|
+
{
|
|
1109
|
+
words.Add(c.ToString());
|
|
1110
|
+
}
|
|
1111
|
+
Trie trie = new(words);
|
|
1112
|
+
|
|
1113
|
+
List<string> enumerated = new();
|
|
1114
|
+
foreach (string word in trie)
|
|
1115
|
+
{
|
|
1116
|
+
enumerated.Add(word);
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
Assert.AreEqual(26, enumerated.Count);
|
|
1120
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
[Test]
|
|
1124
|
+
public void EnumeratorWithIEnumerableInterface()
|
|
1125
|
+
{
|
|
1126
|
+
string[] words = { "test1", "test2", "test3" };
|
|
1127
|
+
Trie trie = new(words);
|
|
1128
|
+
|
|
1129
|
+
System.Collections.IEnumerable enumerable = trie;
|
|
1130
|
+
List<string> enumerated = new();
|
|
1131
|
+
|
|
1132
|
+
foreach (object word in enumerable)
|
|
1133
|
+
{
|
|
1134
|
+
enumerated.Add((string)word);
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
Assert.AreEqual(3, enumerated.Count);
|
|
1138
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
[Test]
|
|
1142
|
+
public void EnumeratorHandlesWhitespaceOnlyWords()
|
|
1143
|
+
{
|
|
1144
|
+
string[] words = { " ", " ", " ", "\t", "\n" };
|
|
1145
|
+
Trie trie = new(words);
|
|
1146
|
+
|
|
1147
|
+
List<string> enumerated = new();
|
|
1148
|
+
foreach (string word in trie)
|
|
1149
|
+
{
|
|
1150
|
+
enumerated.Add(word);
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
Assert.AreEqual(5, enumerated.Count);
|
|
1154
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
[Test]
|
|
1158
|
+
public void GetWordsWithPrefixHandlesMaxResultsZero()
|
|
1159
|
+
{
|
|
1160
|
+
Trie trie = new(new[] { "apple", "application", "apply" });
|
|
1161
|
+
List<string> results = new();
|
|
1162
|
+
int count = trie.GetWordsWithPrefix("app", results, maxResults: 0).Count;
|
|
1163
|
+
|
|
1164
|
+
Assert.AreEqual(0, count);
|
|
1165
|
+
Assert.AreEqual(0, results.Count);
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
[Test]
|
|
1169
|
+
public void GetWordsWithPrefixHandlesMaxResultsNegative()
|
|
1170
|
+
{
|
|
1171
|
+
Trie trie = new(new[] { "apple", "application", "apply" });
|
|
1172
|
+
List<string> results = new();
|
|
1173
|
+
int count = trie.GetWordsWithPrefix("app", results, maxResults: -1).Count;
|
|
1174
|
+
|
|
1175
|
+
Assert.AreEqual(0, count);
|
|
1176
|
+
Assert.AreEqual(0, results.Count);
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
[Test]
|
|
1180
|
+
public void GetWordsWithPrefixIncludesEmptyStringWhenPrefixIsEmpty()
|
|
1181
|
+
{
|
|
1182
|
+
string[] words = { "", "a", "b" };
|
|
1183
|
+
Trie trie = new(words);
|
|
1184
|
+
List<string> results = new();
|
|
1185
|
+
trie.GetWordsWithPrefix("", results);
|
|
1186
|
+
|
|
1187
|
+
Assert.AreEqual(3, results.Count);
|
|
1188
|
+
CollectionAssert.AreEquivalent(words, results);
|
|
1189
|
+
Assert.IsTrue(results.Contains(""));
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
[Test]
|
|
1193
|
+
public void GetWordsWithPrefixWithEmptyStringAsPrefix()
|
|
1194
|
+
{
|
|
1195
|
+
string[] words = { "", "test" };
|
|
1196
|
+
Trie trie = new(words);
|
|
1197
|
+
List<string> results = new();
|
|
1198
|
+
trie.GetWordsWithPrefix("", results);
|
|
1199
|
+
|
|
1200
|
+
Assert.AreEqual(2, results.Count);
|
|
1201
|
+
CollectionAssert.Contains(results, "");
|
|
1202
|
+
CollectionAssert.Contains(results, "test");
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
[Test]
|
|
1206
|
+
public void EnumeratorHandlesAlternatingBranches()
|
|
1207
|
+
{
|
|
1208
|
+
string[] words = { "a", "b", "aa", "bb", "aaa", "bbb" };
|
|
1209
|
+
Trie trie = new(words);
|
|
1210
|
+
|
|
1211
|
+
List<string> enumerated = new();
|
|
1212
|
+
foreach (string word in trie)
|
|
1213
|
+
{
|
|
1214
|
+
enumerated.Add(word);
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
Assert.AreEqual(6, enumerated.Count);
|
|
1218
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
[Test]
|
|
1222
|
+
public void EnumeratorHandlesMixedLengthWords()
|
|
1223
|
+
{
|
|
1224
|
+
string[] words = { "x", "xx", "xxx", "y", "yy", "z" };
|
|
1225
|
+
Trie trie = new(words);
|
|
1226
|
+
|
|
1227
|
+
List<string> enumerated = new();
|
|
1228
|
+
foreach (string word in trie)
|
|
1229
|
+
{
|
|
1230
|
+
enumerated.Add(word);
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
Assert.AreEqual(6, enumerated.Count);
|
|
1234
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
[Test]
|
|
1238
|
+
public void ContainsHandlesNullCharacterInWord()
|
|
1239
|
+
{
|
|
1240
|
+
string[] words = { "test\0ing", "normal" };
|
|
1241
|
+
Trie trie = new(words);
|
|
1242
|
+
|
|
1243
|
+
Assert.IsTrue(trie.Contains("test\0ing"));
|
|
1244
|
+
Assert.IsTrue(trie.Contains("normal"));
|
|
1245
|
+
Assert.IsFalse(trie.Contains("testing"));
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
[Test]
|
|
1249
|
+
public void EnumeratorHandlesNullCharacterInWords()
|
|
1250
|
+
{
|
|
1251
|
+
string[] words = { "abc\0def", "test\0", "\0start" };
|
|
1252
|
+
Trie trie = new(words);
|
|
1253
|
+
|
|
1254
|
+
List<string> enumerated = new();
|
|
1255
|
+
foreach (string word in trie)
|
|
1256
|
+
{
|
|
1257
|
+
enumerated.Add(word);
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
Assert.AreEqual(3, enumerated.Count);
|
|
1261
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
[Test]
|
|
1265
|
+
public void GetWordsWithPrefixHandlesPrefixWithNullCharacter()
|
|
1266
|
+
{
|
|
1267
|
+
string[] words = { "test\0a", "test\0b", "other" };
|
|
1268
|
+
Trie trie = new(words);
|
|
1269
|
+
List<string> results = new();
|
|
1270
|
+
trie.GetWordsWithPrefix("test\0", results);
|
|
1271
|
+
|
|
1272
|
+
Assert.AreEqual(2, results.Count);
|
|
1273
|
+
CollectionAssert.Contains(results, "test\0a");
|
|
1274
|
+
CollectionAssert.Contains(results, "test\0b");
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
[Test]
|
|
1278
|
+
public void EnumeratorHandlesComplexUnicodeMixedWithAscii()
|
|
1279
|
+
{
|
|
1280
|
+
string[] words = { "test", "测试", "test测试", "🎉emoji", "mixed🎉test" };
|
|
1281
|
+
Trie trie = new(words);
|
|
1282
|
+
|
|
1283
|
+
List<string> enumerated = new();
|
|
1284
|
+
foreach (string word in trie)
|
|
1285
|
+
{
|
|
1286
|
+
enumerated.Add(word);
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
Assert.AreEqual(5, enumerated.Count);
|
|
1290
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
[Test]
|
|
1294
|
+
public void EnumeratorHandlesSurrogatePairs()
|
|
1295
|
+
{
|
|
1296
|
+
string[] words = { "𝕳𝖊𝖑𝖑𝖔", "𝓦𝓸𝓻𝓵𝓭", "🚀🌟" };
|
|
1297
|
+
Trie trie = new(words);
|
|
1298
|
+
|
|
1299
|
+
List<string> enumerated = new();
|
|
1300
|
+
foreach (string word in trie)
|
|
1301
|
+
{
|
|
1302
|
+
enumerated.Add(word);
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
Assert.AreEqual(3, enumerated.Count);
|
|
1306
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
[Test]
|
|
1310
|
+
public void GetWordsWithPrefixStressTestWithManyResults()
|
|
1311
|
+
{
|
|
1312
|
+
List<string> words = new();
|
|
1313
|
+
for (int i = 0; i < 10000; i++)
|
|
1314
|
+
{
|
|
1315
|
+
words.Add($"prefix{i}");
|
|
1316
|
+
}
|
|
1317
|
+
Trie trie = new(words);
|
|
1318
|
+
List<string> results = new();
|
|
1319
|
+
trie.GetWordsWithPrefix("prefix", results);
|
|
1320
|
+
|
|
1321
|
+
Assert.AreEqual(10000, results.Count);
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
[Test]
|
|
1325
|
+
public void EnumeratorStressTestWithDeeplyNestedAndWideBranching()
|
|
1326
|
+
{
|
|
1327
|
+
List<string> words = new();
|
|
1328
|
+
// Create a combination of deep and wide branching
|
|
1329
|
+
for (int i = 0; i < 100; i++)
|
|
1330
|
+
{
|
|
1331
|
+
words.Add(new string('a', i + 1));
|
|
1332
|
+
words.Add(new string('b', i + 1));
|
|
1333
|
+
words.Add(new string('c', i + 1));
|
|
1334
|
+
}
|
|
1335
|
+
Trie trie = new(words);
|
|
1336
|
+
|
|
1337
|
+
List<string> enumerated = new();
|
|
1338
|
+
foreach (string word in trie)
|
|
1339
|
+
{
|
|
1340
|
+
enumerated.Add(word);
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
Assert.AreEqual(300, enumerated.Count);
|
|
1344
|
+
CollectionAssert.AreEquivalent(words, enumerated);
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
[Test]
|
|
1348
|
+
public void EnumeratorHandlesSingleCharacterRepeated()
|
|
1349
|
+
{
|
|
1350
|
+
string[] words = { "a", "a", "a" };
|
|
1351
|
+
Trie trie = new(words);
|
|
1352
|
+
|
|
1353
|
+
List<string> enumerated = new();
|
|
1354
|
+
foreach (string word in trie)
|
|
1355
|
+
{
|
|
1356
|
+
enumerated.Add(word);
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
// Should be deduplicated
|
|
1360
|
+
Assert.AreEqual(1, enumerated.Count);
|
|
1361
|
+
Assert.AreEqual("a", enumerated[0]);
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
[Test]
|
|
1365
|
+
public void GetWordsWithPrefixWithMaxResultsLargerThanAvailable()
|
|
1366
|
+
{
|
|
1367
|
+
Trie trie = new(new[] { "a", "b" });
|
|
1368
|
+
List<string> results = new();
|
|
1369
|
+
int count = trie.GetWordsWithPrefix("", results, maxResults: 1000).Count;
|
|
1370
|
+
|
|
1371
|
+
Assert.AreEqual(2, count);
|
|
1372
|
+
Assert.AreEqual(2, results.Count);
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
[Test]
|
|
1376
|
+
public void EnumeratorCurrentBeforeMoveNextReturnsDefault()
|
|
1377
|
+
{
|
|
1378
|
+
Trie trie = new(new[] { "test" });
|
|
1379
|
+
using Trie.Enumerator enumerator = trie.GetEnumerator();
|
|
1380
|
+
|
|
1381
|
+
// Current should be null before first MoveNext
|
|
1382
|
+
Assert.IsNull(enumerator.Current);
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
[Test]
|
|
1386
|
+
public void EnumeratorCurrentAfterLastMoveNextReturnsLastValue()
|
|
1387
|
+
{
|
|
1388
|
+
Trie trie = new(new[] { "single" });
|
|
1389
|
+
using Trie.Enumerator enumerator = trie.GetEnumerator();
|
|
1390
|
+
|
|
1391
|
+
Assert.IsTrue(enumerator.MoveNext());
|
|
1392
|
+
string lastValue = enumerator.Current;
|
|
1393
|
+
Assert.IsFalse(enumerator.MoveNext());
|
|
1394
|
+
|
|
1395
|
+
// Current should still return the last value
|
|
1396
|
+
Assert.AreEqual(lastValue, enumerator.Current);
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
[Test]
|
|
1400
|
+
public void ContainsWithVeryLongWord()
|
|
1401
|
+
{
|
|
1402
|
+
string longWord = new('x', 10000);
|
|
1403
|
+
Trie trie = new(new[] { longWord });
|
|
1404
|
+
|
|
1405
|
+
Assert.IsTrue(trie.Contains(longWord));
|
|
1406
|
+
Assert.IsFalse(trie.Contains(longWord + "y"));
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
[Test]
|
|
1410
|
+
public void GetWordsWithPrefixWithVeryLongPrefix()
|
|
1411
|
+
{
|
|
1412
|
+
string longPrefix = new('x', 5000);
|
|
1413
|
+
string longerWord = longPrefix + "extra";
|
|
1414
|
+
Trie trie = new(new[] { longerWord });
|
|
1415
|
+
List<string> results = new();
|
|
1416
|
+
trie.GetWordsWithPrefix(longPrefix, results);
|
|
1417
|
+
|
|
1418
|
+
Assert.AreEqual(1, results.Count);
|
|
1419
|
+
Assert.AreEqual(longerWord, results[0]);
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
public sealed class GenericTrieTests
|
|
1424
|
+
{
|
|
1425
|
+
[Test]
|
|
1426
|
+
public void ConstructorWithEmptyDictionaryCreatesValidTrie()
|
|
1427
|
+
{
|
|
1428
|
+
Trie<int> trie = new(new Dictionary<string, int>());
|
|
1429
|
+
Assert.IsFalse(trie.TryGetValue("test", out _));
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
[Test]
|
|
1433
|
+
public void ConstructorWithNullDictionaryThrows()
|
|
1434
|
+
{
|
|
1435
|
+
Assert.Throws<ArgumentNullException>(() => new Trie<int>(null));
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
[Test]
|
|
1439
|
+
public void ConstructorWithSingleEntryCreatesValidTrie()
|
|
1440
|
+
{
|
|
1441
|
+
Dictionary<string, int> dict = new() { { "test", 42 } };
|
|
1442
|
+
Trie<int> trie = new(dict);
|
|
1443
|
+
|
|
1444
|
+
Assert.IsTrue(trie.TryGetValue("test", out int value));
|
|
1445
|
+
Assert.AreEqual(42, value);
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
[Test]
|
|
1449
|
+
public void ConstructorWithMultipleEntriesCreatesValidTrie()
|
|
1450
|
+
{
|
|
1451
|
+
Dictionary<string, int> dict = new()
|
|
1452
|
+
{
|
|
1453
|
+
{ "apple", 1 },
|
|
1454
|
+
{ "banana", 2 },
|
|
1455
|
+
{ "cherry", 3 },
|
|
1456
|
+
};
|
|
1457
|
+
Trie<int> trie = new(dict);
|
|
1458
|
+
|
|
1459
|
+
Assert.IsTrue(trie.TryGetValue("apple", out int value1));
|
|
1460
|
+
Assert.AreEqual(1, value1);
|
|
1461
|
+
Assert.IsTrue(trie.TryGetValue("banana", out int value2));
|
|
1462
|
+
Assert.AreEqual(2, value2);
|
|
1463
|
+
Assert.IsTrue(trie.TryGetValue("cherry", out int value3));
|
|
1464
|
+
Assert.AreEqual(3, value3);
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
[Test]
|
|
1468
|
+
public void TryGetValueReturnsFalseForNonExistentKey()
|
|
1469
|
+
{
|
|
1470
|
+
Dictionary<string, string> dict = new() { { "test", "value" } };
|
|
1471
|
+
Trie<string> trie = new(dict);
|
|
1472
|
+
|
|
1473
|
+
Assert.IsFalse(trie.TryGetValue("nonexistent", out string value));
|
|
1474
|
+
Assert.IsNull(value);
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
[Test]
|
|
1478
|
+
public void TryGetValueReturnsFalseForPrefix()
|
|
1479
|
+
{
|
|
1480
|
+
Dictionary<string, int> dict = new() { { "testing", 100 } };
|
|
1481
|
+
Trie<int> trie = new(dict);
|
|
1482
|
+
|
|
1483
|
+
Assert.IsFalse(trie.TryGetValue("test", out _));
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
[Test]
|
|
1487
|
+
public void TryGetValueReturnsTrueForExactKey()
|
|
1488
|
+
{
|
|
1489
|
+
Dictionary<string, string> dict = new()
|
|
1490
|
+
{
|
|
1491
|
+
{ "test", "value1" },
|
|
1492
|
+
{ "testing", "value2" },
|
|
1493
|
+
};
|
|
1494
|
+
Trie<string> trie = new(dict);
|
|
1495
|
+
|
|
1496
|
+
Assert.IsTrue(trie.TryGetValue("test", out string value1));
|
|
1497
|
+
Assert.AreEqual("value1", value1);
|
|
1498
|
+
Assert.IsTrue(trie.TryGetValue("testing", out string value2));
|
|
1499
|
+
Assert.AreEqual("value2", value2);
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
[Test]
|
|
1503
|
+
public void TryGetValueReturnsFalseForEmptyString()
|
|
1504
|
+
{
|
|
1505
|
+
Dictionary<string, int> dict = new() { { "test", 42 } };
|
|
1506
|
+
Trie<int> trie = new(dict);
|
|
1507
|
+
|
|
1508
|
+
Assert.IsFalse(trie.TryGetValue("", out _));
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
[Test]
|
|
1512
|
+
public void TryGetValueHandlesEmptyStringInDictionary()
|
|
1513
|
+
{
|
|
1514
|
+
Dictionary<string, int> dict = new() { { "", 0 }, { "test", 42 } };
|
|
1515
|
+
Trie<int> trie = new(dict);
|
|
1516
|
+
|
|
1517
|
+
Assert.IsTrue(trie.TryGetValue("", out int value1));
|
|
1518
|
+
Assert.AreEqual(0, value1);
|
|
1519
|
+
Assert.IsTrue(trie.TryGetValue("test", out int value2));
|
|
1520
|
+
Assert.AreEqual(42, value2);
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
[Test]
|
|
1524
|
+
public void TryGetValueCaseSensitive()
|
|
1525
|
+
{
|
|
1526
|
+
Dictionary<string, int> dict = new() { { "test", 42 } };
|
|
1527
|
+
Trie<int> trie = new(dict);
|
|
1528
|
+
|
|
1529
|
+
Assert.IsTrue(trie.TryGetValue("test", out int value));
|
|
1530
|
+
Assert.AreEqual(42, value);
|
|
1531
|
+
Assert.IsFalse(trie.TryGetValue("TEST", out _));
|
|
1532
|
+
Assert.IsFalse(trie.TryGetValue("Test", out _));
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
[Test]
|
|
1536
|
+
public void GetValuesWithPrefixReturnsEmptyForNonMatchingPrefix()
|
|
1537
|
+
{
|
|
1538
|
+
Dictionary<string, int> dict = new()
|
|
1539
|
+
{
|
|
1540
|
+
{ "apple", 1 },
|
|
1541
|
+
{ "banana", 2 },
|
|
1542
|
+
{ "cherry", 3 },
|
|
1543
|
+
};
|
|
1544
|
+
Trie<int> trie = new(dict);
|
|
1545
|
+
List<int> results = new();
|
|
1546
|
+
|
|
1547
|
+
int count = trie.GetValuesWithPrefix("xyz", results).Count;
|
|
1548
|
+
|
|
1549
|
+
Assert.AreEqual(0, count);
|
|
1550
|
+
Assert.AreEqual(0, results.Count);
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
[Test]
|
|
1554
|
+
public void GetValuesWithPrefixReturnsMatchingValues()
|
|
1555
|
+
{
|
|
1556
|
+
Dictionary<string, int> dict = new()
|
|
1557
|
+
{
|
|
1558
|
+
{ "apple", 1 },
|
|
1559
|
+
{ "application", 2 },
|
|
1560
|
+
{ "apply", 3 },
|
|
1561
|
+
{ "banana", 4 },
|
|
1562
|
+
};
|
|
1563
|
+
Trie<int> trie = new(dict);
|
|
1564
|
+
List<int> results = new();
|
|
1565
|
+
|
|
1566
|
+
int count = trie.GetValuesWithPrefix("app", results).Count;
|
|
1567
|
+
|
|
1568
|
+
Assert.AreEqual(3, count);
|
|
1569
|
+
Assert.AreEqual(3, results.Count);
|
|
1570
|
+
CollectionAssert.AreEquivalent(new[] { 1, 2, 3 }, results);
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
[Test]
|
|
1574
|
+
public void GetValuesWithPrefixReturnsAllValuesForEmptyPrefix()
|
|
1575
|
+
{
|
|
1576
|
+
Dictionary<string, int> dict = new()
|
|
1577
|
+
{
|
|
1578
|
+
{ "apple", 1 },
|
|
1579
|
+
{ "banana", 2 },
|
|
1580
|
+
{ "cherry", 3 },
|
|
1581
|
+
};
|
|
1582
|
+
Trie<int> trie = new(dict);
|
|
1583
|
+
List<int> results = new();
|
|
1584
|
+
|
|
1585
|
+
int count = trie.GetValuesWithPrefix("", results).Count;
|
|
1586
|
+
|
|
1587
|
+
Assert.AreEqual(3, count);
|
|
1588
|
+
CollectionAssert.AreEquivalent(new[] { 1, 2, 3 }, results);
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
[Test]
|
|
1592
|
+
public void GetValuesWithPrefixRespectsMaxResults()
|
|
1593
|
+
{
|
|
1594
|
+
Dictionary<string, int> dict = new()
|
|
1595
|
+
{
|
|
1596
|
+
{ "apple", 1 },
|
|
1597
|
+
{ "application", 2 },
|
|
1598
|
+
{ "apply", 3 },
|
|
1599
|
+
{ "approach", 4 },
|
|
1600
|
+
};
|
|
1601
|
+
Trie<int> trie = new(dict);
|
|
1602
|
+
List<int> results = new();
|
|
1603
|
+
|
|
1604
|
+
int count = trie.GetValuesWithPrefix("app", results, maxResults: 2).Count;
|
|
1605
|
+
|
|
1606
|
+
Assert.AreEqual(2, count);
|
|
1607
|
+
Assert.AreEqual(2, results.Count);
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
[Test]
|
|
1611
|
+
public void GetValuesWithPrefixClearsResultsList()
|
|
1612
|
+
{
|
|
1613
|
+
Dictionary<string, int> dict = new() { { "apple", 1 }, { "banana", 2 } };
|
|
1614
|
+
Trie<int> trie = new(dict);
|
|
1615
|
+
List<int> results = new() { 100, 200 };
|
|
1616
|
+
|
|
1617
|
+
trie.GetValuesWithPrefix("app", results);
|
|
1618
|
+
|
|
1619
|
+
Assert.AreEqual(1, results.Count);
|
|
1620
|
+
Assert.AreEqual(1, results[0]);
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
[Test]
|
|
1624
|
+
public void GetValuesWithPrefixHandlesExactMatch()
|
|
1625
|
+
{
|
|
1626
|
+
Dictionary<string, int> dict = new()
|
|
1627
|
+
{
|
|
1628
|
+
{ "test", 1 },
|
|
1629
|
+
{ "testing", 2 },
|
|
1630
|
+
{ "tester", 3 },
|
|
1631
|
+
};
|
|
1632
|
+
Trie<int> trie = new(dict);
|
|
1633
|
+
List<int> results = new();
|
|
1634
|
+
|
|
1635
|
+
trie.GetValuesWithPrefix("test", results);
|
|
1636
|
+
|
|
1637
|
+
Assert.AreEqual(3, results.Count);
|
|
1638
|
+
CollectionAssert.Contains(results, 1);
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
[Test]
|
|
1642
|
+
public void GenericTrieHandlesComplexTypes()
|
|
1643
|
+
{
|
|
1644
|
+
Dictionary<string, List<int>> dict = new()
|
|
1645
|
+
{
|
|
1646
|
+
{
|
|
1647
|
+
"key1",
|
|
1648
|
+
new List<int> { 1, 2, 3 }
|
|
1649
|
+
},
|
|
1650
|
+
{
|
|
1651
|
+
"key2",
|
|
1652
|
+
new List<int> { 4, 5, 6 }
|
|
1653
|
+
},
|
|
1654
|
+
};
|
|
1655
|
+
Trie<List<int>> trie = new(dict);
|
|
1656
|
+
|
|
1657
|
+
Assert.IsTrue(trie.TryGetValue("key1", out List<int> value1));
|
|
1658
|
+
CollectionAssert.AreEqual(new[] { 1, 2, 3 }, value1);
|
|
1659
|
+
Assert.IsTrue(trie.TryGetValue("key2", out List<int> value2));
|
|
1660
|
+
CollectionAssert.AreEqual(new[] { 4, 5, 6 }, value2);
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
[Test]
|
|
1664
|
+
public void GenericTrieHandlesNullableValues()
|
|
1665
|
+
{
|
|
1666
|
+
Dictionary<string, int?> dict = new() { { "null", null }, { "value", 42 } };
|
|
1667
|
+
Trie<int?> trie = new(dict);
|
|
1668
|
+
|
|
1669
|
+
Assert.IsTrue(trie.TryGetValue("null", out int? value1));
|
|
1670
|
+
Assert.IsNull(value1);
|
|
1671
|
+
Assert.IsTrue(trie.TryGetValue("value", out int? value2));
|
|
1672
|
+
Assert.AreEqual(42, value2);
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
[Test]
|
|
1676
|
+
public void GenericTrieHandlesReferenceTypes()
|
|
1677
|
+
{
|
|
1678
|
+
Dictionary<string, string> dict = new()
|
|
1679
|
+
{
|
|
1680
|
+
{ "key1", "value1" },
|
|
1681
|
+
{ "key2", "value2" },
|
|
1682
|
+
{ "key3", null },
|
|
1683
|
+
};
|
|
1684
|
+
Trie<string> trie = new(dict);
|
|
1685
|
+
|
|
1686
|
+
Assert.IsTrue(trie.TryGetValue("key1", out string value1));
|
|
1687
|
+
Assert.AreEqual("value1", value1);
|
|
1688
|
+
Assert.IsTrue(trie.TryGetValue("key3", out string value3));
|
|
1689
|
+
Assert.IsNull(value3);
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
[Test]
|
|
1693
|
+
public void GenericTrieHandlesWordsWithCommonPrefixes()
|
|
1694
|
+
{
|
|
1695
|
+
Dictionary<string, int> dict = new()
|
|
1696
|
+
{
|
|
1697
|
+
{ "car", 1 },
|
|
1698
|
+
{ "card", 2 },
|
|
1699
|
+
{ "care", 3 },
|
|
1700
|
+
{ "careful", 4 },
|
|
1701
|
+
{ "carefully", 5 },
|
|
1702
|
+
};
|
|
1703
|
+
Trie<int> trie = new(dict);
|
|
1704
|
+
|
|
1705
|
+
foreach (KeyValuePair<string, int> kvp in dict)
|
|
1706
|
+
{
|
|
1707
|
+
Assert.IsTrue(trie.TryGetValue(kvp.Key, out int value));
|
|
1708
|
+
Assert.AreEqual(kvp.Value, value);
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
List<int> results = new();
|
|
1712
|
+
trie.GetValuesWithPrefix("car", results);
|
|
1713
|
+
Assert.AreEqual(5, results.Count);
|
|
1714
|
+
CollectionAssert.AreEquivalent(new[] { 1, 2, 3, 4, 5 }, results);
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
[Test]
|
|
1718
|
+
public void GenericTrieHandlesSingleCharacterKeys()
|
|
1719
|
+
{
|
|
1720
|
+
Dictionary<string, int> dict = new()
|
|
1721
|
+
{
|
|
1722
|
+
{ "a", 1 },
|
|
1723
|
+
{ "b", 2 },
|
|
1724
|
+
{ "c", 3 },
|
|
1725
|
+
};
|
|
1726
|
+
Trie<int> trie = new(dict);
|
|
1727
|
+
|
|
1728
|
+
Assert.IsTrue(trie.TryGetValue("a", out int value1));
|
|
1729
|
+
Assert.AreEqual(1, value1);
|
|
1730
|
+
Assert.IsTrue(trie.TryGetValue("b", out int value2));
|
|
1731
|
+
Assert.AreEqual(2, value2);
|
|
1732
|
+
Assert.IsTrue(trie.TryGetValue("c", out int value3));
|
|
1733
|
+
Assert.AreEqual(3, value3);
|
|
1734
|
+
Assert.IsFalse(trie.TryGetValue("d", out _));
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
[Test]
|
|
1738
|
+
public void GenericTrieHandlesUnicodeCharacters()
|
|
1739
|
+
{
|
|
1740
|
+
Dictionary<string, string> dict = new()
|
|
1741
|
+
{
|
|
1742
|
+
{ "世界", "world" },
|
|
1743
|
+
{ "世", "generation" },
|
|
1744
|
+
{ "世界和平", "world peace" },
|
|
1745
|
+
};
|
|
1746
|
+
Trie<string> trie = new(dict);
|
|
1747
|
+
|
|
1748
|
+
Assert.IsTrue(trie.TryGetValue("世界", out string value1));
|
|
1749
|
+
Assert.AreEqual("world", value1);
|
|
1750
|
+
Assert.IsTrue(trie.TryGetValue("世", out string value2));
|
|
1751
|
+
Assert.AreEqual("generation", value2);
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
[Test]
|
|
1755
|
+
public void GenericTrieHandlesVeryLongKeys()
|
|
1756
|
+
{
|
|
1757
|
+
string longKey = new('a', 1000);
|
|
1758
|
+
Dictionary<string, int> dict = new() { { longKey, 42 } };
|
|
1759
|
+
Trie<int> trie = new(dict);
|
|
1760
|
+
|
|
1761
|
+
Assert.IsTrue(trie.TryGetValue(longKey, out int value));
|
|
1762
|
+
Assert.AreEqual(42, value);
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
[Test]
|
|
1766
|
+
public void GenericTrieHandlesManyEntries()
|
|
1767
|
+
{
|
|
1768
|
+
Dictionary<string, int> dict = Enumerable
|
|
1769
|
+
.Range(0, 1000)
|
|
1770
|
+
.ToDictionary(i => $"key{i}", i => i);
|
|
1771
|
+
Trie<int> trie = new(dict);
|
|
1772
|
+
|
|
1773
|
+
foreach (KeyValuePair<string, int> kvp in dict)
|
|
1774
|
+
{
|
|
1775
|
+
Assert.IsTrue(trie.TryGetValue(kvp.Key, out int value));
|
|
1776
|
+
Assert.AreEqual(kvp.Value, value);
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
[Test]
|
|
1781
|
+
public void TryGetValueReturnsFalseForSuperstring()
|
|
1782
|
+
{
|
|
1783
|
+
Dictionary<string, int> dict = new() { { "test", 42 } };
|
|
1784
|
+
Trie<int> trie = new(dict);
|
|
1785
|
+
Assert.IsFalse(trie.TryGetValue("testing", out _));
|
|
1786
|
+
Assert.IsFalse(trie.TryGetValue("test1", out _));
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
[Test]
|
|
1790
|
+
public void TryGetValueWithNullKeyThrows()
|
|
1791
|
+
{
|
|
1792
|
+
Dictionary<string, int> dict = new() { { "test", 42 } };
|
|
1793
|
+
Trie<int> trie = new(dict);
|
|
1794
|
+
Assert.Throws<NullReferenceException>(() => trie.TryGetValue(null, out _));
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
[Test]
|
|
1798
|
+
public void GetValuesWithPrefixWithNullPrefixThrows()
|
|
1799
|
+
{
|
|
1800
|
+
Dictionary<string, int> dict = new() { { "test", 42 } };
|
|
1801
|
+
Trie<int> trie = new(dict);
|
|
1802
|
+
List<int> results = new();
|
|
1803
|
+
Assert.Throws<NullReferenceException>(() => trie.GetValuesWithPrefix(null, results));
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
[Test]
|
|
1807
|
+
public void GetValuesWithPrefixWithNullListThrows()
|
|
1808
|
+
{
|
|
1809
|
+
Dictionary<string, int> dict = new() { { "test", 42 } };
|
|
1810
|
+
Trie<int> trie = new(dict);
|
|
1811
|
+
Assert.Throws<NullReferenceException>(() => trie.GetValuesWithPrefix("test", null));
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
[Test]
|
|
1815
|
+
public void GetValuesWithPrefixWithZeroMaxResults()
|
|
1816
|
+
{
|
|
1817
|
+
Dictionary<string, int> dict = new()
|
|
1818
|
+
{
|
|
1819
|
+
{ "apple", 1 },
|
|
1820
|
+
{ "application", 2 },
|
|
1821
|
+
{ "apply", 3 },
|
|
1822
|
+
};
|
|
1823
|
+
Trie<int> trie = new(dict);
|
|
1824
|
+
List<int> results = new();
|
|
1825
|
+
int count = trie.GetValuesWithPrefix("app", results, maxResults: 0).Count;
|
|
1826
|
+
|
|
1827
|
+
Assert.AreEqual(0, count);
|
|
1828
|
+
Assert.AreEqual(0, results.Count);
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
[Test]
|
|
1832
|
+
public void GetValuesWithPrefixWithNegativeMaxResults()
|
|
1833
|
+
{
|
|
1834
|
+
Dictionary<string, int> dict = new()
|
|
1835
|
+
{
|
|
1836
|
+
{ "apple", 1 },
|
|
1837
|
+
{ "application", 2 },
|
|
1838
|
+
{ "apply", 3 },
|
|
1839
|
+
};
|
|
1840
|
+
Trie<int> trie = new(dict);
|
|
1841
|
+
List<int> results = new();
|
|
1842
|
+
int count = trie.GetValuesWithPrefix("app", results, maxResults: -1).Count;
|
|
1843
|
+
|
|
1844
|
+
Assert.AreEqual(0, count);
|
|
1845
|
+
Assert.AreEqual(0, results.Count);
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
[Test]
|
|
1849
|
+
public void GetValuesWithPrefixWithOneMaxResult()
|
|
1850
|
+
{
|
|
1851
|
+
Dictionary<string, int> dict = new()
|
|
1852
|
+
{
|
|
1853
|
+
{ "apple", 1 },
|
|
1854
|
+
{ "application", 2 },
|
|
1855
|
+
{ "apply", 3 },
|
|
1856
|
+
};
|
|
1857
|
+
Trie<int> trie = new(dict);
|
|
1858
|
+
List<int> results = new();
|
|
1859
|
+
int count = trie.GetValuesWithPrefix("app", results, maxResults: 1).Count;
|
|
1860
|
+
|
|
1861
|
+
Assert.AreEqual(1, count);
|
|
1862
|
+
Assert.AreEqual(1, results.Count);
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
[Test]
|
|
1866
|
+
public void GenericTrieHandlesKeysWhereOneIsCompleteSubstringOfAnother()
|
|
1867
|
+
{
|
|
1868
|
+
Dictionary<string, int> dict = new()
|
|
1869
|
+
{
|
|
1870
|
+
{ "a", 1 },
|
|
1871
|
+
{ "ab", 2 },
|
|
1872
|
+
{ "abc", 3 },
|
|
1873
|
+
{ "abcd", 4 },
|
|
1874
|
+
{ "abcde", 5 },
|
|
1875
|
+
};
|
|
1876
|
+
Trie<int> trie = new(dict);
|
|
1877
|
+
|
|
1878
|
+
foreach (KeyValuePair<string, int> kvp in dict)
|
|
1879
|
+
{
|
|
1880
|
+
Assert.IsTrue(trie.TryGetValue(kvp.Key, out int value));
|
|
1881
|
+
Assert.AreEqual(kvp.Value, value);
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1884
|
+
Assert.IsFalse(trie.TryGetValue("abcdef", out _));
|
|
1885
|
+
Assert.IsFalse(trie.TryGetValue("", out _));
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
[Test]
|
|
1889
|
+
public void GenericTrieHandlesKeysThatShareNoCommonPrefix()
|
|
1890
|
+
{
|
|
1891
|
+
Dictionary<string, int> dict = new()
|
|
1892
|
+
{
|
|
1893
|
+
{ "apple", 1 },
|
|
1894
|
+
{ "banana", 2 },
|
|
1895
|
+
{ "cherry", 3 },
|
|
1896
|
+
{ "date", 4 },
|
|
1897
|
+
{ "elderberry", 5 },
|
|
1898
|
+
};
|
|
1899
|
+
Trie<int> trie = new(dict);
|
|
1900
|
+
|
|
1901
|
+
foreach (KeyValuePair<string, int> kvp in dict)
|
|
1902
|
+
{
|
|
1903
|
+
Assert.IsTrue(trie.TryGetValue(kvp.Key, out int value));
|
|
1904
|
+
Assert.AreEqual(kvp.Value, value);
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
[Test]
|
|
1909
|
+
public void GenericTrieHandlesBranchingAtEachLevel()
|
|
1910
|
+
{
|
|
1911
|
+
Dictionary<string, int> dict = new()
|
|
1912
|
+
{
|
|
1913
|
+
{ "a", 1 },
|
|
1914
|
+
{ "b", 2 },
|
|
1915
|
+
{ "aa", 3 },
|
|
1916
|
+
{ "ab", 4 },
|
|
1917
|
+
{ "ba", 5 },
|
|
1918
|
+
{ "bb", 6 },
|
|
1919
|
+
};
|
|
1920
|
+
Trie<int> trie = new(dict);
|
|
1921
|
+
|
|
1922
|
+
foreach (KeyValuePair<string, int> kvp in dict)
|
|
1923
|
+
{
|
|
1924
|
+
Assert.IsTrue(trie.TryGetValue(kvp.Key, out int value));
|
|
1925
|
+
Assert.AreEqual(kvp.Value, value);
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
Assert.IsFalse(trie.TryGetValue("baa", out _));
|
|
1929
|
+
Assert.IsFalse(trie.TryGetValue("c", out _));
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
[Test]
|
|
1933
|
+
public void GetValuesWithPrefixWithSingleCharacterPrefix()
|
|
1934
|
+
{
|
|
1935
|
+
Dictionary<string, int> dict = new()
|
|
1936
|
+
{
|
|
1937
|
+
{ "apple", 1 },
|
|
1938
|
+
{ "application", 2 },
|
|
1939
|
+
{ "banana", 3 },
|
|
1940
|
+
{ "apply", 4 },
|
|
1941
|
+
};
|
|
1942
|
+
Trie<int> trie = new(dict);
|
|
1943
|
+
List<int> results = new();
|
|
1944
|
+
int count = trie.GetValuesWithPrefix("a", results).Count;
|
|
1945
|
+
|
|
1946
|
+
Assert.AreEqual(3, count);
|
|
1947
|
+
CollectionAssert.AreEquivalent(new[] { 1, 2, 4 }, results);
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
[Test]
|
|
1951
|
+
public void GetValuesWithPrefixHandlesDeepNesting()
|
|
1952
|
+
{
|
|
1953
|
+
Dictionary<string, int> dict = new()
|
|
1954
|
+
{
|
|
1955
|
+
{ "a", 1 },
|
|
1956
|
+
{ "ab", 2 },
|
|
1957
|
+
{ "abc", 3 },
|
|
1958
|
+
{ "abcd", 4 },
|
|
1959
|
+
{ "abcde", 5 },
|
|
1960
|
+
{ "abcdef", 6 },
|
|
1961
|
+
};
|
|
1962
|
+
Trie<int> trie = new(dict);
|
|
1963
|
+
List<int> results = new();
|
|
1964
|
+
|
|
1965
|
+
trie.GetValuesWithPrefix("abc", results);
|
|
1966
|
+
Assert.AreEqual(4, results.Count);
|
|
1967
|
+
CollectionAssert.AreEquivalent(new[] { 3, 4, 5, 6 }, results);
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
[Test]
|
|
1971
|
+
public void TryGetValueHandlesRepeatingCharacters()
|
|
1972
|
+
{
|
|
1973
|
+
Dictionary<string, int> dict = new()
|
|
1974
|
+
{
|
|
1975
|
+
{ "aaa", 1 },
|
|
1976
|
+
{ "aaaa", 2 },
|
|
1977
|
+
{ "aaaaa", 3 },
|
|
1978
|
+
};
|
|
1979
|
+
Trie<int> trie = new(dict);
|
|
1980
|
+
|
|
1981
|
+
Assert.IsTrue(trie.TryGetValue("aaa", out int value1));
|
|
1982
|
+
Assert.AreEqual(1, value1);
|
|
1983
|
+
Assert.IsTrue(trie.TryGetValue("aaaa", out int value2));
|
|
1984
|
+
Assert.AreEqual(2, value2);
|
|
1985
|
+
Assert.IsTrue(trie.TryGetValue("aaaaa", out int value3));
|
|
1986
|
+
Assert.AreEqual(3, value3);
|
|
1987
|
+
Assert.IsFalse(trie.TryGetValue("aa", out _));
|
|
1988
|
+
Assert.IsFalse(trie.TryGetValue("aaaaaa", out _));
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
[Test]
|
|
1992
|
+
public void GenericTrieHandlesAllSameCharacterKeys()
|
|
1993
|
+
{
|
|
1994
|
+
Dictionary<string, int> dict = new()
|
|
1995
|
+
{
|
|
1996
|
+
{ "a", 1 },
|
|
1997
|
+
{ "aa", 2 },
|
|
1998
|
+
{ "aaa", 3 },
|
|
1999
|
+
{ "aaaa", 4 },
|
|
2000
|
+
};
|
|
2001
|
+
Trie<int> trie = new(dict);
|
|
2002
|
+
|
|
2003
|
+
foreach (KeyValuePair<string, int> kvp in dict)
|
|
2004
|
+
{
|
|
2005
|
+
Assert.IsTrue(trie.TryGetValue(kvp.Key, out int value));
|
|
2006
|
+
Assert.AreEqual(kvp.Value, value);
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
List<int> results = new();
|
|
2010
|
+
trie.GetValuesWithPrefix("aa", results);
|
|
2011
|
+
Assert.AreEqual(3, results.Count);
|
|
2012
|
+
CollectionAssert.AreEquivalent(new[] { 2, 3, 4 }, results);
|
|
2013
|
+
}
|
|
2014
|
+
|
|
2015
|
+
[Test]
|
|
2016
|
+
public void GetValuesWithPrefixWhenPrefixIsNotAKey()
|
|
2017
|
+
{
|
|
2018
|
+
Dictionary<string, int> dict = new() { { "testing", 1 }, { "tester", 2 } };
|
|
2019
|
+
Trie<int> trie = new(dict);
|
|
2020
|
+
List<int> results = new();
|
|
2021
|
+
int count = trie.GetValuesWithPrefix("test", results).Count;
|
|
2022
|
+
|
|
2023
|
+
Assert.AreEqual(2, count);
|
|
2024
|
+
Assert.IsFalse(trie.TryGetValue("test", out _));
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
[Test]
|
|
2028
|
+
public void GenericTrieHandlesWhitespaceInKeys()
|
|
2029
|
+
{
|
|
2030
|
+
Dictionary<string, int> dict = new()
|
|
2031
|
+
{
|
|
2032
|
+
{ "hello world", 1 },
|
|
2033
|
+
{ "hello world", 2 },
|
|
2034
|
+
{ "hello\tworld", 3 },
|
|
2035
|
+
{ "hello\nworld", 4 },
|
|
2036
|
+
};
|
|
2037
|
+
Trie<int> trie = new(dict);
|
|
2038
|
+
|
|
2039
|
+
foreach (KeyValuePair<string, int> kvp in dict)
|
|
2040
|
+
{
|
|
2041
|
+
Assert.IsTrue(trie.TryGetValue(kvp.Key, out int value));
|
|
2042
|
+
Assert.AreEqual(kvp.Value, value);
|
|
2043
|
+
}
|
|
2044
|
+
|
|
2045
|
+
Assert.IsFalse(trie.TryGetValue("hello", out _));
|
|
2046
|
+
Assert.IsFalse(trie.TryGetValue("world", out _));
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
[Test]
|
|
2050
|
+
public void GenericTrieHandlesNumericKeys()
|
|
2051
|
+
{
|
|
2052
|
+
Dictionary<string, string> dict = new()
|
|
2053
|
+
{
|
|
2054
|
+
{ "123", "a" },
|
|
2055
|
+
{ "1234", "b" },
|
|
2056
|
+
{ "12345", "c" },
|
|
2057
|
+
{ "234", "d" },
|
|
2058
|
+
{ "345", "e" },
|
|
2059
|
+
};
|
|
2060
|
+
Trie<string> trie = new(dict);
|
|
2061
|
+
|
|
2062
|
+
foreach (KeyValuePair<string, string> kvp in dict)
|
|
2063
|
+
{
|
|
2064
|
+
Assert.IsTrue(trie.TryGetValue(kvp.Key, out string value));
|
|
2065
|
+
Assert.AreEqual(kvp.Value, value);
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
List<string> results = new();
|
|
2069
|
+
trie.GetValuesWithPrefix("123", results);
|
|
2070
|
+
Assert.AreEqual(3, results.Count);
|
|
2071
|
+
CollectionAssert.AreEquivalent(new[] { "a", "b", "c" }, results);
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
[Test]
|
|
2075
|
+
public void GetValuesWithPrefixReturnsCorrectCountWhenMaxResultsExceedsAvailable()
|
|
2076
|
+
{
|
|
2077
|
+
Dictionary<string, int> dict = new() { { "apple", 1 }, { "application", 2 } };
|
|
2078
|
+
Trie<int> trie = new(dict);
|
|
2079
|
+
List<int> results = new();
|
|
2080
|
+
int count = trie.GetValuesWithPrefix("app", results, maxResults: 100).Count;
|
|
2081
|
+
|
|
2082
|
+
Assert.AreEqual(2, count);
|
|
2083
|
+
Assert.AreEqual(2, results.Count);
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
[Test]
|
|
2087
|
+
public void TryGetValueMultipleCallsAreIndependent()
|
|
2088
|
+
{
|
|
2089
|
+
Dictionary<string, int> dict = new() { { "test", 1 }, { "testing", 2 } };
|
|
2090
|
+
Trie<int> trie = new(dict);
|
|
2091
|
+
|
|
2092
|
+
Assert.IsTrue(trie.TryGetValue("test", out int value1));
|
|
2093
|
+
Assert.AreEqual(1, value1);
|
|
2094
|
+
Assert.IsTrue(trie.TryGetValue("testing", out int value2));
|
|
2095
|
+
Assert.AreEqual(2, value2);
|
|
2096
|
+
Assert.IsFalse(trie.TryGetValue("tested", out _));
|
|
2097
|
+
Assert.IsTrue(trie.TryGetValue("test", out int value3));
|
|
2098
|
+
Assert.AreEqual(1, value3);
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
[Test]
|
|
2102
|
+
public void GetValuesWithPrefixMultipleCallsAreIndependent()
|
|
2103
|
+
{
|
|
2104
|
+
Dictionary<string, int> dict = new()
|
|
2105
|
+
{
|
|
2106
|
+
{ "apple", 1 },
|
|
2107
|
+
{ "application", 2 },
|
|
2108
|
+
{ "apply", 3 },
|
|
2109
|
+
{ "banana", 4 },
|
|
2110
|
+
};
|
|
2111
|
+
Trie<int> trie = new(dict);
|
|
2112
|
+
List<int> results = new();
|
|
2113
|
+
|
|
2114
|
+
trie.GetValuesWithPrefix("app", results);
|
|
2115
|
+
Assert.AreEqual(3, results.Count);
|
|
2116
|
+
|
|
2117
|
+
trie.GetValuesWithPrefix("ban", results);
|
|
2118
|
+
Assert.AreEqual(1, results.Count);
|
|
2119
|
+
Assert.AreEqual(4, results[0]);
|
|
2120
|
+
|
|
2121
|
+
trie.GetValuesWithPrefix("app", results);
|
|
2122
|
+
Assert.AreEqual(3, results.Count);
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
[Test]
|
|
2126
|
+
public void GenericTrieHandlesKeysWithOnlySpecialCharacters()
|
|
2127
|
+
{
|
|
2128
|
+
Dictionary<string, int> dict = new()
|
|
2129
|
+
{
|
|
2130
|
+
{ "!!!", 1 },
|
|
2131
|
+
{ "@@@", 2 },
|
|
2132
|
+
{ "###", 3 },
|
|
2133
|
+
{ "$$$", 4 },
|
|
2134
|
+
};
|
|
2135
|
+
Trie<int> trie = new(dict);
|
|
2136
|
+
|
|
2137
|
+
foreach (KeyValuePair<string, int> kvp in dict)
|
|
2138
|
+
{
|
|
2139
|
+
Assert.IsTrue(trie.TryGetValue(kvp.Key, out int value));
|
|
2140
|
+
Assert.AreEqual(kvp.Value, value);
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
[Test]
|
|
2145
|
+
public void GetValuesWithPrefixWithSpecialCharacterPrefix()
|
|
2146
|
+
{
|
|
2147
|
+
Dictionary<string, int> dict = new()
|
|
2148
|
+
{
|
|
2149
|
+
{ "!test", 1 },
|
|
2150
|
+
{ "!testing", 2 },
|
|
2151
|
+
{ "!tester", 3 },
|
|
2152
|
+
{ "#test", 4 },
|
|
2153
|
+
};
|
|
2154
|
+
Trie<int> trie = new(dict);
|
|
2155
|
+
List<int> results = new();
|
|
2156
|
+
int count = trie.GetValuesWithPrefix("!", results).Count;
|
|
2157
|
+
|
|
2158
|
+
Assert.AreEqual(3, count);
|
|
2159
|
+
CollectionAssert.AreEquivalent(new[] { 1, 2, 3 }, results);
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
[Test]
|
|
2163
|
+
public void GenericTrieHandlesEmojiKeys()
|
|
2164
|
+
{
|
|
2165
|
+
Dictionary<string, string> dict = new()
|
|
2166
|
+
{
|
|
2167
|
+
{ "😀", "happy" },
|
|
2168
|
+
{ "😀😀", "very happy" },
|
|
2169
|
+
{ "😁", "grin" },
|
|
2170
|
+
{ "test😀", "test happy" },
|
|
2171
|
+
};
|
|
2172
|
+
Trie<string> trie = new(dict);
|
|
2173
|
+
|
|
2174
|
+
foreach (KeyValuePair<string, string> kvp in dict)
|
|
2175
|
+
{
|
|
2176
|
+
Assert.IsTrue(trie.TryGetValue(kvp.Key, out string value));
|
|
2177
|
+
Assert.AreEqual(kvp.Value, value);
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
|
|
2181
|
+
[Test]
|
|
2182
|
+
public void GetValuesWithPrefixHandlesLargeMaxResults()
|
|
2183
|
+
{
|
|
2184
|
+
Dictionary<string, int> dict = new() { { "apple", 1 }, { "application", 2 } };
|
|
2185
|
+
Trie<int> trie = new(dict);
|
|
2186
|
+
List<int> results = new();
|
|
2187
|
+
int count = trie.GetValuesWithPrefix("app", results, maxResults: int.MaxValue).Count;
|
|
2188
|
+
|
|
2189
|
+
Assert.AreEqual(2, count);
|
|
2190
|
+
Assert.AreEqual(2, results.Count);
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
[Test]
|
|
2194
|
+
public void GenericTrieHandlesKeysStartingWithSameCharacterButDifferentSecondChar()
|
|
2195
|
+
{
|
|
2196
|
+
Dictionary<string, int> dict = new()
|
|
2197
|
+
{
|
|
2198
|
+
{ "aa", 1 },
|
|
2199
|
+
{ "ab", 2 },
|
|
2200
|
+
{ "ac", 3 },
|
|
2201
|
+
{ "ad", 4 },
|
|
2202
|
+
{ "ae", 5 },
|
|
2203
|
+
};
|
|
2204
|
+
Trie<int> trie = new(dict);
|
|
2205
|
+
|
|
2206
|
+
foreach (KeyValuePair<string, int> kvp in dict)
|
|
2207
|
+
{
|
|
2208
|
+
Assert.IsTrue(trie.TryGetValue(kvp.Key, out int value));
|
|
2209
|
+
Assert.AreEqual(kvp.Value, value);
|
|
2210
|
+
}
|
|
2211
|
+
|
|
2212
|
+
List<int> results = new();
|
|
2213
|
+
trie.GetValuesWithPrefix("a", results);
|
|
2214
|
+
Assert.AreEqual(5, results.Count);
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
[Test]
|
|
2218
|
+
public void TryGetValueAfterConstructingWithEmptyDictionary()
|
|
2219
|
+
{
|
|
2220
|
+
Trie<int> trie = new(new Dictionary<string, int>());
|
|
2221
|
+
Assert.IsFalse(trie.TryGetValue("anything", out _));
|
|
2222
|
+
Assert.IsFalse(trie.TryGetValue("", out _));
|
|
2223
|
+
Assert.IsFalse(trie.TryGetValue("a", out _));
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
[Test]
|
|
2227
|
+
public void GetValuesWithPrefixOnEmptyTrie()
|
|
2228
|
+
{
|
|
2229
|
+
Trie<int> trie = new(new Dictionary<string, int>());
|
|
2230
|
+
List<int> results = new();
|
|
2231
|
+
int count = trie.GetValuesWithPrefix("test", results).Count;
|
|
2232
|
+
|
|
2233
|
+
Assert.AreEqual(0, count);
|
|
2234
|
+
Assert.AreEqual(0, results.Count);
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
[Test]
|
|
2238
|
+
public void GetValuesWithPrefixEmptyPrefixOnEmptyTrie()
|
|
2239
|
+
{
|
|
2240
|
+
Trie<int> trie = new(new Dictionary<string, int>());
|
|
2241
|
+
List<int> results = new();
|
|
2242
|
+
int count = trie.GetValuesWithPrefix("", results).Count;
|
|
2243
|
+
|
|
2244
|
+
Assert.AreEqual(0, count);
|
|
2245
|
+
Assert.AreEqual(0, results.Count);
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
[Test]
|
|
2249
|
+
public void GenericTrieHandlesOnlyEmptyStringKey()
|
|
2250
|
+
{
|
|
2251
|
+
Dictionary<string, int> dict = new() { { "", 42 } };
|
|
2252
|
+
Trie<int> trie = new(dict);
|
|
2253
|
+
|
|
2254
|
+
Assert.IsTrue(trie.TryGetValue("", out int value));
|
|
2255
|
+
Assert.AreEqual(42, value);
|
|
2256
|
+
Assert.IsFalse(trie.TryGetValue("a", out _));
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
[Test]
|
|
2260
|
+
public void GetValuesWithPrefixReturnsEmptyStringValueWhenPresent()
|
|
2261
|
+
{
|
|
2262
|
+
Dictionary<string, int> dict = new() { { "", 0 }, { "test", 42 } };
|
|
2263
|
+
Trie<int> trie = new(dict);
|
|
2264
|
+
List<int> results = new();
|
|
2265
|
+
trie.GetValuesWithPrefix("", results);
|
|
2266
|
+
|
|
2267
|
+
Assert.AreEqual(2, results.Count);
|
|
2268
|
+
CollectionAssert.Contains(results, 0);
|
|
2269
|
+
CollectionAssert.Contains(results, 42);
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
[Test]
|
|
2273
|
+
public void TryGetValueDistinguishesBetweenSimilarKeys()
|
|
2274
|
+
{
|
|
2275
|
+
Dictionary<string, int> dict = new()
|
|
2276
|
+
{
|
|
2277
|
+
{ "car", 1 },
|
|
2278
|
+
{ "cart", 2 },
|
|
2279
|
+
{ "card", 3 },
|
|
2280
|
+
{ "care", 4 },
|
|
2281
|
+
};
|
|
2282
|
+
Trie<int> trie = new(dict);
|
|
2283
|
+
|
|
2284
|
+
Assert.IsTrue(trie.TryGetValue("car", out int value1));
|
|
2285
|
+
Assert.AreEqual(1, value1);
|
|
2286
|
+
Assert.IsTrue(trie.TryGetValue("cart", out int value2));
|
|
2287
|
+
Assert.AreEqual(2, value2);
|
|
2288
|
+
Assert.IsTrue(trie.TryGetValue("card", out int value3));
|
|
2289
|
+
Assert.AreEqual(3, value3);
|
|
2290
|
+
Assert.IsTrue(trie.TryGetValue("care", out int value4));
|
|
2291
|
+
Assert.AreEqual(4, value4);
|
|
2292
|
+
Assert.IsFalse(trie.TryGetValue("ca", out _));
|
|
2293
|
+
Assert.IsFalse(trie.TryGetValue("cars", out _));
|
|
2294
|
+
Assert.IsFalse(trie.TryGetValue("carts", out _));
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
[Test]
|
|
2298
|
+
public void GenericTrieHandlesControlCharactersInKeys()
|
|
2299
|
+
{
|
|
2300
|
+
Dictionary<string, int> dict = new()
|
|
2301
|
+
{
|
|
2302
|
+
{ "test\r\nline", 1 },
|
|
2303
|
+
{ "test\r", 2 },
|
|
2304
|
+
{ "test\n", 3 },
|
|
2305
|
+
{ "test\t", 4 },
|
|
2306
|
+
};
|
|
2307
|
+
Trie<int> trie = new(dict);
|
|
2308
|
+
|
|
2309
|
+
foreach (KeyValuePair<string, int> kvp in dict)
|
|
2310
|
+
{
|
|
2311
|
+
Assert.IsTrue(trie.TryGetValue(kvp.Key, out int value));
|
|
2312
|
+
Assert.AreEqual(kvp.Value, value);
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
|
|
2316
|
+
[Test]
|
|
2317
|
+
public void GetValuesWithPrefixStopsAtMaxResultsInMiddleOfTraversal()
|
|
2318
|
+
{
|
|
2319
|
+
Dictionary<string, int> dict = new()
|
|
2320
|
+
{
|
|
2321
|
+
{ "a", 1 },
|
|
2322
|
+
{ "aa", 2 },
|
|
2323
|
+
{ "aaa", 3 },
|
|
2324
|
+
{ "aaaa", 4 },
|
|
2325
|
+
{ "aaaaa", 5 },
|
|
2326
|
+
{ "aaaaaa", 6 },
|
|
2327
|
+
};
|
|
2328
|
+
Trie<int> trie = new(dict);
|
|
2329
|
+
List<int> results = new();
|
|
2330
|
+
int count = trie.GetValuesWithPrefix("a", results, maxResults: 3).Count;
|
|
2331
|
+
|
|
2332
|
+
Assert.AreEqual(3, count);
|
|
2333
|
+
Assert.AreEqual(3, results.Count);
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
[Test]
|
|
2337
|
+
public void GenericTrieHandlesKeysWithLeadingAndTrailingSpaces()
|
|
2338
|
+
{
|
|
2339
|
+
Dictionary<string, int> dict = new()
|
|
2340
|
+
{
|
|
2341
|
+
{ " test", 1 },
|
|
2342
|
+
{ "test ", 2 },
|
|
2343
|
+
{ " test ", 3 },
|
|
2344
|
+
};
|
|
2345
|
+
Trie<int> trie = new(dict);
|
|
2346
|
+
|
|
2347
|
+
Assert.IsTrue(trie.TryGetValue(" test", out int value1));
|
|
2348
|
+
Assert.AreEqual(1, value1);
|
|
2349
|
+
Assert.IsTrue(trie.TryGetValue("test ", out int value2));
|
|
2350
|
+
Assert.AreEqual(2, value2);
|
|
2351
|
+
Assert.IsTrue(trie.TryGetValue(" test ", out int value3));
|
|
2352
|
+
Assert.AreEqual(3, value3);
|
|
2353
|
+
Assert.IsFalse(trie.TryGetValue("test", out _));
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
[Test]
|
|
2357
|
+
public void GetValuesWithPrefixWithPrefixMatchingCompleteKey()
|
|
2358
|
+
{
|
|
2359
|
+
Dictionary<string, int> dict = new() { { "test", 42 } };
|
|
2360
|
+
Trie<int> trie = new(dict);
|
|
2361
|
+
List<int> results = new();
|
|
2362
|
+
int count = trie.GetValuesWithPrefix("test", results).Count;
|
|
2363
|
+
|
|
2364
|
+
Assert.AreEqual(1, count);
|
|
2365
|
+
Assert.AreEqual(42, results[0]);
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
[Test]
|
|
2369
|
+
public void GenericTrieHandlesIdenticalKeysInDifferentCase()
|
|
2370
|
+
{
|
|
2371
|
+
Dictionary<string, int> dict = new()
|
|
2372
|
+
{
|
|
2373
|
+
{ "test", 1 },
|
|
2374
|
+
{ "Test", 2 },
|
|
2375
|
+
{ "TEST", 3 },
|
|
2376
|
+
{ "TeSt", 4 },
|
|
2377
|
+
};
|
|
2378
|
+
Trie<int> trie = new(dict);
|
|
2379
|
+
|
|
2380
|
+
foreach (KeyValuePair<string, int> kvp in dict)
|
|
2381
|
+
{
|
|
2382
|
+
Assert.IsTrue(trie.TryGetValue(kvp.Key, out int value));
|
|
2383
|
+
Assert.AreEqual(kvp.Value, value);
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
List<int> results = new();
|
|
2387
|
+
trie.GetValuesWithPrefix("T", results);
|
|
2388
|
+
Assert.AreEqual(3, results.Count);
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2391
|
+
[Test]
|
|
2392
|
+
public void GenericTrieHandlesDefaultValues()
|
|
2393
|
+
{
|
|
2394
|
+
Dictionary<string, int> dict = new() { { "zero", 0 }, { "one", 1 } };
|
|
2395
|
+
Trie<int> trie = new(dict);
|
|
2396
|
+
|
|
2397
|
+
Assert.IsTrue(trie.TryGetValue("zero", out int value));
|
|
2398
|
+
Assert.AreEqual(0, value);
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
[Test]
|
|
2402
|
+
public void GenericTrieHandlesStructValues()
|
|
2403
|
+
{
|
|
2404
|
+
Dictionary<string, DateTime> dict = new()
|
|
2405
|
+
{
|
|
2406
|
+
{ "date1", new DateTime(2024, 1, 1) },
|
|
2407
|
+
{ "date2", new DateTime(2024, 12, 31) },
|
|
2408
|
+
};
|
|
2409
|
+
Trie<DateTime> trie = new(dict);
|
|
2410
|
+
|
|
2411
|
+
Assert.IsTrue(trie.TryGetValue("date1", out DateTime value1));
|
|
2412
|
+
Assert.AreEqual(new DateTime(2024, 1, 1), value1);
|
|
2413
|
+
Assert.IsTrue(trie.TryGetValue("date2", out DateTime value2));
|
|
2414
|
+
Assert.AreEqual(new DateTime(2024, 12, 31), value2);
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
[Test]
|
|
2418
|
+
public void GetValuesWithPrefixLongPrefixThatDoesNotExist()
|
|
2419
|
+
{
|
|
2420
|
+
Dictionary<string, int> dict = new() { { "test", 42 } };
|
|
2421
|
+
Trie<int> trie = new(dict);
|
|
2422
|
+
List<int> results = new();
|
|
2423
|
+
int count = trie.GetValuesWithPrefix("testingextra", results).Count;
|
|
2424
|
+
|
|
2425
|
+
Assert.AreEqual(0, count);
|
|
2426
|
+
Assert.AreEqual(0, results.Count);
|
|
2427
|
+
}
|
|
2428
|
+
|
|
2429
|
+
[Test]
|
|
2430
|
+
public void GenericTriePreservesInsertionValueForDuplicateKeys()
|
|
2431
|
+
{
|
|
2432
|
+
Dictionary<string, int> dict = new() { { "test", 42 } };
|
|
2433
|
+
Trie<int> trie = new(dict);
|
|
2434
|
+
|
|
2435
|
+
Assert.IsTrue(trie.TryGetValue("test", out int value));
|
|
2436
|
+
Assert.AreEqual(42, value);
|
|
2437
|
+
|
|
2438
|
+
List<int> results = new();
|
|
2439
|
+
trie.GetValuesWithPrefix("test", results);
|
|
2440
|
+
Assert.AreEqual(1, results.Count);
|
|
2441
|
+
Assert.AreEqual(42, results[0]);
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
[Test]
|
|
2445
|
+
public void GenericEnumeratorIteratesAllValues()
|
|
2446
|
+
{
|
|
2447
|
+
Dictionary<string, int> dict = new()
|
|
2448
|
+
{
|
|
2449
|
+
{ "apple", 1 },
|
|
2450
|
+
{ "banana", 2 },
|
|
2451
|
+
{ "cherry", 3 },
|
|
2452
|
+
};
|
|
2453
|
+
Trie<int> trie = new(dict);
|
|
2454
|
+
|
|
2455
|
+
List<int> enumerated = new();
|
|
2456
|
+
foreach (int value in trie)
|
|
2457
|
+
{
|
|
2458
|
+
enumerated.Add(value);
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
Assert.AreEqual(3, enumerated.Count);
|
|
2462
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
[Test]
|
|
2466
|
+
public void GenericEnumeratorWorksWithEmptyTrie()
|
|
2467
|
+
{
|
|
2468
|
+
Trie<string> trie = new(new Dictionary<string, string>());
|
|
2469
|
+
|
|
2470
|
+
int count = 0;
|
|
2471
|
+
foreach (string value in trie)
|
|
2472
|
+
{
|
|
2473
|
+
count++;
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
Assert.AreEqual(0, count);
|
|
2477
|
+
}
|
|
2478
|
+
|
|
2479
|
+
[Test]
|
|
2480
|
+
public void GenericEnumeratorHandlesSingleValue()
|
|
2481
|
+
{
|
|
2482
|
+
Dictionary<string, string> dict = new() { { "test", "value" } };
|
|
2483
|
+
Trie<string> trie = new(dict);
|
|
2484
|
+
|
|
2485
|
+
List<string> enumerated = new();
|
|
2486
|
+
foreach (string value in trie)
|
|
2487
|
+
{
|
|
2488
|
+
enumerated.Add(value);
|
|
2489
|
+
}
|
|
2490
|
+
|
|
2491
|
+
Assert.AreEqual(1, enumerated.Count);
|
|
2492
|
+
Assert.AreEqual("value", enumerated[0]);
|
|
2493
|
+
}
|
|
2494
|
+
|
|
2495
|
+
[Test]
|
|
2496
|
+
public void GenericEnumeratorHandlesKeysWithCommonPrefixes()
|
|
2497
|
+
{
|
|
2498
|
+
Dictionary<string, int> dict = new()
|
|
2499
|
+
{
|
|
2500
|
+
{ "test", 1 },
|
|
2501
|
+
{ "testing", 2 },
|
|
2502
|
+
{ "tester", 3 },
|
|
2503
|
+
{ "tea", 4 },
|
|
2504
|
+
};
|
|
2505
|
+
Trie<int> trie = new(dict);
|
|
2506
|
+
|
|
2507
|
+
List<int> enumerated = new();
|
|
2508
|
+
foreach (int value in trie)
|
|
2509
|
+
{
|
|
2510
|
+
enumerated.Add(value);
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2513
|
+
Assert.AreEqual(4, enumerated.Count);
|
|
2514
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
[Test]
|
|
2518
|
+
public void GenericEnumeratorCanBeUsedMultipleTimes()
|
|
2519
|
+
{
|
|
2520
|
+
Dictionary<string, int> dict = new()
|
|
2521
|
+
{
|
|
2522
|
+
{ "apple", 1 },
|
|
2523
|
+
{ "banana", 2 },
|
|
2524
|
+
{ "cherry", 3 },
|
|
2525
|
+
};
|
|
2526
|
+
Trie<int> trie = new(dict);
|
|
2527
|
+
|
|
2528
|
+
List<int> firstEnumeration = new();
|
|
2529
|
+
foreach (int value in trie)
|
|
2530
|
+
{
|
|
2531
|
+
firstEnumeration.Add(value);
|
|
2532
|
+
}
|
|
2533
|
+
|
|
2534
|
+
List<int> secondEnumeration = new();
|
|
2535
|
+
foreach (int value in trie)
|
|
2536
|
+
{
|
|
2537
|
+
secondEnumeration.Add(value);
|
|
2538
|
+
}
|
|
2539
|
+
|
|
2540
|
+
Assert.AreEqual(3, firstEnumeration.Count);
|
|
2541
|
+
Assert.AreEqual(3, secondEnumeration.Count);
|
|
2542
|
+
CollectionAssert.AreEquivalent(firstEnumeration, secondEnumeration);
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
[Test]
|
|
2546
|
+
public void GenericEnumeratorHandlesComplexTypes()
|
|
2547
|
+
{
|
|
2548
|
+
Dictionary<string, (int, string)> dict = new()
|
|
2549
|
+
{
|
|
2550
|
+
{ "one", (1, "first") },
|
|
2551
|
+
{ "two", (2, "second") },
|
|
2552
|
+
{ "three", (3, "third") },
|
|
2553
|
+
};
|
|
2554
|
+
Trie<(int, string)> trie = new(dict);
|
|
2555
|
+
|
|
2556
|
+
List<(int, string)> enumerated = new();
|
|
2557
|
+
foreach ((int, string) value in trie)
|
|
2558
|
+
{
|
|
2559
|
+
enumerated.Add(value);
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
Assert.AreEqual(3, enumerated.Count);
|
|
2563
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2566
|
+
[Test]
|
|
2567
|
+
public void GenericEnumeratorHandlesNullValues()
|
|
2568
|
+
{
|
|
2569
|
+
Dictionary<string, string> dict = new() { { "null", null }, { "notNull", "value" } };
|
|
2570
|
+
Trie<string> trie = new(dict);
|
|
2571
|
+
|
|
2572
|
+
List<string> enumerated = new();
|
|
2573
|
+
foreach (string value in trie)
|
|
2574
|
+
{
|
|
2575
|
+
enumerated.Add(value);
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
Assert.AreEqual(2, enumerated.Count);
|
|
2579
|
+
Assert.IsTrue(enumerated.Contains(null));
|
|
2580
|
+
Assert.IsTrue(enumerated.Contains("value"));
|
|
2581
|
+
}
|
|
2582
|
+
|
|
2583
|
+
[Test]
|
|
2584
|
+
public void GenericEnumeratorHandlesReferenceTypes()
|
|
2585
|
+
{
|
|
2586
|
+
List<string> list1 = new() { "a", "b" };
|
|
2587
|
+
List<string> list2 = new() { "c", "d" };
|
|
2588
|
+
Dictionary<string, List<string>> dict = new() { { "key1", list1 }, { "key2", list2 } };
|
|
2589
|
+
Trie<List<string>> trie = new(dict);
|
|
2590
|
+
|
|
2591
|
+
List<List<string>> enumerated = new();
|
|
2592
|
+
foreach (List<string> value in trie)
|
|
2593
|
+
{
|
|
2594
|
+
enumerated.Add(value);
|
|
2595
|
+
}
|
|
2596
|
+
|
|
2597
|
+
Assert.AreEqual(2, enumerated.Count);
|
|
2598
|
+
Assert.IsTrue(enumerated.Contains(list1));
|
|
2599
|
+
Assert.IsTrue(enumerated.Contains(list2));
|
|
2600
|
+
}
|
|
2601
|
+
|
|
2602
|
+
[Test]
|
|
2603
|
+
public void GenericEnumeratorUsesValueTypeForEfficiency()
|
|
2604
|
+
{
|
|
2605
|
+
Dictionary<string, int> dict = new() { { "test", 42 } };
|
|
2606
|
+
Trie<int> trie = new(dict);
|
|
2607
|
+
|
|
2608
|
+
// Get the enumerator directly to verify it's a value type
|
|
2609
|
+
Trie<int>.Enumerator enumerator = trie.GetEnumerator();
|
|
2610
|
+
Assert.IsTrue(enumerator.GetType().IsValueType);
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2613
|
+
[Test]
|
|
2614
|
+
public void GenericEnumeratorCanBreakEarly()
|
|
2615
|
+
{
|
|
2616
|
+
Dictionary<string, int> dict = new()
|
|
2617
|
+
{
|
|
2618
|
+
{ "a", 1 },
|
|
2619
|
+
{ "b", 2 },
|
|
2620
|
+
{ "c", 3 },
|
|
2621
|
+
{ "d", 4 },
|
|
2622
|
+
{ "e", 5 },
|
|
2623
|
+
};
|
|
2624
|
+
Trie<int> trie = new(dict);
|
|
2625
|
+
|
|
2626
|
+
int count = 0;
|
|
2627
|
+
foreach (int value in trie)
|
|
2628
|
+
{
|
|
2629
|
+
count++;
|
|
2630
|
+
if (count == 3)
|
|
2631
|
+
{
|
|
2632
|
+
break;
|
|
2633
|
+
}
|
|
2634
|
+
}
|
|
2635
|
+
|
|
2636
|
+
Assert.AreEqual(3, count);
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
[Test]
|
|
2640
|
+
public void GenericEnumeratorWorksWithLinq()
|
|
2641
|
+
{
|
|
2642
|
+
Dictionary<string, int> dict = new()
|
|
2643
|
+
{
|
|
2644
|
+
{ "apple", 10 },
|
|
2645
|
+
{ "banana", 20 },
|
|
2646
|
+
{ "cherry", 30 },
|
|
2647
|
+
{ "date", 40 },
|
|
2648
|
+
};
|
|
2649
|
+
Trie<int> trie = new(dict);
|
|
2650
|
+
|
|
2651
|
+
List<int> filtered = trie.Where(v => v > 15).ToList();
|
|
2652
|
+
|
|
2653
|
+
Assert.AreEqual(3, filtered.Count);
|
|
2654
|
+
Assert.IsTrue(filtered.Contains(20));
|
|
2655
|
+
Assert.IsTrue(filtered.Contains(30));
|
|
2656
|
+
Assert.IsTrue(filtered.Contains(40));
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2659
|
+
[Test]
|
|
2660
|
+
public void GenericEnumeratorHandlesDefaultValues()
|
|
2661
|
+
{
|
|
2662
|
+
Dictionary<string, int> dict = new()
|
|
2663
|
+
{
|
|
2664
|
+
{ "zero", 0 },
|
|
2665
|
+
{ "one", 1 },
|
|
2666
|
+
{ "minusOne", -1 },
|
|
2667
|
+
};
|
|
2668
|
+
Trie<int> trie = new(dict);
|
|
2669
|
+
|
|
2670
|
+
List<int> enumerated = new();
|
|
2671
|
+
foreach (int value in trie)
|
|
2672
|
+
{
|
|
2673
|
+
enumerated.Add(value);
|
|
2674
|
+
}
|
|
2675
|
+
|
|
2676
|
+
Assert.AreEqual(3, enumerated.Count);
|
|
2677
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2680
|
+
[Test]
|
|
2681
|
+
public void GenericEnumeratorHandlesStructValues()
|
|
2682
|
+
{
|
|
2683
|
+
Dictionary<string, DateTime> dict = new()
|
|
2684
|
+
{
|
|
2685
|
+
{ "date1", new DateTime(2024, 1, 1) },
|
|
2686
|
+
{ "date2", new DateTime(2024, 6, 15) },
|
|
2687
|
+
{ "date3", new DateTime(2024, 12, 31) },
|
|
2688
|
+
};
|
|
2689
|
+
Trie<DateTime> trie = new(dict);
|
|
2690
|
+
|
|
2691
|
+
List<DateTime> enumerated = new();
|
|
2692
|
+
foreach (DateTime value in trie)
|
|
2693
|
+
{
|
|
2694
|
+
enumerated.Add(value);
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2697
|
+
Assert.AreEqual(3, enumerated.Count);
|
|
2698
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
2699
|
+
}
|
|
2700
|
+
|
|
2701
|
+
[Test]
|
|
2702
|
+
public void GenericEnumeratorHandlesManyEntries()
|
|
2703
|
+
{
|
|
2704
|
+
Dictionary<string, int> dict = new();
|
|
2705
|
+
for (int i = 0; i < 1000; i++)
|
|
2706
|
+
{
|
|
2707
|
+
dict[$"key{i}"] = i;
|
|
2708
|
+
}
|
|
2709
|
+
Trie<int> trie = new(dict);
|
|
2710
|
+
|
|
2711
|
+
List<int> enumerated = new();
|
|
2712
|
+
foreach (int value in trie)
|
|
2713
|
+
{
|
|
2714
|
+
enumerated.Add(value);
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
Assert.AreEqual(1000, enumerated.Count);
|
|
2718
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
2719
|
+
}
|
|
2720
|
+
|
|
2721
|
+
[Test]
|
|
2722
|
+
public void GenericEnumeratorHandlesUnicodeKeys()
|
|
2723
|
+
{
|
|
2724
|
+
Dictionary<string, int> dict = new()
|
|
2725
|
+
{
|
|
2726
|
+
{ "café", 1 },
|
|
2727
|
+
{ "naïve", 2 },
|
|
2728
|
+
{ "résumé", 3 },
|
|
2729
|
+
};
|
|
2730
|
+
Trie<int> trie = new(dict);
|
|
2731
|
+
|
|
2732
|
+
List<int> enumerated = new();
|
|
2733
|
+
foreach (int value in trie)
|
|
2734
|
+
{
|
|
2735
|
+
enumerated.Add(value);
|
|
2736
|
+
}
|
|
2737
|
+
|
|
2738
|
+
Assert.AreEqual(3, enumerated.Count);
|
|
2739
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
2740
|
+
}
|
|
2741
|
+
|
|
2742
|
+
[Test]
|
|
2743
|
+
public void GenericEnumeratorHandlesEmptyStringKey()
|
|
2744
|
+
{
|
|
2745
|
+
Dictionary<string, int> dict = new()
|
|
2746
|
+
{
|
|
2747
|
+
{ "", 0 },
|
|
2748
|
+
{ "a", 1 },
|
|
2749
|
+
{ "ab", 2 },
|
|
2750
|
+
};
|
|
2751
|
+
Trie<int> trie = new(dict);
|
|
2752
|
+
|
|
2753
|
+
List<int> enumerated = new();
|
|
2754
|
+
foreach (int value in trie)
|
|
2755
|
+
{
|
|
2756
|
+
enumerated.Add(value);
|
|
2757
|
+
}
|
|
2758
|
+
|
|
2759
|
+
Assert.AreEqual(3, enumerated.Count);
|
|
2760
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2763
|
+
[Test]
|
|
2764
|
+
public void GenericEnumeratorHandlesOnlyEmptyStringKey()
|
|
2765
|
+
{
|
|
2766
|
+
Dictionary<string, int> dict = new() { { "", 42 } };
|
|
2767
|
+
Trie<int> trie = new(dict);
|
|
2768
|
+
|
|
2769
|
+
List<int> enumerated = new();
|
|
2770
|
+
foreach (int value in trie)
|
|
2771
|
+
{
|
|
2772
|
+
enumerated.Add(value);
|
|
2773
|
+
}
|
|
2774
|
+
|
|
2775
|
+
Assert.AreEqual(1, enumerated.Count);
|
|
2776
|
+
Assert.AreEqual(42, enumerated[0]);
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2779
|
+
[Test]
|
|
2780
|
+
public void GenericEnumeratorHandlesKeysAsCompleteSubsets()
|
|
2781
|
+
{
|
|
2782
|
+
Dictionary<string, int> dict = new()
|
|
2783
|
+
{
|
|
2784
|
+
{ "a", 1 },
|
|
2785
|
+
{ "aa", 2 },
|
|
2786
|
+
{ "aaa", 3 },
|
|
2787
|
+
{ "aaaa", 4 },
|
|
2788
|
+
};
|
|
2789
|
+
Trie<int> trie = new(dict);
|
|
2790
|
+
|
|
2791
|
+
List<int> enumerated = new();
|
|
2792
|
+
foreach (int value in trie)
|
|
2793
|
+
{
|
|
2794
|
+
enumerated.Add(value);
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2797
|
+
Assert.AreEqual(4, enumerated.Count);
|
|
2798
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
2799
|
+
}
|
|
2800
|
+
|
|
2801
|
+
[Test]
|
|
2802
|
+
public void GenericMultipleEnumeratorsCanRunSimultaneously()
|
|
2803
|
+
{
|
|
2804
|
+
Dictionary<string, int> dict = new()
|
|
2805
|
+
{
|
|
2806
|
+
{ "apple", 1 },
|
|
2807
|
+
{ "banana", 2 },
|
|
2808
|
+
{ "cherry", 3 },
|
|
2809
|
+
{ "date", 4 },
|
|
2810
|
+
};
|
|
2811
|
+
Trie<int> trie = new(dict);
|
|
2812
|
+
|
|
2813
|
+
Trie<int>.Enumerator enumerator1 = trie.GetEnumerator();
|
|
2814
|
+
Trie<int>.Enumerator enumerator2 = trie.GetEnumerator();
|
|
2815
|
+
|
|
2816
|
+
List<int> list1 = new();
|
|
2817
|
+
List<int> list2 = new();
|
|
2818
|
+
|
|
2819
|
+
// Interleave enumeration
|
|
2820
|
+
Assert.IsTrue(enumerator1.MoveNext());
|
|
2821
|
+
list1.Add(enumerator1.Current);
|
|
2822
|
+
|
|
2823
|
+
Assert.IsTrue(enumerator2.MoveNext());
|
|
2824
|
+
list2.Add(enumerator2.Current);
|
|
2825
|
+
|
|
2826
|
+
Assert.IsTrue(enumerator1.MoveNext());
|
|
2827
|
+
list1.Add(enumerator1.Current);
|
|
2828
|
+
|
|
2829
|
+
while (enumerator1.MoveNext())
|
|
2830
|
+
{
|
|
2831
|
+
list1.Add(enumerator1.Current);
|
|
2832
|
+
}
|
|
2833
|
+
|
|
2834
|
+
while (enumerator2.MoveNext())
|
|
2835
|
+
{
|
|
2836
|
+
list2.Add(enumerator2.Current);
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2839
|
+
Assert.AreEqual(4, list1.Count);
|
|
2840
|
+
Assert.AreEqual(4, list2.Count);
|
|
2841
|
+
CollectionAssert.AreEquivalent(dict.Values, list1);
|
|
2842
|
+
CollectionAssert.AreEquivalent(dict.Values, list2);
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2845
|
+
[Test]
|
|
2846
|
+
public void GenericEnumeratorHandlesNestedPrefixesWithEmptyStringKey()
|
|
2847
|
+
{
|
|
2848
|
+
Dictionary<string, int> dict = new()
|
|
2849
|
+
{
|
|
2850
|
+
{ "", 0 },
|
|
2851
|
+
{ "a", 1 },
|
|
2852
|
+
{ "ab", 2 },
|
|
2853
|
+
{ "abc", 3 },
|
|
2854
|
+
{ "abcd", 4 },
|
|
2855
|
+
};
|
|
2856
|
+
Trie<int> trie = new(dict);
|
|
2857
|
+
|
|
2858
|
+
List<int> enumerated = new();
|
|
2859
|
+
foreach (int value in trie)
|
|
2860
|
+
{
|
|
2861
|
+
enumerated.Add(value);
|
|
2862
|
+
}
|
|
2863
|
+
|
|
2864
|
+
Assert.AreEqual(5, enumerated.Count);
|
|
2865
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
2866
|
+
}
|
|
2867
|
+
|
|
2868
|
+
[Test]
|
|
2869
|
+
public void GenericEnumeratorHandlesDeeplyNestedSingleBranch()
|
|
2870
|
+
{
|
|
2871
|
+
Dictionary<string, int> dict = new();
|
|
2872
|
+
for (int i = 1; i <= 100; i++)
|
|
2873
|
+
{
|
|
2874
|
+
dict[new string('a', i)] = i;
|
|
2875
|
+
}
|
|
2876
|
+
Trie<int> trie = new(dict);
|
|
2877
|
+
|
|
2878
|
+
List<int> enumerated = new();
|
|
2879
|
+
foreach (int value in trie)
|
|
2880
|
+
{
|
|
2881
|
+
enumerated.Add(value);
|
|
2882
|
+
}
|
|
2883
|
+
|
|
2884
|
+
Assert.AreEqual(100, enumerated.Count);
|
|
2885
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
2886
|
+
}
|
|
2887
|
+
|
|
2888
|
+
[Test]
|
|
2889
|
+
public void GenericEnumeratorHandlesWideBranching()
|
|
2890
|
+
{
|
|
2891
|
+
Dictionary<string, int> dict = new();
|
|
2892
|
+
for (char c = 'a'; c <= 'z'; c++)
|
|
2893
|
+
{
|
|
2894
|
+
dict[c.ToString()] = c - 'a';
|
|
2895
|
+
}
|
|
2896
|
+
Trie<int> trie = new(dict);
|
|
2897
|
+
|
|
2898
|
+
List<int> enumerated = new();
|
|
2899
|
+
foreach (int value in trie)
|
|
2900
|
+
{
|
|
2901
|
+
enumerated.Add(value);
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2904
|
+
Assert.AreEqual(26, enumerated.Count);
|
|
2905
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
2906
|
+
}
|
|
2907
|
+
|
|
2908
|
+
[Test]
|
|
2909
|
+
public void GenericEnumeratorWithIEnumerableInterface()
|
|
2910
|
+
{
|
|
2911
|
+
Dictionary<string, int> dict = new()
|
|
2912
|
+
{
|
|
2913
|
+
{ "test1", 1 },
|
|
2914
|
+
{ "test2", 2 },
|
|
2915
|
+
{ "test3", 3 },
|
|
2916
|
+
};
|
|
2917
|
+
Trie<int> trie = new(dict);
|
|
2918
|
+
|
|
2919
|
+
System.Collections.IEnumerable enumerable = trie;
|
|
2920
|
+
List<int> enumerated = new();
|
|
2921
|
+
|
|
2922
|
+
foreach (object value in enumerable)
|
|
2923
|
+
{
|
|
2924
|
+
enumerated.Add((int)value);
|
|
2925
|
+
}
|
|
2926
|
+
|
|
2927
|
+
Assert.AreEqual(3, enumerated.Count);
|
|
2928
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
2929
|
+
}
|
|
2930
|
+
|
|
2931
|
+
[Test]
|
|
2932
|
+
public void GenericEnumeratorHandlesWhitespaceOnlyKeys()
|
|
2933
|
+
{
|
|
2934
|
+
Dictionary<string, int> dict = new()
|
|
2935
|
+
{
|
|
2936
|
+
{ " ", 1 },
|
|
2937
|
+
{ " ", 2 },
|
|
2938
|
+
{ " ", 3 },
|
|
2939
|
+
{ "\t", 4 },
|
|
2940
|
+
{ "\n", 5 },
|
|
2941
|
+
};
|
|
2942
|
+
Trie<int> trie = new(dict);
|
|
2943
|
+
|
|
2944
|
+
List<int> enumerated = new();
|
|
2945
|
+
foreach (int value in trie)
|
|
2946
|
+
{
|
|
2947
|
+
enumerated.Add(value);
|
|
2948
|
+
}
|
|
2949
|
+
|
|
2950
|
+
Assert.AreEqual(5, enumerated.Count);
|
|
2951
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
2952
|
+
}
|
|
2953
|
+
|
|
2954
|
+
[Test]
|
|
2955
|
+
public void GetValuesWithPrefixHandlesMaxResultsZero()
|
|
2956
|
+
{
|
|
2957
|
+
Dictionary<string, int> dict = new()
|
|
2958
|
+
{
|
|
2959
|
+
{ "apple", 1 },
|
|
2960
|
+
{ "application", 2 },
|
|
2961
|
+
{ "apply", 3 },
|
|
2962
|
+
};
|
|
2963
|
+
Trie<int> trie = new(dict);
|
|
2964
|
+
List<int> results = new();
|
|
2965
|
+
int count = trie.GetValuesWithPrefix("app", results, maxResults: 0).Count;
|
|
2966
|
+
|
|
2967
|
+
Assert.AreEqual(0, count);
|
|
2968
|
+
Assert.AreEqual(0, results.Count);
|
|
2969
|
+
}
|
|
2970
|
+
|
|
2971
|
+
[Test]
|
|
2972
|
+
public void GetValuesWithPrefixHandlesMaxResultsNegative()
|
|
2973
|
+
{
|
|
2974
|
+
Dictionary<string, int> dict = new()
|
|
2975
|
+
{
|
|
2976
|
+
{ "apple", 1 },
|
|
2977
|
+
{ "application", 2 },
|
|
2978
|
+
{ "apply", 3 },
|
|
2979
|
+
};
|
|
2980
|
+
Trie<int> trie = new(dict);
|
|
2981
|
+
List<int> results = new();
|
|
2982
|
+
int count = trie.GetValuesWithPrefix("app", results, maxResults: -1).Count;
|
|
2983
|
+
|
|
2984
|
+
Assert.AreEqual(0, count);
|
|
2985
|
+
Assert.AreEqual(0, results.Count);
|
|
2986
|
+
}
|
|
2987
|
+
|
|
2988
|
+
[Test]
|
|
2989
|
+
public void GetValuesWithPrefixIncludesEmptyStringKeyWhenPrefixIsEmpty()
|
|
2990
|
+
{
|
|
2991
|
+
Dictionary<string, int> dict = new()
|
|
2992
|
+
{
|
|
2993
|
+
{ "", 0 },
|
|
2994
|
+
{ "a", 1 },
|
|
2995
|
+
{ "b", 2 },
|
|
2996
|
+
};
|
|
2997
|
+
Trie<int> trie = new(dict);
|
|
2998
|
+
List<int> results = new();
|
|
2999
|
+
trie.GetValuesWithPrefix("", results);
|
|
3000
|
+
|
|
3001
|
+
Assert.AreEqual(3, results.Count);
|
|
3002
|
+
CollectionAssert.AreEquivalent(dict.Values, results);
|
|
3003
|
+
Assert.IsTrue(results.Contains(0));
|
|
3004
|
+
}
|
|
3005
|
+
|
|
3006
|
+
[Test]
|
|
3007
|
+
public void GetValuesWithPrefixWithEmptyStringAsPrefix()
|
|
3008
|
+
{
|
|
3009
|
+
Dictionary<string, int> dict = new() { { "", 0 }, { "test", 1 } };
|
|
3010
|
+
Trie<int> trie = new(dict);
|
|
3011
|
+
List<int> results = new();
|
|
3012
|
+
trie.GetValuesWithPrefix("", results);
|
|
3013
|
+
|
|
3014
|
+
Assert.AreEqual(2, results.Count);
|
|
3015
|
+
CollectionAssert.Contains(results, 0);
|
|
3016
|
+
CollectionAssert.Contains(results, 1);
|
|
3017
|
+
}
|
|
3018
|
+
|
|
3019
|
+
[Test]
|
|
3020
|
+
public void GenericEnumeratorHandlesAlternatingBranches()
|
|
3021
|
+
{
|
|
3022
|
+
Dictionary<string, int> dict = new()
|
|
3023
|
+
{
|
|
3024
|
+
{ "a", 1 },
|
|
3025
|
+
{ "b", 2 },
|
|
3026
|
+
{ "aa", 3 },
|
|
3027
|
+
{ "bb", 4 },
|
|
3028
|
+
{ "aaa", 5 },
|
|
3029
|
+
{ "bbb", 6 },
|
|
3030
|
+
};
|
|
3031
|
+
Trie<int> trie = new(dict);
|
|
3032
|
+
|
|
3033
|
+
List<int> enumerated = new();
|
|
3034
|
+
foreach (int value in trie)
|
|
3035
|
+
{
|
|
3036
|
+
enumerated.Add(value);
|
|
3037
|
+
}
|
|
3038
|
+
|
|
3039
|
+
Assert.AreEqual(6, enumerated.Count);
|
|
3040
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
3041
|
+
}
|
|
3042
|
+
|
|
3043
|
+
[Test]
|
|
3044
|
+
public void GenericEnumeratorHandlesMixedLengthKeys()
|
|
3045
|
+
{
|
|
3046
|
+
Dictionary<string, int> dict = new()
|
|
3047
|
+
{
|
|
3048
|
+
{ "x", 1 },
|
|
3049
|
+
{ "xx", 2 },
|
|
3050
|
+
{ "xxx", 3 },
|
|
3051
|
+
{ "y", 4 },
|
|
3052
|
+
{ "yy", 5 },
|
|
3053
|
+
{ "z", 6 },
|
|
3054
|
+
};
|
|
3055
|
+
Trie<int> trie = new(dict);
|
|
3056
|
+
|
|
3057
|
+
List<int> enumerated = new();
|
|
3058
|
+
foreach (int value in trie)
|
|
3059
|
+
{
|
|
3060
|
+
enumerated.Add(value);
|
|
3061
|
+
}
|
|
3062
|
+
|
|
3063
|
+
Assert.AreEqual(6, enumerated.Count);
|
|
3064
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
3065
|
+
}
|
|
3066
|
+
|
|
3067
|
+
[Test]
|
|
3068
|
+
public void TryGetValueHandlesNullCharacterInKey()
|
|
3069
|
+
{
|
|
3070
|
+
Dictionary<string, int> dict = new() { { "test\0ing", 1 }, { "normal", 2 } };
|
|
3071
|
+
Trie<int> trie = new(dict);
|
|
3072
|
+
|
|
3073
|
+
Assert.IsTrue(trie.TryGetValue("test\0ing", out int value1));
|
|
3074
|
+
Assert.AreEqual(1, value1);
|
|
3075
|
+
Assert.IsTrue(trie.TryGetValue("normal", out int value2));
|
|
3076
|
+
Assert.AreEqual(2, value2);
|
|
3077
|
+
Assert.IsFalse(trie.TryGetValue("testing", out _));
|
|
3078
|
+
}
|
|
3079
|
+
|
|
3080
|
+
[Test]
|
|
3081
|
+
public void GenericEnumeratorHandlesNullCharacterInKeys()
|
|
3082
|
+
{
|
|
3083
|
+
Dictionary<string, int> dict = new()
|
|
3084
|
+
{
|
|
3085
|
+
{ "abc\0def", 1 },
|
|
3086
|
+
{ "test\0", 2 },
|
|
3087
|
+
{ "\0start", 3 },
|
|
3088
|
+
};
|
|
3089
|
+
Trie<int> trie = new(dict);
|
|
3090
|
+
|
|
3091
|
+
List<int> enumerated = new();
|
|
3092
|
+
foreach (int value in trie)
|
|
3093
|
+
{
|
|
3094
|
+
enumerated.Add(value);
|
|
3095
|
+
}
|
|
3096
|
+
|
|
3097
|
+
Assert.AreEqual(3, enumerated.Count);
|
|
3098
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
3099
|
+
}
|
|
3100
|
+
|
|
3101
|
+
[Test]
|
|
3102
|
+
public void GetValuesWithPrefixHandlesPrefixWithNullCharacter()
|
|
3103
|
+
{
|
|
3104
|
+
Dictionary<string, int> dict = new()
|
|
3105
|
+
{
|
|
3106
|
+
{ "test\0a", 1 },
|
|
3107
|
+
{ "test\0b", 2 },
|
|
3108
|
+
{ "other", 3 },
|
|
3109
|
+
};
|
|
3110
|
+
Trie<int> trie = new(dict);
|
|
3111
|
+
List<int> results = new();
|
|
3112
|
+
trie.GetValuesWithPrefix("test\0", results);
|
|
3113
|
+
|
|
3114
|
+
Assert.AreEqual(2, results.Count);
|
|
3115
|
+
CollectionAssert.Contains(results, 1);
|
|
3116
|
+
CollectionAssert.Contains(results, 2);
|
|
3117
|
+
}
|
|
3118
|
+
|
|
3119
|
+
[Test]
|
|
3120
|
+
public void GenericEnumeratorHandlesComplexUnicodeMixedWithAscii()
|
|
3121
|
+
{
|
|
3122
|
+
Dictionary<string, int> dict = new()
|
|
3123
|
+
{
|
|
3124
|
+
{ "test", 1 },
|
|
3125
|
+
{ "测试", 2 },
|
|
3126
|
+
{ "test测试", 3 },
|
|
3127
|
+
{ "🎉emoji", 4 },
|
|
3128
|
+
{ "mixed🎉test", 5 },
|
|
3129
|
+
};
|
|
3130
|
+
Trie<int> trie = new(dict);
|
|
3131
|
+
|
|
3132
|
+
List<int> enumerated = new();
|
|
3133
|
+
foreach (int value in trie)
|
|
3134
|
+
{
|
|
3135
|
+
enumerated.Add(value);
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3138
|
+
Assert.AreEqual(5, enumerated.Count);
|
|
3139
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
3140
|
+
}
|
|
3141
|
+
|
|
3142
|
+
[Test]
|
|
3143
|
+
public void GenericEnumeratorHandlesSurrogatePairs()
|
|
3144
|
+
{
|
|
3145
|
+
Dictionary<string, int> dict = new()
|
|
3146
|
+
{
|
|
3147
|
+
{ "𝕳𝖊𝖑𝖑𝖔", 1 },
|
|
3148
|
+
{ "𝓦𝓸𝓻𝓵𝓭", 2 },
|
|
3149
|
+
{ "🚀🌟", 3 },
|
|
3150
|
+
};
|
|
3151
|
+
Trie<int> trie = new(dict);
|
|
3152
|
+
|
|
3153
|
+
List<int> enumerated = new();
|
|
3154
|
+
foreach (int value in trie)
|
|
3155
|
+
{
|
|
3156
|
+
enumerated.Add(value);
|
|
3157
|
+
}
|
|
3158
|
+
|
|
3159
|
+
Assert.AreEqual(3, enumerated.Count);
|
|
3160
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
3161
|
+
}
|
|
3162
|
+
|
|
3163
|
+
[Test]
|
|
3164
|
+
public void GetValuesWithPrefixStressTestWithManyResults()
|
|
3165
|
+
{
|
|
3166
|
+
Dictionary<string, int> dict = new();
|
|
3167
|
+
for (int i = 0; i < 10000; i++)
|
|
3168
|
+
{
|
|
3169
|
+
dict[$"prefix{i}"] = i;
|
|
3170
|
+
}
|
|
3171
|
+
Trie<int> trie = new(dict);
|
|
3172
|
+
List<int> results = new();
|
|
3173
|
+
trie.GetValuesWithPrefix("prefix", results);
|
|
3174
|
+
|
|
3175
|
+
Assert.AreEqual(10000, results.Count);
|
|
3176
|
+
}
|
|
3177
|
+
|
|
3178
|
+
[Test]
|
|
3179
|
+
public void GenericEnumeratorStressTestWithDeeplyNestedAndWideBranching()
|
|
3180
|
+
{
|
|
3181
|
+
Dictionary<string, int> dict = new();
|
|
3182
|
+
int counter = 0;
|
|
3183
|
+
// Create a combination of deep and wide branching
|
|
3184
|
+
for (int i = 0; i < 100; i++)
|
|
3185
|
+
{
|
|
3186
|
+
dict[new string('a', i + 1)] = counter++;
|
|
3187
|
+
dict[new string('b', i + 1)] = counter++;
|
|
3188
|
+
dict[new string('c', i + 1)] = counter++;
|
|
3189
|
+
}
|
|
3190
|
+
Trie<int> trie = new(dict);
|
|
3191
|
+
|
|
3192
|
+
List<int> enumerated = new();
|
|
3193
|
+
foreach (int value in trie)
|
|
3194
|
+
{
|
|
3195
|
+
enumerated.Add(value);
|
|
3196
|
+
}
|
|
3197
|
+
|
|
3198
|
+
Assert.AreEqual(300, enumerated.Count);
|
|
3199
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
3200
|
+
}
|
|
3201
|
+
|
|
3202
|
+
[Test]
|
|
3203
|
+
public void GetValuesWithPrefixWithMaxResultsLargerThanAvailable()
|
|
3204
|
+
{
|
|
3205
|
+
Dictionary<string, int> dict = new() { { "a", 1 }, { "b", 2 } };
|
|
3206
|
+
Trie<int> trie = new(dict);
|
|
3207
|
+
List<int> results = new();
|
|
3208
|
+
int count = trie.GetValuesWithPrefix("", results, maxResults: 1000).Count;
|
|
3209
|
+
|
|
3210
|
+
Assert.AreEqual(2, count);
|
|
3211
|
+
Assert.AreEqual(2, results.Count);
|
|
3212
|
+
}
|
|
3213
|
+
|
|
3214
|
+
[Test]
|
|
3215
|
+
public void GenericEnumeratorCurrentBeforeMoveNextReturnsDefault()
|
|
3216
|
+
{
|
|
3217
|
+
Dictionary<string, int> dict = new() { { "test", 42 } };
|
|
3218
|
+
Trie<int> trie = new(dict);
|
|
3219
|
+
Trie<int>.Enumerator enumerator = trie.GetEnumerator();
|
|
3220
|
+
|
|
3221
|
+
// Current should be default before first MoveNext
|
|
3222
|
+
Assert.AreEqual(default(int), enumerator.Current);
|
|
3223
|
+
}
|
|
3224
|
+
|
|
3225
|
+
[Test]
|
|
3226
|
+
public void GenericEnumeratorCurrentAfterLastMoveNextReturnsLastValue()
|
|
3227
|
+
{
|
|
3228
|
+
Dictionary<string, int> dict = new() { { "single", 42 } };
|
|
3229
|
+
Trie<int> trie = new(dict);
|
|
3230
|
+
Trie<int>.Enumerator enumerator = trie.GetEnumerator();
|
|
3231
|
+
|
|
3232
|
+
Assert.IsTrue(enumerator.MoveNext());
|
|
3233
|
+
int lastValue = enumerator.Current;
|
|
3234
|
+
Assert.IsFalse(enumerator.MoveNext());
|
|
3235
|
+
|
|
3236
|
+
// Current should still return the last value
|
|
3237
|
+
Assert.AreEqual(lastValue, enumerator.Current);
|
|
3238
|
+
}
|
|
3239
|
+
|
|
3240
|
+
[Test]
|
|
3241
|
+
public void TryGetValueWithVeryLongKey()
|
|
3242
|
+
{
|
|
3243
|
+
string longKey = new('x', 10000);
|
|
3244
|
+
Dictionary<string, int> dict = new() { { longKey, 42 } };
|
|
3245
|
+
Trie<int> trie = new(dict);
|
|
3246
|
+
|
|
3247
|
+
Assert.IsTrue(trie.TryGetValue(longKey, out int value));
|
|
3248
|
+
Assert.AreEqual(42, value);
|
|
3249
|
+
Assert.IsFalse(trie.TryGetValue(longKey + "y", out _));
|
|
3250
|
+
}
|
|
3251
|
+
|
|
3252
|
+
[Test]
|
|
3253
|
+
public void GetValuesWithPrefixWithVeryLongPrefix()
|
|
3254
|
+
{
|
|
3255
|
+
string longPrefix = new('x', 5000);
|
|
3256
|
+
string longerKey = longPrefix + "extra";
|
|
3257
|
+
Dictionary<string, int> dict = new() { { longerKey, 99 } };
|
|
3258
|
+
Trie<int> trie = new(dict);
|
|
3259
|
+
List<int> results = new();
|
|
3260
|
+
trie.GetValuesWithPrefix(longPrefix, results);
|
|
3261
|
+
|
|
3262
|
+
Assert.AreEqual(1, results.Count);
|
|
3263
|
+
Assert.AreEqual(99, results[0]);
|
|
3264
|
+
}
|
|
3265
|
+
|
|
3266
|
+
[Test]
|
|
3267
|
+
public void GenericEnumeratorHandlesLargeValueTypes()
|
|
3268
|
+
{
|
|
3269
|
+
Dictionary<string, (long, long, long, long)> dict = new()
|
|
3270
|
+
{
|
|
3271
|
+
{ "a", (long.MaxValue, long.MinValue, 0, 12345) },
|
|
3272
|
+
{ "b", (1, 2, 3, 4) },
|
|
3273
|
+
{ "c", (-1, -2, -3, -4) },
|
|
3274
|
+
};
|
|
3275
|
+
Trie<(long, long, long, long)> trie = new(dict);
|
|
3276
|
+
|
|
3277
|
+
List<(long, long, long, long)> enumerated = new();
|
|
3278
|
+
foreach ((long, long, long, long) value in trie)
|
|
3279
|
+
{
|
|
3280
|
+
enumerated.Add(value);
|
|
3281
|
+
}
|
|
3282
|
+
|
|
3283
|
+
Assert.AreEqual(3, enumerated.Count);
|
|
3284
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
3285
|
+
}
|
|
3286
|
+
|
|
3287
|
+
[Test]
|
|
3288
|
+
public void GenericEnumeratorHandlesNestedCollections()
|
|
3289
|
+
{
|
|
3290
|
+
Dictionary<string, List<List<int>>> dict = new()
|
|
3291
|
+
{
|
|
3292
|
+
{
|
|
3293
|
+
"a",
|
|
3294
|
+
new List<List<int>>
|
|
3295
|
+
{
|
|
3296
|
+
new() { 1, 2 },
|
|
3297
|
+
new() { 3, 4 },
|
|
3298
|
+
}
|
|
3299
|
+
},
|
|
3300
|
+
{
|
|
3301
|
+
"b",
|
|
3302
|
+
new List<List<int>> { new() { 5 } }
|
|
3303
|
+
},
|
|
3304
|
+
};
|
|
3305
|
+
Trie<List<List<int>>> trie = new(dict);
|
|
3306
|
+
|
|
3307
|
+
List<List<List<int>>> enumerated = new();
|
|
3308
|
+
foreach (List<List<int>> value in trie)
|
|
3309
|
+
{
|
|
3310
|
+
enumerated.Add(value);
|
|
3311
|
+
}
|
|
3312
|
+
|
|
3313
|
+
Assert.AreEqual(2, enumerated.Count);
|
|
3314
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
3315
|
+
}
|
|
3316
|
+
|
|
3317
|
+
[Test]
|
|
3318
|
+
public void GetValuesWithPrefixHandlesEmptyDictionary()
|
|
3319
|
+
{
|
|
3320
|
+
Trie<int> trie = new(new Dictionary<string, int>());
|
|
3321
|
+
List<int> results = new();
|
|
3322
|
+
trie.GetValuesWithPrefix("anything", results);
|
|
3323
|
+
|
|
3324
|
+
Assert.AreEqual(0, results.Count);
|
|
3325
|
+
}
|
|
3326
|
+
|
|
3327
|
+
[Test]
|
|
3328
|
+
public void GenericEnumeratorHandlesBoolValues()
|
|
3329
|
+
{
|
|
3330
|
+
Dictionary<string, bool> dict = new()
|
|
3331
|
+
{
|
|
3332
|
+
{ "true1", true },
|
|
3333
|
+
{ "false1", false },
|
|
3334
|
+
{ "true2", true },
|
|
3335
|
+
};
|
|
3336
|
+
Trie<bool> trie = new(dict);
|
|
3337
|
+
|
|
3338
|
+
List<bool> enumerated = new();
|
|
3339
|
+
foreach (bool value in trie)
|
|
3340
|
+
{
|
|
3341
|
+
enumerated.Add(value);
|
|
3342
|
+
}
|
|
3343
|
+
|
|
3344
|
+
Assert.AreEqual(3, enumerated.Count);
|
|
3345
|
+
CollectionAssert.AreEquivalent(dict.Values, enumerated);
|
|
3346
|
+
}
|
|
3347
|
+
|
|
3348
|
+
[Test]
|
|
3349
|
+
public void TryGetValueHandlesCaseSensitivityForSimilarKeys()
|
|
3350
|
+
{
|
|
3351
|
+
Dictionary<string, int> dict = new()
|
|
3352
|
+
{
|
|
3353
|
+
{ "test", 1 },
|
|
3354
|
+
{ "Test", 2 },
|
|
3355
|
+
{ "TEST", 3 },
|
|
3356
|
+
};
|
|
3357
|
+
Trie<int> trie = new(dict);
|
|
3358
|
+
|
|
3359
|
+
Assert.IsTrue(trie.TryGetValue("test", out int value1));
|
|
3360
|
+
Assert.AreEqual(1, value1);
|
|
3361
|
+
Assert.IsTrue(trie.TryGetValue("Test", out int value2));
|
|
3362
|
+
Assert.AreEqual(2, value2);
|
|
3363
|
+
Assert.IsTrue(trie.TryGetValue("TEST", out int value3));
|
|
3364
|
+
Assert.AreEqual(3, value3);
|
|
3365
|
+
}
|
|
3366
|
+
|
|
3367
|
+
[Test]
|
|
3368
|
+
public void GetValuesWithPrefixHandlesPartialUnicodePrefix()
|
|
3369
|
+
{
|
|
3370
|
+
Dictionary<string, int> dict = new()
|
|
3371
|
+
{
|
|
3372
|
+
{ "café", 1 },
|
|
3373
|
+
{ "cafeteria", 2 },
|
|
3374
|
+
{ "cat", 3 },
|
|
3375
|
+
};
|
|
3376
|
+
Trie<int> trie = new(dict);
|
|
3377
|
+
List<int> results = new();
|
|
3378
|
+
trie.GetValuesWithPrefix("caf", results);
|
|
3379
|
+
|
|
3380
|
+
Assert.AreEqual(2, results.Count);
|
|
3381
|
+
CollectionAssert.Contains(results, 1);
|
|
3382
|
+
CollectionAssert.Contains(results, 2);
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
}
|