@crownpeak/dqm-react-component-dev-mcp 1.2.0
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/README.md +138 -0
- package/data/.env.example +22 -0
- package/data/.gitattributes +47 -0
- package/data/.glfrc.json +7 -0
- package/data/.husky/pre-commit +5 -0
- package/data/.nvmrc +1 -0
- package/data/CHANGELOG.md +75 -0
- package/data/CODE_OF_CONDUCT.md +129 -0
- package/data/CONTRIBUTING.md +203 -0
- package/data/DOCS-STRUCTURE.md +307 -0
- package/data/I18N.md +292 -0
- package/data/LICENSE +22 -0
- package/data/README.md +315 -0
- package/data/SECURITY.md +125 -0
- package/data/WIKI-DEPLOYMENT.md +348 -0
- package/data/docs/AI-FEATURES.md +610 -0
- package/data/docs/API-REFERENCE.md +1022 -0
- package/data/docs/AUTHENTICATION.md +301 -0
- package/data/docs/BACKEND-API.md +468 -0
- package/data/docs/DEVELOPMENT.md +375 -0
- package/data/docs/EXAMPLES.md +622 -0
- package/data/docs/MCP-SERVER.md +307 -0
- package/data/docs/MIGRATION-GUIDE.md +367 -0
- package/data/docs/NPM-PUBLISH.md +193 -0
- package/data/docs/QUICKSTART.md +206 -0
- package/data/docs/REDIS-SETUP.md +162 -0
- package/data/docs/SERVER.md +228 -0
- package/data/docs/TROUBLESHOOTING.md +657 -0
- package/data/docs/WIDGET-GUIDE.md +638 -0
- package/data/docs/WIKI-HOME.md +58 -0
- package/data/docs/WIKI-SIDEBAR.md +39 -0
- package/data/package.json +171 -0
- package/data/playwright.config.ts +64 -0
- package/data/probe/.cargo/config.toml +10 -0
- package/data/probe/.claude/commands/performance-review.md +15 -0
- package/data/probe/.clinerules +288 -0
- package/data/probe/.dockerignore +57 -0
- package/data/probe/.githooks/post-commit +11 -0
- package/data/probe/.githooks/pre-commit +99 -0
- package/data/probe/.githooks/pre-commit-vow +9 -0
- package/data/probe/.prompts/engineer.md +41 -0
- package/data/probe/.roomodes +28 -0
- package/data/probe/.windsurfrules +0 -0
- package/data/probe/BASH_TOOL_SUMMARY.md +148 -0
- package/data/probe/BENCHMARKING.md +256 -0
- package/data/probe/CLAUDE.md +226 -0
- package/data/probe/CODE_OF_CONDUCT.md +128 -0
- package/data/probe/CONTRIBUTING.md +193 -0
- package/data/probe/Cargo.toml +120 -0
- package/data/probe/Cross.toml +10 -0
- package/data/probe/DOCKER-README.md +224 -0
- package/data/probe/Dockerfile +32 -0
- package/data/probe/ENHANCED_DEBUG_TELEMETRY.md +188 -0
- package/data/probe/LICENSE +201 -0
- package/data/probe/Makefile +210 -0
- package/data/probe/README.md +824 -0
- package/data/probe/SECURITY.md +67 -0
- package/data/probe/WINDOWS-GUIDE.md +294 -0
- package/data/probe/benches/parsing_benchmarks.rs +370 -0
- package/data/probe/benches/search_benchmarks.rs +599 -0
- package/data/probe/benches/simd_benchmarks.rs +372 -0
- package/data/probe/benches/timing_benchmarks.rs +287 -0
- package/data/probe/build-windows.bat +229 -0
- package/data/probe/codex-config/config.toml +6 -0
- package/data/probe/docs/PERFORMANCE_OPTIMIZATION.md +161 -0
- package/data/probe/examples/cache_demo.rs +46 -0
- package/data/probe/examples/chat/.dockerignore +37 -0
- package/data/probe/examples/chat/ChatSessionManager.js +295 -0
- package/data/probe/examples/chat/Dockerfile +98 -0
- package/data/probe/examples/chat/LICENSE +201 -0
- package/data/probe/examples/chat/LOCAL_IMAGE_SUPPORT.md +195 -0
- package/data/probe/examples/chat/MCP_INTEGRATION.md +400 -0
- package/data/probe/examples/chat/README.md +338 -0
- package/data/probe/examples/chat/TRACING.md +226 -0
- package/data/probe/examples/chat/appTracer.js +968 -0
- package/data/probe/examples/chat/auth.js +76 -0
- package/data/probe/examples/chat/bin/probe-chat.js +13 -0
- package/data/probe/examples/chat/build.js +104 -0
- package/data/probe/examples/chat/cancelRequest.js +84 -0
- package/data/probe/examples/chat/demo-agentic-image-flow.js +88 -0
- package/data/probe/examples/chat/demo-local-images.js +128 -0
- package/data/probe/examples/chat/fileSpanExporter.js +181 -0
- package/data/probe/examples/chat/implement/README.md +228 -0
- package/data/probe/examples/chat/implement/backends/AiderBackend.js +750 -0
- package/data/probe/examples/chat/implement/backends/BaseBackend.js +276 -0
- package/data/probe/examples/chat/implement/backends/ClaudeCodeBackend.js +767 -0
- package/data/probe/examples/chat/implement/backends/MockBackend.js +237 -0
- package/data/probe/examples/chat/implement/backends/registry.js +85 -0
- package/data/probe/examples/chat/implement/core/BackendManager.js +567 -0
- package/data/probe/examples/chat/implement/core/ImplementTool.js +354 -0
- package/data/probe/examples/chat/implement/core/config.js +428 -0
- package/data/probe/examples/chat/implement/core/timeouts.js +58 -0
- package/data/probe/examples/chat/implement/core/utils.js +496 -0
- package/data/probe/examples/chat/implement/types/BackendTypes.js +126 -0
- package/data/probe/examples/chat/index.js +669 -0
- package/data/probe/examples/chat/mcpServer.js +341 -0
- package/data/probe/examples/chat/npm/LICENSE +15 -0
- package/data/probe/examples/chat/npm/README.md +168 -0
- package/data/probe/examples/chat/npm/bin/probe-chat.js +156 -0
- package/data/probe/examples/chat/npm/index.js +259 -0
- package/data/probe/examples/chat/npm/package.json +54 -0
- package/data/probe/examples/chat/package.json +102 -0
- package/data/probe/examples/chat/probeChat.js +456 -0
- package/data/probe/examples/chat/probeTool.js +491 -0
- package/data/probe/examples/chat/storage/JsonChatStorage.js +476 -0
- package/data/probe/examples/chat/telemetry.js +281 -0
- package/data/probe/examples/chat/test/integration/chatFlows.test.js +320 -0
- package/data/probe/examples/chat/test/integration/toolCalling.test.js +471 -0
- package/data/probe/examples/chat/test/mocks/mockLLMProvider.js +269 -0
- package/data/probe/examples/chat/test/test-backends.js +90 -0
- package/data/probe/examples/chat/test/testUtils.js +530 -0
- package/data/probe/examples/chat/test/unit/backendTimeout.test.js +161 -0
- package/data/probe/examples/chat/test/unit/packageFiles.test.js +120 -0
- package/data/probe/examples/chat/test/verify-tests.js +118 -0
- package/data/probe/examples/chat/test-agentic-image-loading.js +294 -0
- package/data/probe/examples/chat/test-ai-sdk-telemetry.js +204 -0
- package/data/probe/examples/chat/test-chat-tracing.js +38 -0
- package/data/probe/examples/chat/test-direct-function.js +49 -0
- package/data/probe/examples/chat/test-file-size-validation.js +103 -0
- package/data/probe/examples/chat/test-full-mcp-integration.js +258 -0
- package/data/probe/examples/chat/test-github-context.txt +12 -0
- package/data/probe/examples/chat/test-hierarchy.js +203 -0
- package/data/probe/examples/chat/test-image-spans.js +37 -0
- package/data/probe/examples/chat/test-local-image-reading.js +176 -0
- package/data/probe/examples/chat/test-mcp-integration.js +136 -0
- package/data/probe/examples/chat/test-mcp-probe-server.js +161 -0
- package/data/probe/examples/chat/test-mcp-with-ai.js +279 -0
- package/data/probe/examples/chat/test-multiple-allowed-dirs.js +111 -0
- package/data/probe/examples/chat/test-probe-mcp-server.js +110 -0
- package/data/probe/examples/chat/test-security-validation.js +145 -0
- package/data/probe/examples/chat/test-simple-tracing.js +32 -0
- package/data/probe/examples/chat/test-trace-verification.js +235 -0
- package/data/probe/examples/chat/test-tracing.js +114 -0
- package/data/probe/examples/chat/tokenCounter.js +419 -0
- package/data/probe/examples/chat/tokenUsageDisplay.js +134 -0
- package/data/probe/examples/chat/webServer.js +1103 -0
- package/data/probe/examples/reranker/Cargo.toml +33 -0
- package/data/probe/examples/reranker/DEBUG_OUTPUT_ANALYSIS.md +71 -0
- package/data/probe/examples/reranker/MODELS.md +66 -0
- package/data/probe/examples/reranker/MODEL_COMPARISON.md +60 -0
- package/data/probe/examples/reranker/MULTI_MODEL_ANALYSIS.md +176 -0
- package/data/probe/examples/reranker/PERFORMANCE_SUMMARY.md +156 -0
- package/data/probe/examples/reranker/README.md +347 -0
- package/data/probe/examples/reranker/RUST_BERT_COMPARISON.md +82 -0
- package/data/probe/examples/reranker/TOKENIZATION_GUIDE.md +120 -0
- package/data/probe/examples/reranker/check_rust_tokenizer.py +108 -0
- package/data/probe/examples/reranker/convert_to_torchscript.py +109 -0
- package/data/probe/examples/reranker/debug_scoring.py +189 -0
- package/data/probe/examples/reranker/debug_tokenization.py +154 -0
- package/data/probe/examples/reranker/download_models.sh +73 -0
- package/data/probe/examples/reranker/requirements.txt +13 -0
- package/data/probe/examples/reranker/run_comprehensive_benchmark.sh +83 -0
- package/data/probe/examples/reranker/rust_bert_test/Cargo.toml +12 -0
- package/data/probe/examples/reranker/rust_bert_test/README.md +54 -0
- package/data/probe/examples/reranker/simple_test.py +50 -0
- package/data/probe/examples/reranker/test_all_models.sh +63 -0
- package/data/probe/examples/reranker/test_bert_results.sh +44 -0
- package/data/probe/examples/reranker/test_cross_encoder.py +334 -0
- package/data/probe/examples/reranker/test_cross_encoder.sh +80 -0
- package/data/probe/examples/reranker/test_exact_comparison.py +151 -0
- package/data/probe/examples/reranker/test_parallel_performance.sh +56 -0
- package/data/probe/examples/reranker/test_scores.py +132 -0
- package/data/probe/install.ps1 +508 -0
- package/data/probe/install.sh +460 -0
- package/data/probe/npm/CLONE_METHOD_EXAMPLES.md +596 -0
- package/data/probe/npm/CONTEXT_COMPACTION.md +303 -0
- package/data/probe/npm/DELEGATE_TOOL_README.md +166 -0
- package/data/probe/npm/MAID_INTEGRATION.md +313 -0
- package/data/probe/npm/MCP_INTEGRATION_SUMMARY.md +241 -0
- package/data/probe/npm/README.md +824 -0
- package/data/probe/npm/bin/.gitignore +7 -0
- package/data/probe/npm/bin/.gitkeep +0 -0
- package/data/probe/npm/bin/README.md +12 -0
- package/data/probe/npm/bin/probe +167 -0
- package/data/probe/npm/docs/CLAUDE_CODE_INTEGRATION.md +414 -0
- package/data/probe/npm/docs/CODEX_INTEGRATION.md +502 -0
- package/data/probe/npm/docs/EDIT_CREATE_TOOLS.md +233 -0
- package/data/probe/npm/docs/RETRY_AND_FALLBACK.md +674 -0
- package/data/probe/npm/example-usage.js +335 -0
- package/data/probe/npm/examples/multi-engine-demo.js +117 -0
- package/data/probe/npm/examples/probe-agent-cli.js +113 -0
- package/data/probe/npm/examples/test-agent-edit.js +114 -0
- package/data/probe/npm/examples/test-edit-create.js +120 -0
- package/data/probe/npm/examples/test-edit-direct.js +114 -0
- package/data/probe/npm/index.d.ts +744 -0
- package/data/probe/npm/jest.config.js +52 -0
- package/data/probe/npm/package.json +117 -0
- package/data/probe/npm/scripts/build-agent.cjs +75 -0
- package/data/probe/npm/scripts/build-cjs.js +124 -0
- package/data/probe/npm/scripts/build-mcp.cjs +36 -0
- package/data/probe/npm/scripts/postinstall.js +216 -0
- package/data/probe/npm/test-codex-e2e.js +78 -0
- package/data/probe/npm/test-download-lock.js +109 -0
- package/data/probe/npm/test-grep-security.js +94 -0
- package/data/probe/npm/test-grep-simplified.js +63 -0
- package/data/probe/npm/test-grep.js +51 -0
- package/data/probe/npm/tests/README.md +96 -0
- package/data/probe/npm/tests/agent-compact-history.test.js +174 -0
- package/data/probe/npm/tests/allow-tests-default.test.js +151 -0
- package/data/probe/npm/tests/contextCompactor.test.js +498 -0
- package/data/probe/npm/tests/delegate-config.test.js +353 -0
- package/data/probe/npm/tests/delegate-integration.test.js +348 -0
- package/data/probe/npm/tests/extractor-integration.test.js +162 -0
- package/data/probe/npm/tests/extractor.test.js +317 -0
- package/data/probe/npm/tests/fixtures/sampleDiagrams.js +267 -0
- package/data/probe/npm/tests/integration/claude-code-auto-fallback.spec.js +148 -0
- package/data/probe/npm/tests/integration/claude-code-multi-step.spec.js +127 -0
- package/data/probe/npm/tests/integration/claude-code-tool-events.spec.js +163 -0
- package/data/probe/npm/tests/integration/codex-auto-fallback.spec.js +191 -0
- package/data/probe/npm/tests/integration/codex-tool-events.spec.js +147 -0
- package/data/probe/npm/tests/integration/examplesChatMcp.test.js +402 -0
- package/data/probe/npm/tests/integration/mcpDotenvSupport.test.js +174 -0
- package/data/probe/npm/tests/integration/mcpErrorHandling.test.js +566 -0
- package/data/probe/npm/tests/integration/mcpRobustness.test.js +564 -0
- package/data/probe/npm/tests/integration/mcpStdoutPurity.test.js +355 -0
- package/data/probe/npm/tests/integration/probeAgentMcp.test.js +398 -0
- package/data/probe/npm/tests/integration/retryFallback.test.js +368 -0
- package/data/probe/npm/tests/integration/schema-in-initial-message.test.js +318 -0
- package/data/probe/npm/tests/integration/schema-validation-loop-prevention.test.js +244 -0
- package/data/probe/npm/tests/integration/schemaRetryLogic.test.js +94 -0
- package/data/probe/npm/tests/integration/validationFlow.test.js +329 -0
- package/data/probe/npm/tests/manual/test-codex-basic.js +110 -0
- package/data/probe/npm/tests/mcp/mcpClientManager.test.js +614 -0
- package/data/probe/npm/tests/mcp/mcpConfig.test.js +359 -0
- package/data/probe/npm/tests/mcp/mcpXmlBridge.test.js +436 -0
- package/data/probe/npm/tests/mcp/mockMcpServer.js +510 -0
- package/data/probe/npm/tests/mcp-strict-syntax.test.js +319 -0
- package/data/probe/npm/tests/mermaidQuoteEscaping.test.js +214 -0
- package/data/probe/npm/tests/nestedQuoteFix.test.js +40 -0
- package/data/probe/npm/tests/setup.js +46 -0
- package/data/probe/npm/tests/unit/allowed-tools.test.js +513 -0
- package/data/probe/npm/tests/unit/attempt-completion-closing-tag-in-content.test.js +188 -0
- package/data/probe/npm/tests/unit/attemptCompletionJsonFix.test.js +238 -0
- package/data/probe/npm/tests/unit/attemptCompletionJsonIssue.test.js +128 -0
- package/data/probe/npm/tests/unit/backtickAutoFix.test.js +35 -0
- package/data/probe/npm/tests/unit/bash-probe-agent-integration.test.js +389 -0
- package/data/probe/npm/tests/unit/bash-simple-commands.test.js +324 -0
- package/data/probe/npm/tests/unit/bash-tool-comprehensive.test.js +371 -0
- package/data/probe/npm/tests/unit/bash-tool-integration.test.js +310 -0
- package/data/probe/npm/tests/unit/bash-tool.test.js +341 -0
- package/data/probe/npm/tests/unit/completion-prompt.test.js +379 -0
- package/data/probe/npm/tests/unit/cwd-path-options.test.js +287 -0
- package/data/probe/npm/tests/unit/delegate-limits.test.js +422 -0
- package/data/probe/npm/tests/unit/direct-content-attempt-completion.test.js +235 -0
- package/data/probe/npm/tests/unit/edit-create-tools.test.js +609 -0
- package/data/probe/npm/tests/unit/enhancedMermaidValidation.test.js +577 -0
- package/data/probe/npm/tests/unit/extract-content.test.js +83 -0
- package/data/probe/npm/tests/unit/extract-multiple-targets.test.js +89 -0
- package/data/probe/npm/tests/unit/fallbackManager.test.js +442 -0
- package/data/probe/npm/tests/unit/githubCompatibilityValidation.test.js +258 -0
- package/data/probe/npm/tests/unit/imageConfig.test.js +149 -0
- package/data/probe/npm/tests/unit/imagePathResolution.test.js +345 -0
- package/data/probe/npm/tests/unit/json-fixing-agent.test.js +238 -0
- package/data/probe/npm/tests/unit/json-validation-enhanced-errors.test.js +199 -0
- package/data/probe/npm/tests/unit/jsonValidationInfiniteLoopFix.test.js +228 -0
- package/data/probe/npm/tests/unit/maidIntegration.test.js +139 -0
- package/data/probe/npm/tests/unit/maxIterationsWarning.test.js +195 -0
- package/data/probe/npm/tests/unit/mermaidEdgeLabelFix.test.js +161 -0
- package/data/probe/npm/tests/unit/mermaidHtmlEntities.test.js +76 -0
- package/data/probe/npm/tests/unit/mermaidInfiniteLoopFix.test.js +64 -0
- package/data/probe/npm/tests/unit/mermaidValidation.test.js +723 -0
- package/data/probe/npm/tests/unit/mermaidValidationVisorExample.test.js +309 -0
- package/data/probe/npm/tests/unit/probe-agent-clone-realistic.test.js +643 -0
- package/data/probe/npm/tests/unit/probe-agent-clone.test.js +476 -0
- package/data/probe/npm/tests/unit/probe-agent-delegate.test.js +400 -0
- package/data/probe/npm/tests/unit/probe-agent-model-option.test.js +118 -0
- package/data/probe/npm/tests/unit/probeTool-security.test.js +283 -0
- package/data/probe/npm/tests/unit/readImageTool.test.js +418 -0
- package/data/probe/npm/tests/unit/retryManager.test.js +317 -0
- package/data/probe/npm/tests/unit/schema-aware-reminders.test.js +288 -0
- package/data/probe/npm/tests/unit/schemaDefinitionDetection.test.js +115 -0
- package/data/probe/npm/tests/unit/schemaUtils.test.js +1268 -0
- package/data/probe/npm/tests/unit/simpleTelemetry.test.js +282 -0
- package/data/probe/npm/tests/unit/simplified-attempt-completion.test.js +274 -0
- package/data/probe/npm/tests/unit/single-quote-json-bug.test.js +231 -0
- package/data/probe/npm/tests/unit/subgraphAutoFix.test.js +110 -0
- package/data/probe/npm/tests/unit/system-prompt.test.js +32 -0
- package/data/probe/npm/tests/unit/types-probe-agent-options.test.js +42 -0
- package/data/probe/npm/tests/unit/xmlParsing.test.js +720 -0
- package/data/probe/npm/tsconfig.json +21 -0
- package/data/probe/result1.txt +19 -0
- package/data/probe/result2.txt +26 -0
- package/data/probe/scripts/benchmark.sh +270 -0
- package/data/probe/scripts/cache_memory_analysis.rs +844 -0
- package/data/probe/scripts/claude-hook-wrapper.sh +56 -0
- package/data/probe/site/.env.example +10 -0
- package/data/probe/site/DEPLOYMENT.md +86 -0
- package/data/probe/site/README.md +183 -0
- package/data/probe/site/adding-languages.md +135 -0
- package/data/probe/site/ai-chat.md +427 -0
- package/data/probe/site/ai-integration.md +1488 -0
- package/data/probe/site/blog/agentic-flow-custom-xml-protocol.md +407 -0
- package/data/probe/site/blog/index.md +118 -0
- package/data/probe/site/blog/v0.6.0-release.md +426 -0
- package/data/probe/site/blog.md +8 -0
- package/data/probe/site/changelog.md +200 -0
- package/data/probe/site/cli-mode.md +437 -0
- package/data/probe/site/code-extraction.md +436 -0
- package/data/probe/site/contributing/README.md +9 -0
- package/data/probe/site/contributing/documentation-cross-references.md +215 -0
- package/data/probe/site/contributing/documentation-maintenance.md +275 -0
- package/data/probe/site/contributing/documentation-structure.md +75 -0
- package/data/probe/site/documentation-cross-references.md +215 -0
- package/data/probe/site/documentation-guide.md +132 -0
- package/data/probe/site/documentation-maintenance.md +275 -0
- package/data/probe/site/features.md +147 -0
- package/data/probe/site/how-it-works.md +118 -0
- package/data/probe/site/index.md +175 -0
- package/data/probe/site/index.md.bak +133 -0
- package/data/probe/site/installation.md +235 -0
- package/data/probe/site/integrations/docker.md +248 -0
- package/data/probe/site/integrations/github-actions.md +413 -0
- package/data/probe/site/language-support-overview.md +168 -0
- package/data/probe/site/mcp-integration.md +587 -0
- package/data/probe/site/mcp-server.md +304 -0
- package/data/probe/site/navigation-structure.md +76 -0
- package/data/probe/site/nodejs-sdk.md +798 -0
- package/data/probe/site/output-formats.md +625 -0
- package/data/probe/site/package.json +21 -0
- package/data/probe/site/public/_headers +28 -0
- package/data/probe/site/public/_redirects +11 -0
- package/data/probe/site/quick-start.md +289 -0
- package/data/probe/site/search-functionality.md +291 -0
- package/data/probe/site/search-reference.md +291 -0
- package/data/probe/site/supported-languages.md +215 -0
- package/data/probe/site/use-cases/README.md +8 -0
- package/data/probe/site/use-cases/advanced-cli.md +253 -0
- package/data/probe/site/use-cases/ai-code-editors.md +239 -0
- package/data/probe/site/use-cases/building-ai-tools.md +529 -0
- package/data/probe/site/use-cases/cli-ai-workflows.md +285 -0
- package/data/probe/site/use-cases/deploying-probe-web-interface.md +255 -0
- package/data/probe/site/use-cases/integrating-probe-into-ai-code-editors.md +161 -0
- package/data/probe/site/use-cases/nodejs-sdk.md +596 -0
- package/data/probe/site/use-cases/team-chat.md +350 -0
- package/data/probe/site/web-interface.md +434 -0
- package/data/probe/site/wrangler.toml +9 -0
- package/data/probe/test-api-key.sh +1 -0
- package/data/probe/test-probe-implementation/hello.js +7 -0
- package/data/probe/test_cases/demonstrate_early_termination_issues.sh +176 -0
- package/data/probe/test_cases/early_termination_issues.rs +533 -0
- package/data/probe/test_data/test_nested_struct.go +26 -0
- package/data/probe/tests/README.md +286 -0
- package/data/probe/tests/README_search_determinism_tests.md +116 -0
- package/data/probe/tests/adjacent_comment_test.rs +152 -0
- package/data/probe/tests/apostrophe_handling_tests.rs +132 -0
- package/data/probe/tests/block_filtering_with_ast_tests.rs +669 -0
- package/data/probe/tests/block_merging_tests.rs +396 -0
- package/data/probe/tests/c_outline_format_tests.rs +2179 -0
- package/data/probe/tests/cache_invalidation_issues.rs.disabled +682 -0
- package/data/probe/tests/cache_order_tests.rs +147 -0
- package/data/probe/tests/cache_query_scoping_tests.rs +221 -0
- package/data/probe/tests/cli_tests.rs +680 -0
- package/data/probe/tests/comment_context_integration_test.rs +240 -0
- package/data/probe/tests/common.rs +33 -0
- package/data/probe/tests/complex_block_merging_tests.rs +599 -0
- package/data/probe/tests/complex_query_block_filtering_tests.rs +422 -0
- package/data/probe/tests/control_flow_closing_braces_test.rs +91 -0
- package/data/probe/tests/cpp_outline_format_tests.rs +1507 -0
- package/data/probe/tests/csharp_outline_format_tests.rs +941 -0
- package/data/probe/tests/elastic_query_integration_tests.rs +922 -0
- package/data/probe/tests/extract_command_tests.rs +1848 -0
- package/data/probe/tests/extract_deduplication_tests.rs +146 -0
- package/data/probe/tests/extract_input_file_tests.rs +84 -0
- package/data/probe/tests/extract_prompt_tests.rs +102 -0
- package/data/probe/tests/filename_search_tests.rs +96 -0
- package/data/probe/tests/fixtures/user/AssemblyInfo.cs +3 -0
- package/data/probe/tests/github_extract_tests.rs +234 -0
- package/data/probe/tests/go_comment_test.rs +253 -0
- package/data/probe/tests/go_outline_format_tests.rs +2587 -0
- package/data/probe/tests/go_path_resolver_tests.rs +96 -0
- package/data/probe/tests/html_outline_format_tests.rs +637 -0
- package/data/probe/tests/integration_tests.rs +837 -0
- package/data/probe/tests/ip_whitelist_test.rs +148 -0
- package/data/probe/tests/java_outline_format_tests.rs +1611 -0
- package/data/probe/tests/javascript_extract_tests.rs +315 -0
- package/data/probe/tests/javascript_outline_format_tests.rs +1464 -0
- package/data/probe/tests/json_format_tests.rs +436 -0
- package/data/probe/tests/json_schema_validation_tests.rs +450 -0
- package/data/probe/tests/lib_usage.rs +60 -0
- package/data/probe/tests/line_comment_context_extension_test.rs +459 -0
- package/data/probe/tests/line_map_cache_tests.rs +114 -0
- package/data/probe/tests/markdown_integration_tests.rs +190 -0
- package/data/probe/tests/mocks/test_ip_whitelist.go +11 -0
- package/data/probe/tests/mocks/test_object.js +27 -0
- package/data/probe/tests/mocks/test_struct.go +50 -0
- package/data/probe/tests/multi_keyword_pattern_tests.rs +464 -0
- package/data/probe/tests/multi_language_syntax_integration_tests.rs +218 -0
- package/data/probe/tests/multiple_capture_groups_tests.rs +169 -0
- package/data/probe/tests/negative_compound_word_tests.rs +246 -0
- package/data/probe/tests/nested_symbol_extraction_tests.rs +99 -0
- package/data/probe/tests/outline_cross_file_interference_test.rs +335 -0
- package/data/probe/tests/outline_keyword_preservation_test.rs +67 -0
- package/data/probe/tests/output_format_edge_cases_tests.rs +693 -0
- package/data/probe/tests/parallel_extraction_tests.rs +178 -0
- package/data/probe/tests/parallel_search_tests.rs +355 -0
- package/data/probe/tests/path_resolver_tests.rs +698 -0
- package/data/probe/tests/php_outline_format_extended_tests.rs +928 -0
- package/data/probe/tests/php_outline_format_tests.rs +768 -0
- package/data/probe/tests/property_tests.proptest-regressions +9 -0
- package/data/probe/tests/property_tests.rs +118 -0
- package/data/probe/tests/python_outline_format_tests.rs +1538 -0
- package/data/probe/tests/query_command_json_tests.rs +438 -0
- package/data/probe/tests/query_command_tests.rs +232 -0
- package/data/probe/tests/query_command_xml_tests.rs +569 -0
- package/data/probe/tests/quoted_term_with_negative_keyword_tests.rs +216 -0
- package/data/probe/tests/required_terms_filename_tests.rs +116 -0
- package/data/probe/tests/ruby_outline_format_tests.rs +1011 -0
- package/data/probe/tests/rust_line_comment_context_test.rs +151 -0
- package/data/probe/tests/rust_outline_format_enhanced_tests.rs +725 -0
- package/data/probe/tests/rust_outline_format_tests.rs +843 -0
- package/data/probe/tests/schemas/xml_output_schema.xsd +38 -0
- package/data/probe/tests/search_determinism_tests.rs +451 -0
- package/data/probe/tests/search_hints_tests.rs +253 -0
- package/data/probe/tests/special_character_escaping_tests.rs +417 -0
- package/data/probe/tests/stemming_compound_word_filtering_tests.rs +535 -0
- package/data/probe/tests/strict_elastic_syntax_tests.rs +404 -0
- package/data/probe/tests/swift_outline_format_tests.rs +3319 -0
- package/data/probe/tests/symbols_tests.rs +166 -0
- package/data/probe/tests/test_file.rs +45 -0
- package/data/probe/tests/test_tokenize.rs +28 -0
- package/data/probe/tests/timeout_tests.rs +82 -0
- package/data/probe/tests/tokenization_tests.rs +195 -0
- package/data/probe/tests/tokenized_block_filtering_tests.rs +174 -0
- package/data/probe/tests/typescript_extract_tests.rs +214 -0
- package/data/probe/tests/typescript_outline_format_tests.rs +2188 -0
- package/data/probe/tests/xml_format_tests.rs +568 -0
- package/data/probe/tests/xml_schema_validation_tests.rs +497 -0
- package/data/scripts/postinstall.mjs +9 -0
- package/data/scripts/set-version.js +0 -0
- package/data/scripts/wiki-build.sh +111 -0
- package/data/scripts/wiki-deploy.sh +73 -0
- package/data/serve.json +12 -0
- package/data/test/demo-dynamic.html +134 -0
- package/data/test/demo-esm.html +105 -0
- package/data/test/demo-iife.html +78 -0
- package/data/tsconfig.json +7 -0
- package/data/vite.server.ts +483 -0
- package/data/vitest.config.ts +40 -0
- package/data/wiki/Home.md +58 -0
- package/data/wiki/_Sidebar.md +39 -0
- package/docs-mcp.config.json +20 -0
- package/package.json +56 -0
- package/src/config.js +111 -0
- package/src/index.js +395 -0
|
@@ -0,0 +1,1507 @@
|
|
|
1
|
+
use anyhow::Result;
|
|
2
|
+
use std::fs;
|
|
3
|
+
use tempfile::TempDir;
|
|
4
|
+
|
|
5
|
+
mod common;
|
|
6
|
+
use common::TestContext;
|
|
7
|
+
|
|
8
|
+
#[test]
|
|
9
|
+
fn test_cpp_outline_basic_symbols() -> Result<()> {
|
|
10
|
+
let temp_dir = TempDir::new()?;
|
|
11
|
+
let test_file = temp_dir.path().join("basic.cpp");
|
|
12
|
+
|
|
13
|
+
let content = r#"#include <iostream>
|
|
14
|
+
#include <vector>
|
|
15
|
+
#include <memory>
|
|
16
|
+
#include <string>
|
|
17
|
+
#include <algorithm>
|
|
18
|
+
|
|
19
|
+
// Namespace for calculator functionality
|
|
20
|
+
namespace calculator {
|
|
21
|
+
|
|
22
|
+
// Abstract base class
|
|
23
|
+
class CalculatorInterface {
|
|
24
|
+
public:
|
|
25
|
+
virtual ~CalculatorInterface() = default;
|
|
26
|
+
virtual double add(double x, double y) = 0;
|
|
27
|
+
virtual double subtract(double x, double y) = 0;
|
|
28
|
+
virtual double multiply(double x, double y) = 0;
|
|
29
|
+
virtual double divide(double x, double y) = 0;
|
|
30
|
+
virtual std::vector<double> getHistory() const = 0;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Template calculator class
|
|
34
|
+
template<typename T>
|
|
35
|
+
class Calculator : public CalculatorInterface {
|
|
36
|
+
private:
|
|
37
|
+
std::string name_;
|
|
38
|
+
std::vector<T> history_;
|
|
39
|
+
int precision_;
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
explicit Calculator(const std::string& name, int precision = 2)
|
|
43
|
+
: name_(name), precision_(precision) {}
|
|
44
|
+
|
|
45
|
+
virtual ~Calculator() override = default;
|
|
46
|
+
|
|
47
|
+
// Move constructor and assignment
|
|
48
|
+
Calculator(Calculator&& other) noexcept
|
|
49
|
+
: name_(std::move(other.name_))
|
|
50
|
+
, history_(std::move(other.history_))
|
|
51
|
+
, precision_(other.precision_) {}
|
|
52
|
+
|
|
53
|
+
Calculator& operator=(Calculator&& other) noexcept {
|
|
54
|
+
if (this != &other) {
|
|
55
|
+
name_ = std::move(other.name_);
|
|
56
|
+
history_ = std::move(other.history_);
|
|
57
|
+
precision_ = other.precision_;
|
|
58
|
+
}
|
|
59
|
+
return *this;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Arithmetic operations
|
|
63
|
+
double add(double x, double y) override {
|
|
64
|
+
T result = static_cast<T>(x + y);
|
|
65
|
+
recordOperation(result);
|
|
66
|
+
return static_cast<double>(result);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
double subtract(double x, double y) override {
|
|
70
|
+
T result = static_cast<T>(x - y);
|
|
71
|
+
recordOperation(result);
|
|
72
|
+
return static_cast<double>(result);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
double multiply(double x, double y) override {
|
|
76
|
+
T result = static_cast<T>(x * y);
|
|
77
|
+
recordOperation(result);
|
|
78
|
+
return static_cast<double>(result);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
double divide(double x, double y) override {
|
|
82
|
+
if (y == 0) {
|
|
83
|
+
throw std::runtime_error("Division by zero");
|
|
84
|
+
}
|
|
85
|
+
T result = static_cast<T>(x / y);
|
|
86
|
+
recordOperation(result);
|
|
87
|
+
return static_cast<double>(result);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
std::vector<double> getHistory() const override {
|
|
91
|
+
std::vector<double> result;
|
|
92
|
+
result.reserve(history_.size());
|
|
93
|
+
std::transform(history_.begin(), history_.end(),
|
|
94
|
+
std::back_inserter(result),
|
|
95
|
+
[](const T& val) { return static_cast<double>(val); });
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Template member function
|
|
100
|
+
template<typename U>
|
|
101
|
+
auto process(const std::vector<U>& data) -> std::vector<decltype(T{} + U{})> {
|
|
102
|
+
std::vector<decltype(T{} + U{})> results;
|
|
103
|
+
for (const auto& item : data) {
|
|
104
|
+
results.push_back(static_cast<T>(item));
|
|
105
|
+
}
|
|
106
|
+
return results;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private:
|
|
110
|
+
void recordOperation(const T& result) {
|
|
111
|
+
history_.push_back(result);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// Factory function
|
|
116
|
+
template<typename T>
|
|
117
|
+
std::unique_ptr<Calculator<T>> createCalculator(const std::string& name, int precision = 2) {
|
|
118
|
+
return std::make_unique<Calculator<T>>(name, precision);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Specialized template for floating point
|
|
122
|
+
template<>
|
|
123
|
+
class Calculator<float> : public CalculatorInterface {
|
|
124
|
+
private:
|
|
125
|
+
std::string name_;
|
|
126
|
+
std::vector<float> history_;
|
|
127
|
+
int precision_;
|
|
128
|
+
|
|
129
|
+
public:
|
|
130
|
+
explicit Calculator(const std::string& name, int precision = 2)
|
|
131
|
+
: name_(name), precision_(precision) {}
|
|
132
|
+
|
|
133
|
+
double add(double x, double y) override {
|
|
134
|
+
float result = static_cast<float>(x + y);
|
|
135
|
+
history_.push_back(result);
|
|
136
|
+
return static_cast<double>(result);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
double subtract(double x, double y) override {
|
|
140
|
+
float result = static_cast<float>(x - y);
|
|
141
|
+
history_.push_back(result);
|
|
142
|
+
return static_cast<double>(result);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
double multiply(double x, double y) override {
|
|
146
|
+
float result = static_cast<float>(x * y);
|
|
147
|
+
history_.push_back(result);
|
|
148
|
+
return static_cast<double>(result);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
double divide(double x, double y) override {
|
|
152
|
+
if (y == 0) throw std::runtime_error("Division by zero");
|
|
153
|
+
float result = static_cast<float>(x / y);
|
|
154
|
+
history_.push_back(result);
|
|
155
|
+
return static_cast<double>(result);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
std::vector<double> getHistory() const override {
|
|
159
|
+
return std::vector<double>(history_.begin(), history_.end());
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
} // namespace calculator
|
|
164
|
+
|
|
165
|
+
// Global function outside namespace
|
|
166
|
+
std::unique_ptr<calculator::CalculatorInterface> createDefaultCalculator() {
|
|
167
|
+
return calculator::createCalculator<double>("Default Calculator");
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
int main() {
|
|
171
|
+
auto calc = calculator::createCalculator<double>("Test Calculator");
|
|
172
|
+
|
|
173
|
+
try {
|
|
174
|
+
double result = calc->add(10.5, 20.3);
|
|
175
|
+
std::cout << "Result: " << result << std::endl;
|
|
176
|
+
} catch (const std::exception& e) {
|
|
177
|
+
std::cerr << "Error: " << e.what() << std::endl;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return 0;
|
|
181
|
+
}
|
|
182
|
+
"#;
|
|
183
|
+
|
|
184
|
+
fs::write(&test_file, content)?;
|
|
185
|
+
|
|
186
|
+
let ctx = TestContext::new();
|
|
187
|
+
let output = ctx.run_probe(&[
|
|
188
|
+
"search",
|
|
189
|
+
"Calculator", // Search for Calculator classes
|
|
190
|
+
test_file.to_str().unwrap(),
|
|
191
|
+
"--format",
|
|
192
|
+
"outline",
|
|
193
|
+
])?;
|
|
194
|
+
|
|
195
|
+
// Verify C++ symbols are extracted
|
|
196
|
+
assert!(
|
|
197
|
+
output.contains("namespace calculator") || output.contains("class CalculatorInterface"),
|
|
198
|
+
"Missing C++ namespace or class - output: {}",
|
|
199
|
+
output
|
|
200
|
+
);
|
|
201
|
+
assert!(
|
|
202
|
+
output.contains("class Calculator") || output.contains("template"),
|
|
203
|
+
"Missing template class - output: {}",
|
|
204
|
+
output
|
|
205
|
+
);
|
|
206
|
+
assert!(
|
|
207
|
+
output.contains("createCalculator") || output.contains("createDefaultCalculator"),
|
|
208
|
+
"Missing factory functions - output: {}",
|
|
209
|
+
output
|
|
210
|
+
);
|
|
211
|
+
// The output should contain substantial C++ code structures
|
|
212
|
+
assert!(
|
|
213
|
+
output.len() > 800, // Should contain significant C++ code
|
|
214
|
+
"Should contain substantial C++ code - output length: {}, output: {}",
|
|
215
|
+
output.len(),
|
|
216
|
+
output
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
Ok(())
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
#[test]
|
|
223
|
+
fn test_cpp_outline_stl_and_templates() -> Result<()> {
|
|
224
|
+
let temp_dir = TempDir::new()?;
|
|
225
|
+
let test_file = temp_dir.path().join("templates.cpp");
|
|
226
|
+
|
|
227
|
+
let content = r#"#include <vector>
|
|
228
|
+
#include <map>
|
|
229
|
+
#include <algorithm>
|
|
230
|
+
#include <memory>
|
|
231
|
+
#include <functional>
|
|
232
|
+
#include <type_traits>
|
|
233
|
+
|
|
234
|
+
// Advanced template metaprogramming
|
|
235
|
+
template<typename T, typename Enable = void>
|
|
236
|
+
struct TypeTraits {
|
|
237
|
+
static constexpr bool is_numeric = false;
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
template<typename T>
|
|
241
|
+
struct TypeTraits<T, std::enable_if_t<std::is_arithmetic_v<T>>> {
|
|
242
|
+
static constexpr bool is_numeric = true;
|
|
243
|
+
using value_type = T;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
// SFINAE template functions
|
|
247
|
+
template<typename T>
|
|
248
|
+
std::enable_if_t<std::is_integral_v<T>, T> processInteger(T value) {
|
|
249
|
+
return value * 2;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
template<typename T>
|
|
253
|
+
std::enable_if_t<std::is_floating_point_v<T>, T> processFloat(T value) {
|
|
254
|
+
return value * 1.5;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Variadic template class
|
|
258
|
+
template<typename... Args>
|
|
259
|
+
class DataContainer {
|
|
260
|
+
private:
|
|
261
|
+
std::tuple<Args...> data_;
|
|
262
|
+
|
|
263
|
+
public:
|
|
264
|
+
explicit DataContainer(Args... args) : data_(std::make_tuple(args...)) {}
|
|
265
|
+
|
|
266
|
+
template<size_t Index>
|
|
267
|
+
auto get() const -> std::tuple_element_t<Index, std::tuple<Args...>> {
|
|
268
|
+
return std::get<Index>(data_);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
template<typename F>
|
|
272
|
+
void forEach(F&& func) {
|
|
273
|
+
forEachImpl(std::forward<F>(func), std::index_sequence_for<Args...>{});
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
private:
|
|
277
|
+
template<typename F, size_t... Indices>
|
|
278
|
+
void forEachImpl(F&& func, std::index_sequence<Indices...>) {
|
|
279
|
+
(func(std::get<Indices>(data_)), ...);
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
// Template specialization
|
|
284
|
+
template<>
|
|
285
|
+
class DataContainer<std::string> {
|
|
286
|
+
private:
|
|
287
|
+
std::vector<std::string> strings_;
|
|
288
|
+
|
|
289
|
+
public:
|
|
290
|
+
explicit DataContainer(const std::string& str) : strings_{str} {}
|
|
291
|
+
|
|
292
|
+
void addString(const std::string& str) {
|
|
293
|
+
strings_.push_back(str);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const std::vector<std::string>& getStrings() const {
|
|
297
|
+
return strings_;
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
// CRTP pattern
|
|
302
|
+
template<typename Derived>
|
|
303
|
+
class Printable {
|
|
304
|
+
public:
|
|
305
|
+
void print() const {
|
|
306
|
+
static_cast<const Derived*>(this)->printImpl();
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
protected:
|
|
310
|
+
~Printable() = default;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
class Document : public Printable<Document> {
|
|
314
|
+
private:
|
|
315
|
+
std::string content_;
|
|
316
|
+
|
|
317
|
+
public:
|
|
318
|
+
explicit Document(const std::string& content) : content_(content) {}
|
|
319
|
+
|
|
320
|
+
void printImpl() const {
|
|
321
|
+
std::cout << "Document: " << content_ << std::endl;
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
// Lambda and functional programming support
|
|
326
|
+
template<typename Container, typename Predicate>
|
|
327
|
+
auto filterContainer(const Container& container, Predicate pred) {
|
|
328
|
+
Container result;
|
|
329
|
+
std::copy_if(container.begin(), container.end(),
|
|
330
|
+
std::back_inserter(result), pred);
|
|
331
|
+
return result;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Advanced template with concept-like requirements (C++17 style)
|
|
335
|
+
template<typename T>
|
|
336
|
+
class SmartProcessor {
|
|
337
|
+
static_assert(std::is_default_constructible_v<T>, "T must be default constructible");
|
|
338
|
+
static_assert(std::is_copy_constructible_v<T>, "T must be copy constructible");
|
|
339
|
+
|
|
340
|
+
private:
|
|
341
|
+
std::vector<T> items_;
|
|
342
|
+
std::function<T(const T&)> processor_;
|
|
343
|
+
|
|
344
|
+
public:
|
|
345
|
+
template<typename Processor>
|
|
346
|
+
SmartProcessor(Processor&& proc) : processor_(std::forward<Processor>(proc)) {}
|
|
347
|
+
|
|
348
|
+
void addItem(const T& item) {
|
|
349
|
+
items_.push_back(item);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
std::vector<T> processAll() const {
|
|
353
|
+
std::vector<T> results;
|
|
354
|
+
results.reserve(items_.size());
|
|
355
|
+
|
|
356
|
+
std::transform(items_.begin(), items_.end(),
|
|
357
|
+
std::back_inserter(results),
|
|
358
|
+
processor_);
|
|
359
|
+
|
|
360
|
+
return results;
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
int main() {
|
|
365
|
+
// Test variadic template
|
|
366
|
+
DataContainer<int, double, std::string> container(42, 3.14, "Hello");
|
|
367
|
+
std::cout << "First: " << container.get<0>() << std::endl;
|
|
368
|
+
|
|
369
|
+
// Test CRTP
|
|
370
|
+
Document doc("Sample document");
|
|
371
|
+
doc.print();
|
|
372
|
+
|
|
373
|
+
// Test smart processor
|
|
374
|
+
SmartProcessor<int> processor([](int x) { return x * x; });
|
|
375
|
+
processor.addItem(5);
|
|
376
|
+
processor.addItem(10);
|
|
377
|
+
|
|
378
|
+
auto results = processor.processAll();
|
|
379
|
+
for (const auto& result : results) {
|
|
380
|
+
std::cout << result << " ";
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
return 0;
|
|
384
|
+
}
|
|
385
|
+
"#;
|
|
386
|
+
|
|
387
|
+
fs::write(&test_file, content)?;
|
|
388
|
+
|
|
389
|
+
let ctx = TestContext::new();
|
|
390
|
+
let output = ctx.run_probe(&[
|
|
391
|
+
"search",
|
|
392
|
+
"DataContainer", // Search for template classes
|
|
393
|
+
test_file.to_str().unwrap(),
|
|
394
|
+
"--format",
|
|
395
|
+
"outline",
|
|
396
|
+
])?;
|
|
397
|
+
|
|
398
|
+
// Verify C++ template features
|
|
399
|
+
assert!(
|
|
400
|
+
output.contains("template") || output.contains("struct TypeTraits"),
|
|
401
|
+
"Missing template structures - output: {}",
|
|
402
|
+
output
|
|
403
|
+
);
|
|
404
|
+
assert!(
|
|
405
|
+
output.contains("class DataContainer"),
|
|
406
|
+
"Missing variadic template class - output: {}",
|
|
407
|
+
output
|
|
408
|
+
);
|
|
409
|
+
// The search results show various template patterns even if not all classes are included
|
|
410
|
+
assert!(
|
|
411
|
+
output.len() > 500, // Should have substantial template-related content
|
|
412
|
+
"Should contain substantial template code - output length: {}, output: {}",
|
|
413
|
+
output.len(),
|
|
414
|
+
output
|
|
415
|
+
);
|
|
416
|
+
|
|
417
|
+
Ok(())
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
#[test]
|
|
421
|
+
fn test_cpp_outline_smart_closing_brace_comments() -> Result<()> {
|
|
422
|
+
let temp_dir = TempDir::new()?;
|
|
423
|
+
let test_file = temp_dir.path().join("smart_braces.cpp");
|
|
424
|
+
|
|
425
|
+
let content = r#"// Small function that should NOT get closing brace comments.
|
|
426
|
+
int small_function(int x) {
|
|
427
|
+
int result = x * 2;
|
|
428
|
+
return result + 1;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// Large function that SHOULD get closing brace comments with C++ // syntax.
|
|
432
|
+
std::vector<std::string> large_function_with_gaps(const std::vector<int>& data) {
|
|
433
|
+
std::vector<std::string> results;
|
|
434
|
+
DataProcessor processor;
|
|
435
|
+
|
|
436
|
+
// Phase 1: Initial processing with nested control flow
|
|
437
|
+
for (size_t i = 0; i < data.size(); ++i) {
|
|
438
|
+
if (data[i] > 100) {
|
|
439
|
+
processor.processLargeValue(data[i], i);
|
|
440
|
+
if (data[i] > 1000) {
|
|
441
|
+
processor.markAsExceptional(i);
|
|
442
|
+
}
|
|
443
|
+
} else if (data[i] < 0) {
|
|
444
|
+
processor.processNegativeValue(data[i], i);
|
|
445
|
+
} else {
|
|
446
|
+
processor.processSmallValue(data[i], i);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// Phase 2: Complex transformation logic with switch
|
|
451
|
+
auto transformedData = processor.getTransformedData();
|
|
452
|
+
for (const auto& item : transformedData) {
|
|
453
|
+
switch (item.category) {
|
|
454
|
+
case Category::HIGH:
|
|
455
|
+
results.push_back("HIGH: " + std::to_string(item.value));
|
|
456
|
+
break;
|
|
457
|
+
case Category::MEDIUM:
|
|
458
|
+
results.push_back("MED: " + std::to_string(item.value));
|
|
459
|
+
break;
|
|
460
|
+
case Category::LOW:
|
|
461
|
+
results.push_back("LOW: " + std::to_string(item.value));
|
|
462
|
+
break;
|
|
463
|
+
default:
|
|
464
|
+
results.push_back("UNKNOWN: " + std::to_string(item.value));
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// Phase 3: Final validation and cleanup with try-catch
|
|
470
|
+
std::vector<std::string> validatedResults;
|
|
471
|
+
for (const auto& result : results) {
|
|
472
|
+
try {
|
|
473
|
+
if (result.length() > 5) {
|
|
474
|
+
validatedResults.push_back(result);
|
|
475
|
+
}
|
|
476
|
+
} catch (const std::exception& e) {
|
|
477
|
+
std::cerr << "Error processing result: " << e.what() << std::endl;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
return validatedResults;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// Another large C++ class with RAII and modern features
|
|
485
|
+
class LargeResourceManager {
|
|
486
|
+
private:
|
|
487
|
+
std::unique_ptr<Resource> resource_;
|
|
488
|
+
std::shared_ptr<SharedData> shared_data_;
|
|
489
|
+
mutable std::mutex mutex_;
|
|
490
|
+
std::atomic<bool> active_;
|
|
491
|
+
|
|
492
|
+
public:
|
|
493
|
+
explicit LargeResourceManager(std::unique_ptr<Resource> resource)
|
|
494
|
+
: resource_(std::move(resource))
|
|
495
|
+
, shared_data_(std::make_shared<SharedData>())
|
|
496
|
+
, active_(true) {}
|
|
497
|
+
|
|
498
|
+
~LargeResourceManager() {
|
|
499
|
+
cleanup();
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// Move semantics
|
|
503
|
+
LargeResourceManager(LargeResourceManager&& other) noexcept
|
|
504
|
+
: resource_(std::move(other.resource_))
|
|
505
|
+
, shared_data_(std::move(other.shared_data_))
|
|
506
|
+
, active_(other.active_.load()) {
|
|
507
|
+
other.active_ = false;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
auto processData(const std::vector<DataItem>& items) -> std::future<ProcessResult> {
|
|
511
|
+
return std::async(std::launch::async, [this, items]() {
|
|
512
|
+
std::lock_guard<std::mutex> lock(mutex_);
|
|
513
|
+
ProcessResult result;
|
|
514
|
+
|
|
515
|
+
for (const auto& item : items) {
|
|
516
|
+
if (!active_.load()) {
|
|
517
|
+
break;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
try {
|
|
521
|
+
auto processed = resource_->process(item);
|
|
522
|
+
result.addItem(processed);
|
|
523
|
+
} catch (const ProcessingException& e) {
|
|
524
|
+
result.addError(e.what());
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
return result;
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
private:
|
|
533
|
+
void cleanup() {
|
|
534
|
+
if (resource_) {
|
|
535
|
+
resource_->cleanup();
|
|
536
|
+
}
|
|
537
|
+
active_ = false;
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
"#;
|
|
541
|
+
|
|
542
|
+
fs::write(&test_file, content)?;
|
|
543
|
+
|
|
544
|
+
let ctx = TestContext::new();
|
|
545
|
+
let output = ctx.run_probe(&[
|
|
546
|
+
"search",
|
|
547
|
+
"large_function", // Search for large functions
|
|
548
|
+
test_file.to_str().unwrap(),
|
|
549
|
+
"--format",
|
|
550
|
+
"outline",
|
|
551
|
+
])?;
|
|
552
|
+
|
|
553
|
+
// Should find the large functions and classes
|
|
554
|
+
assert!(
|
|
555
|
+
output.contains("large_function_with_gaps") || output.contains("LargeResourceManager"),
|
|
556
|
+
"Missing large function or class - output: {}",
|
|
557
|
+
output
|
|
558
|
+
);
|
|
559
|
+
|
|
560
|
+
// Large functions/classes should have closing brace comments with C++ // syntax
|
|
561
|
+
// Look for lines ending with "} // " (C++ style comments)
|
|
562
|
+
let cpp_closing_comments: Vec<&str> = output
|
|
563
|
+
.lines()
|
|
564
|
+
.filter(|line| line.contains("} //"))
|
|
565
|
+
.collect();
|
|
566
|
+
|
|
567
|
+
assert!(
|
|
568
|
+
!cpp_closing_comments.is_empty(),
|
|
569
|
+
"Large C++ functions should have closing brace comments with // syntax. Output:\n{}",
|
|
570
|
+
output
|
|
571
|
+
);
|
|
572
|
+
|
|
573
|
+
// Large functions/classes should have closing brace comments with C++ // syntax
|
|
574
|
+
// The main function we're testing should have closing brace comments
|
|
575
|
+
assert!(
|
|
576
|
+
!cpp_closing_comments.is_empty(),
|
|
577
|
+
"Should have at least one closing brace comment for large C++ functions. Found: {}. Output:\n{}",
|
|
578
|
+
cpp_closing_comments.len(),
|
|
579
|
+
output
|
|
580
|
+
);
|
|
581
|
+
|
|
582
|
+
// Verify the closing brace comments use C++ style (//) not C style (/* */)
|
|
583
|
+
let has_cpp_style_comments = output.contains("} //") && !output.contains("} /*");
|
|
584
|
+
assert!(
|
|
585
|
+
has_cpp_style_comments,
|
|
586
|
+
"Closing brace comments should use C++ style (//) not C style (/* */). Output:\n{}",
|
|
587
|
+
output
|
|
588
|
+
);
|
|
589
|
+
|
|
590
|
+
Ok(())
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
#[test]
|
|
594
|
+
fn test_cpp_control_flow_structures() -> Result<()> {
|
|
595
|
+
let temp_dir = TempDir::new()?;
|
|
596
|
+
let test_file = temp_dir.path().join("control_flow.cpp");
|
|
597
|
+
|
|
598
|
+
let content = r#"#include <iostream>
|
|
599
|
+
#include <vector>
|
|
600
|
+
#include <algorithm>
|
|
601
|
+
#include <exception>
|
|
602
|
+
|
|
603
|
+
// Function with comprehensive C++ control flow
|
|
604
|
+
void processControlFlow(const std::vector<int>& data) {
|
|
605
|
+
// Traditional for loop
|
|
606
|
+
for (int i = 0; i < static_cast<int>(data.size()); ++i) {
|
|
607
|
+
if (data[i] > 100) {
|
|
608
|
+
std::cout << "Large value: " << data[i] << std::endl;
|
|
609
|
+
} else if (data[i] < 0) {
|
|
610
|
+
std::cout << "Negative value: " << data[i] << std::endl;
|
|
611
|
+
} else {
|
|
612
|
+
std::cout << "Normal value: " << data[i] << std::endl;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
// Range-based for loop (C++11)
|
|
617
|
+
for (const auto& value : data) {
|
|
618
|
+
switch (value % 3) {
|
|
619
|
+
case 0:
|
|
620
|
+
std::cout << "Divisible by 3" << std::endl;
|
|
621
|
+
break;
|
|
622
|
+
case 1:
|
|
623
|
+
std::cout << "Remainder 1" << std::endl;
|
|
624
|
+
break;
|
|
625
|
+
case 2:
|
|
626
|
+
std::cout << "Remainder 2" << std::endl;
|
|
627
|
+
break;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// While loop with exception handling
|
|
632
|
+
int index = 0;
|
|
633
|
+
while (index < static_cast<int>(data.size())) {
|
|
634
|
+
try {
|
|
635
|
+
if (data[index] == 0) {
|
|
636
|
+
throw std::runtime_error("Zero value encountered");
|
|
637
|
+
}
|
|
638
|
+
processValue(data[index]);
|
|
639
|
+
} catch (const std::runtime_error& e) {
|
|
640
|
+
std::cerr << "Runtime error: " << e.what() << std::endl;
|
|
641
|
+
} catch (const std::exception& e) {
|
|
642
|
+
std::cerr << "General error: " << e.what() << std::endl;
|
|
643
|
+
} catch (...) {
|
|
644
|
+
std::cerr << "Unknown error occurred" << std::endl;
|
|
645
|
+
}
|
|
646
|
+
++index;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
// Do-while loop
|
|
650
|
+
int attempts = 0;
|
|
651
|
+
do {
|
|
652
|
+
attempts++;
|
|
653
|
+
std::cout << "Attempt: " << attempts << std::endl;
|
|
654
|
+
} while (attempts < 3);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// Function with nested control structures
|
|
658
|
+
int complexNestedControl(const std::vector<std::vector<int>>& matrix) {
|
|
659
|
+
int result = 0;
|
|
660
|
+
|
|
661
|
+
for (size_t row = 0; row < matrix.size(); ++row) {
|
|
662
|
+
for (size_t col = 0; col < matrix[row].size(); ++col) {
|
|
663
|
+
if (matrix[row][col] > 0) {
|
|
664
|
+
switch (matrix[row][col] % 4) {
|
|
665
|
+
case 0:
|
|
666
|
+
result += matrix[row][col] * 2;
|
|
667
|
+
break;
|
|
668
|
+
case 1:
|
|
669
|
+
result += matrix[row][col];
|
|
670
|
+
break;
|
|
671
|
+
case 2: {
|
|
672
|
+
int temp = matrix[row][col];
|
|
673
|
+
while (temp > 10) {
|
|
674
|
+
temp /= 2;
|
|
675
|
+
}
|
|
676
|
+
result += temp;
|
|
677
|
+
break;
|
|
678
|
+
}
|
|
679
|
+
default:
|
|
680
|
+
result -= matrix[row][col];
|
|
681
|
+
break;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
return result;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
private:
|
|
691
|
+
void processValue(int value) {
|
|
692
|
+
// Simple processing
|
|
693
|
+
std::cout << "Processing: " << value << std::endl;
|
|
694
|
+
}
|
|
695
|
+
"#;
|
|
696
|
+
|
|
697
|
+
fs::write(&test_file, content)?;
|
|
698
|
+
|
|
699
|
+
let ctx = TestContext::new();
|
|
700
|
+
let output = ctx.run_probe(&[
|
|
701
|
+
"search",
|
|
702
|
+
"processControlFlow", // Search for control flow function
|
|
703
|
+
test_file.to_str().unwrap(),
|
|
704
|
+
"--format",
|
|
705
|
+
"outline",
|
|
706
|
+
])?;
|
|
707
|
+
|
|
708
|
+
// Should find the control flow function
|
|
709
|
+
assert!(
|
|
710
|
+
output.contains("processControlFlow"),
|
|
711
|
+
"Should contain processControlFlow function - output: {}",
|
|
712
|
+
output
|
|
713
|
+
);
|
|
714
|
+
|
|
715
|
+
// Should show function with closing brace comment
|
|
716
|
+
assert!(
|
|
717
|
+
output.contains("} //") || output.contains("..."),
|
|
718
|
+
"Should contain closing brace comment or truncation for control flow function - output: {}",
|
|
719
|
+
output
|
|
720
|
+
);
|
|
721
|
+
|
|
722
|
+
Ok(())
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
#[test]
|
|
726
|
+
fn test_cpp_modern_features_and_lambdas() -> Result<()> {
|
|
727
|
+
let temp_dir = TempDir::new()?;
|
|
728
|
+
let test_file = temp_dir.path().join("modern_cpp.cpp");
|
|
729
|
+
|
|
730
|
+
let content = r#"#include <iostream>
|
|
731
|
+
#include <vector>
|
|
732
|
+
#include <algorithm>
|
|
733
|
+
#include <memory>
|
|
734
|
+
#include <functional>
|
|
735
|
+
#include <type_traits>
|
|
736
|
+
|
|
737
|
+
// Modern C++ features demonstration
|
|
738
|
+
class ModernCppFeatures {
|
|
739
|
+
public:
|
|
740
|
+
// Auto type deduction
|
|
741
|
+
auto processData(const std::vector<int>& data) -> std::vector<std::string> {
|
|
742
|
+
std::vector<std::string> results;
|
|
743
|
+
results.reserve(data.size());
|
|
744
|
+
|
|
745
|
+
// Lambda with capture
|
|
746
|
+
auto formatter = [](int value) -> std::string {
|
|
747
|
+
if constexpr (std::is_integral_v<int>) {
|
|
748
|
+
return std::to_string(value * 2);
|
|
749
|
+
} else {
|
|
750
|
+
return "non-integral";
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
|
|
754
|
+
// Range-based for with auto
|
|
755
|
+
for (const auto& item : data) {
|
|
756
|
+
auto formatted = formatter(item);
|
|
757
|
+
results.push_back(formatted);
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
return results;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// Constexpr function (C++11)
|
|
764
|
+
constexpr int fibonacci(int n) {
|
|
765
|
+
if (n <= 1) return n;
|
|
766
|
+
return fibonacci(n - 1) + fibonacci(n - 2);
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
// Template with auto return type deduction (C++14)
|
|
770
|
+
template<typename T, typename U>
|
|
771
|
+
auto multiply(T a, U b) -> decltype(a * b) {
|
|
772
|
+
return a * b;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
// Smart pointer usage with RAII
|
|
776
|
+
std::unique_ptr<Resource> createResource(const std::string& name) {
|
|
777
|
+
auto resource = std::make_unique<Resource>(name);
|
|
778
|
+
|
|
779
|
+
// Complex lambda with multiple captures
|
|
780
|
+
auto initializer = [&resource, name](int complexity) mutable {
|
|
781
|
+
if (complexity > 10) {
|
|
782
|
+
resource->setComplexMode(true);
|
|
783
|
+
resource->allocateBuffers(complexity * 1024);
|
|
784
|
+
} else {
|
|
785
|
+
resource->setSimpleMode();
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// Nested lambda
|
|
789
|
+
auto logger = [name](const std::string& message) {
|
|
790
|
+
std::cout << "[" << name << "] " << message << std::endl;
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
logger("Resource initialized");
|
|
794
|
+
};
|
|
795
|
+
|
|
796
|
+
initializer(15);
|
|
797
|
+
return resource;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
// Variadic template with perfect forwarding (C++11)
|
|
801
|
+
template<typename... Args>
|
|
802
|
+
auto createSharedResource(Args&&... args) -> std::shared_ptr<Resource> {
|
|
803
|
+
return std::make_shared<Resource>(std::forward<Args>(args)...);
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
// Generic lambda (C++14)
|
|
807
|
+
void processGeneric() {
|
|
808
|
+
auto genericProcessor = [](auto&& item) {
|
|
809
|
+
using T = std::decay_t<decltype(item)>;
|
|
810
|
+
if constexpr (std::is_arithmetic_v<T>) {
|
|
811
|
+
return item * 2;
|
|
812
|
+
} else {
|
|
813
|
+
return item;
|
|
814
|
+
}
|
|
815
|
+
};
|
|
816
|
+
|
|
817
|
+
auto result1 = genericProcessor(42);
|
|
818
|
+
auto result2 = genericProcessor(3.14);
|
|
819
|
+
auto result3 = genericProcessor(std::string("hello"));
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
|
|
823
|
+
// C++17 features
|
|
824
|
+
class Cpp17Features {
|
|
825
|
+
public:
|
|
826
|
+
// Structured bindings (C++17)
|
|
827
|
+
auto getCoordinates() -> std::tuple<int, int, int> {
|
|
828
|
+
return {10, 20, 30};
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
void useStructuredBindings() {
|
|
832
|
+
auto [x, y, z] = getCoordinates();
|
|
833
|
+
std::cout << "Coordinates: " << x << ", " << y << ", " << z << std::endl;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
// If constexpr (C++17)
|
|
837
|
+
template<typename T>
|
|
838
|
+
void processType() {
|
|
839
|
+
if constexpr (std::is_integral_v<T>) {
|
|
840
|
+
std::cout << "Processing integer type" << std::endl;
|
|
841
|
+
} else if constexpr (std::is_floating_point_v<T>) {
|
|
842
|
+
std::cout << "Processing floating point type" << std::endl;
|
|
843
|
+
} else {
|
|
844
|
+
std::cout << "Processing other type" << std::endl;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
|
|
849
|
+
int main() {
|
|
850
|
+
ModernCppFeatures modern;
|
|
851
|
+
std::vector<int> data{1, 2, 3, 4, 5};
|
|
852
|
+
|
|
853
|
+
auto results = modern.processData(data);
|
|
854
|
+
for (const auto& result : results) {
|
|
855
|
+
std::cout << result << " ";
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
return 0;
|
|
859
|
+
}
|
|
860
|
+
"#;
|
|
861
|
+
|
|
862
|
+
fs::write(&test_file, content)?;
|
|
863
|
+
|
|
864
|
+
let ctx = TestContext::new();
|
|
865
|
+
let output = ctx.run_probe(&[
|
|
866
|
+
"search",
|
|
867
|
+
"auto", // Search for modern C++ features
|
|
868
|
+
test_file.to_str().unwrap(),
|
|
869
|
+
"--format",
|
|
870
|
+
"outline",
|
|
871
|
+
])?;
|
|
872
|
+
|
|
873
|
+
// Should contain modern C++ features
|
|
874
|
+
assert!(
|
|
875
|
+
output.contains("auto") || output.contains("lambda") || output.contains("constexpr"),
|
|
876
|
+
"Should contain modern C++ features - output: {}",
|
|
877
|
+
output
|
|
878
|
+
);
|
|
879
|
+
|
|
880
|
+
// Should contain lambda expressions
|
|
881
|
+
assert!(
|
|
882
|
+
output.contains("[") && output.contains("]"),
|
|
883
|
+
"Should contain lambda capture syntax - output: {}",
|
|
884
|
+
output
|
|
885
|
+
);
|
|
886
|
+
|
|
887
|
+
// Should show template structures
|
|
888
|
+
assert!(
|
|
889
|
+
output.contains("template"),
|
|
890
|
+
"Should contain template definitions - output: {}",
|
|
891
|
+
output
|
|
892
|
+
);
|
|
893
|
+
|
|
894
|
+
Ok(())
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
#[test]
|
|
898
|
+
fn test_cpp_test_framework_detection() -> Result<()> {
|
|
899
|
+
let temp_dir = TempDir::new()?;
|
|
900
|
+
let test_file = temp_dir.path().join("tests.cpp");
|
|
901
|
+
|
|
902
|
+
let content = r#"// Google Test framework
|
|
903
|
+
#include <gtest/gtest.h>
|
|
904
|
+
#include <gmock/gmock.h>
|
|
905
|
+
|
|
906
|
+
class CalculatorTest : public ::testing::Test {
|
|
907
|
+
protected:
|
|
908
|
+
void SetUp() override {
|
|
909
|
+
calculator = std::make_unique<Calculator>();
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
void TearDown() override {
|
|
913
|
+
calculator.reset();
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
std::unique_ptr<Calculator> calculator;
|
|
917
|
+
};
|
|
918
|
+
|
|
919
|
+
TEST_F(CalculatorTest, Addition) {
|
|
920
|
+
EXPECT_EQ(calculator->add(2, 3), 5);
|
|
921
|
+
EXPECT_EQ(calculator->add(-1, 1), 0);
|
|
922
|
+
EXPECT_EQ(calculator->add(0, 0), 0);
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
TEST_F(CalculatorTest, Division) {
|
|
926
|
+
EXPECT_EQ(calculator->divide(10, 2), 5);
|
|
927
|
+
EXPECT_THROW(calculator->divide(10, 0), std::runtime_error);
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
// Parameterized tests
|
|
931
|
+
class ParameterizedCalculatorTest : public ::testing::TestWithParam<std::tuple<int, int, int>> {
|
|
932
|
+
};
|
|
933
|
+
|
|
934
|
+
TEST_P(ParameterizedCalculatorTest, AdditionParameterized) {
|
|
935
|
+
auto [a, b, expected] = GetParam();
|
|
936
|
+
Calculator calc;
|
|
937
|
+
EXPECT_EQ(calc.add(a, b), expected);
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
INSTANTIATE_TEST_SUITE_P(
|
|
941
|
+
AdditionTests,
|
|
942
|
+
ParameterizedCalculatorTest,
|
|
943
|
+
::testing::Values(
|
|
944
|
+
std::make_tuple(1, 2, 3),
|
|
945
|
+
std::make_tuple(0, 0, 0),
|
|
946
|
+
std::make_tuple(-1, 1, 0)
|
|
947
|
+
)
|
|
948
|
+
);
|
|
949
|
+
|
|
950
|
+
// Mock object testing
|
|
951
|
+
class MockDataSource : public DataSourceInterface {
|
|
952
|
+
public:
|
|
953
|
+
MOCK_METHOD(std::vector<int>, getData, (), (override));
|
|
954
|
+
MOCK_METHOD(void, saveData, (const std::vector<int>&), (override));
|
|
955
|
+
};
|
|
956
|
+
|
|
957
|
+
TEST(MockTest, DataProcessing) {
|
|
958
|
+
MockDataSource mockSource;
|
|
959
|
+
DataProcessor processor(&mockSource);
|
|
960
|
+
|
|
961
|
+
std::vector<int> testData{1, 2, 3, 4, 5};
|
|
962
|
+
|
|
963
|
+
EXPECT_CALL(mockSource, getData())
|
|
964
|
+
.WillOnce(::testing::Return(testData));
|
|
965
|
+
|
|
966
|
+
EXPECT_CALL(mockSource, saveData(::testing::_))
|
|
967
|
+
.Times(1);
|
|
968
|
+
|
|
969
|
+
processor.processAndSave();
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
// Simple assert-based tests
|
|
973
|
+
void testBasicFunctionality() {
|
|
974
|
+
Calculator calc;
|
|
975
|
+
|
|
976
|
+
// Basic assertions
|
|
977
|
+
assert(calc.add(2, 3) == 5);
|
|
978
|
+
assert(calc.subtract(5, 3) == 2);
|
|
979
|
+
assert(calc.multiply(4, 3) == 12);
|
|
980
|
+
|
|
981
|
+
// Test division by zero
|
|
982
|
+
try {
|
|
983
|
+
calc.divide(10, 0);
|
|
984
|
+
assert(false); // Should not reach here
|
|
985
|
+
} catch (const std::runtime_error& e) {
|
|
986
|
+
assert(std::string(e.what()).find("zero") != std::string::npos);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
// Catch2 style tests
|
|
991
|
+
#include <catch2/catch.hpp>
|
|
992
|
+
|
|
993
|
+
TEST_CASE("Calculator basic operations", "[calculator]") {
|
|
994
|
+
Calculator calc;
|
|
995
|
+
|
|
996
|
+
SECTION("Addition") {
|
|
997
|
+
REQUIRE(calc.add(2, 3) == 5);
|
|
998
|
+
REQUIRE(calc.add(-1, 1) == 0);
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
SECTION("Division") {
|
|
1002
|
+
REQUIRE(calc.divide(10, 2) == 5);
|
|
1003
|
+
REQUIRE_THROWS_AS(calc.divide(10, 0), std::runtime_error);
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
TEST_CASE("Vector operations", "[vector]") {
|
|
1008
|
+
std::vector<int> v{1, 2, 3};
|
|
1009
|
+
|
|
1010
|
+
REQUIRE(v.size() == 3);
|
|
1011
|
+
REQUIRE(v[0] == 1);
|
|
1012
|
+
REQUIRE(v.back() == 3);
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
int main(int argc, char** argv) {
|
|
1016
|
+
// Google Test initialization
|
|
1017
|
+
::testing::InitGoogleTest(&argc, argv);
|
|
1018
|
+
|
|
1019
|
+
// Run simple tests
|
|
1020
|
+
testBasicFunctionality();
|
|
1021
|
+
|
|
1022
|
+
return RUN_ALL_TESTS();
|
|
1023
|
+
}
|
|
1024
|
+
"#;
|
|
1025
|
+
|
|
1026
|
+
fs::write(&test_file, content)?;
|
|
1027
|
+
|
|
1028
|
+
let ctx = TestContext::new();
|
|
1029
|
+
let output = ctx.run_probe(&[
|
|
1030
|
+
"search",
|
|
1031
|
+
"TEST", // Search for test patterns
|
|
1032
|
+
test_file.to_str().unwrap(),
|
|
1033
|
+
"--format",
|
|
1034
|
+
"outline",
|
|
1035
|
+
])?;
|
|
1036
|
+
|
|
1037
|
+
// Should detect test patterns (TEST is found, which matches TEST_F, TEST_CASE, etc.)
|
|
1038
|
+
assert!(
|
|
1039
|
+
output.contains("TEST") || output.contains("EXPECT_") || output.contains("REQUIRE"),
|
|
1040
|
+
"Should detect test patterns - output: {}",
|
|
1041
|
+
output
|
|
1042
|
+
);
|
|
1043
|
+
|
|
1044
|
+
// Should detect test classes
|
|
1045
|
+
assert!(
|
|
1046
|
+
output.contains("CalculatorTest") || output.contains("MockDataSource"),
|
|
1047
|
+
"Should detect test class definitions - output: {}",
|
|
1048
|
+
output
|
|
1049
|
+
);
|
|
1050
|
+
|
|
1051
|
+
// Should detect testing-related content - TEST patterns are found
|
|
1052
|
+
// The output shows TEST_CASE and other testing structures which is sufficient
|
|
1053
|
+
assert!(
|
|
1054
|
+
output.len() > 200, // Should have substantial test-related content
|
|
1055
|
+
"Should contain substantial test code - output length: {}, output: {}",
|
|
1056
|
+
output.len(),
|
|
1057
|
+
output
|
|
1058
|
+
);
|
|
1059
|
+
|
|
1060
|
+
Ok(())
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
#[test]
|
|
1064
|
+
fn test_cpp_multiple_file_extensions() -> Result<()> {
|
|
1065
|
+
let temp_dir = TempDir::new()?;
|
|
1066
|
+
|
|
1067
|
+
// Test different C++ file extensions
|
|
1068
|
+
let extensions = vec![
|
|
1069
|
+
("test.cpp", "C++ source"),
|
|
1070
|
+
("test.cc", "C++ source (Google style)"),
|
|
1071
|
+
("test.cxx", "C++ source (Microsoft style)"),
|
|
1072
|
+
("test.hpp", "C++ header"),
|
|
1073
|
+
("test.hxx", "C++ header (Microsoft style)"),
|
|
1074
|
+
];
|
|
1075
|
+
|
|
1076
|
+
for (filename, description) in extensions {
|
|
1077
|
+
let test_file = temp_dir.path().join(filename);
|
|
1078
|
+
|
|
1079
|
+
let content = format!(
|
|
1080
|
+
r#"// {}
|
|
1081
|
+
#include <iostream>
|
|
1082
|
+
#include <vector>
|
|
1083
|
+
|
|
1084
|
+
namespace test_{} {{
|
|
1085
|
+
|
|
1086
|
+
class TestClass {{
|
|
1087
|
+
public:
|
|
1088
|
+
explicit TestClass(const std::string& name) : name_(name) {{}}
|
|
1089
|
+
|
|
1090
|
+
virtual ~TestClass() = default;
|
|
1091
|
+
|
|
1092
|
+
auto getName() const -> const std::string& {{
|
|
1093
|
+
return name_;
|
|
1094
|
+
}}
|
|
1095
|
+
|
|
1096
|
+
template<typename T>
|
|
1097
|
+
void processData(const std::vector<T>& data) {{
|
|
1098
|
+
for (const auto& item : data) {{
|
|
1099
|
+
processItem(item);
|
|
1100
|
+
}}
|
|
1101
|
+
}}
|
|
1102
|
+
|
|
1103
|
+
private:
|
|
1104
|
+
std::string name_;
|
|
1105
|
+
|
|
1106
|
+
template<typename T>
|
|
1107
|
+
void processItem(const T& item) {{
|
|
1108
|
+
std::cout << "Processing: " << item << std::endl;
|
|
1109
|
+
}}
|
|
1110
|
+
}};
|
|
1111
|
+
|
|
1112
|
+
// Factory function
|
|
1113
|
+
std::unique_ptr<TestClass> createTestClass(const std::string& name) {{
|
|
1114
|
+
return std::make_unique<TestClass>(name);
|
|
1115
|
+
}}
|
|
1116
|
+
|
|
1117
|
+
}} // namespace test_{}
|
|
1118
|
+
|
|
1119
|
+
int main() {{
|
|
1120
|
+
auto obj = test_{}::createTestClass("TestObject");
|
|
1121
|
+
std::vector<int> data{{1, 2, 3, 4, 5}};
|
|
1122
|
+
obj->processData(data);
|
|
1123
|
+
return 0;
|
|
1124
|
+
}}
|
|
1125
|
+
"#,
|
|
1126
|
+
description,
|
|
1127
|
+
filename.replace('.', "_"),
|
|
1128
|
+
filename.replace('.', "_"),
|
|
1129
|
+
filename.replace('.', "_")
|
|
1130
|
+
);
|
|
1131
|
+
|
|
1132
|
+
fs::write(&test_file, content)?;
|
|
1133
|
+
|
|
1134
|
+
let ctx = TestContext::new();
|
|
1135
|
+
let output = ctx.run_probe(&[
|
|
1136
|
+
"search",
|
|
1137
|
+
"TestClass", // Search for test class
|
|
1138
|
+
test_file.to_str().unwrap(),
|
|
1139
|
+
"--format",
|
|
1140
|
+
"outline",
|
|
1141
|
+
])?;
|
|
1142
|
+
|
|
1143
|
+
// Should extract C++ symbols regardless of file extension
|
|
1144
|
+
assert!(
|
|
1145
|
+
output.contains("TestClass") || output.contains("createTestClass"),
|
|
1146
|
+
"Should extract C++ symbols from {} - output: {}",
|
|
1147
|
+
filename,
|
|
1148
|
+
output
|
|
1149
|
+
);
|
|
1150
|
+
|
|
1151
|
+
// Should contain template and namespace information
|
|
1152
|
+
assert!(
|
|
1153
|
+
output.contains("template") || output.contains("namespace"),
|
|
1154
|
+
"Should contain C++ structural elements in {} - output: {}",
|
|
1155
|
+
filename,
|
|
1156
|
+
output
|
|
1157
|
+
);
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
Ok(())
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
#[test]
|
|
1164
|
+
fn test_cpp_keyword_highlighting_in_outline() -> Result<()> {
|
|
1165
|
+
let temp_dir = TempDir::new()?;
|
|
1166
|
+
let test_file = temp_dir.path().join("keywords.cpp");
|
|
1167
|
+
|
|
1168
|
+
let content = r#"#include <iostream>
|
|
1169
|
+
#include <vector>
|
|
1170
|
+
#include <string>
|
|
1171
|
+
#include <memory>
|
|
1172
|
+
|
|
1173
|
+
// Function with multiple C++ keywords for highlighting
|
|
1174
|
+
class KeywordDemonstration {
|
|
1175
|
+
public:
|
|
1176
|
+
// Constructor with virtual and override keywords
|
|
1177
|
+
explicit KeywordDemonstration(const std::string& name) : name_(name) {}
|
|
1178
|
+
|
|
1179
|
+
// Virtual destructor
|
|
1180
|
+
virtual ~KeywordDemonstration() = default;
|
|
1181
|
+
|
|
1182
|
+
// Pure virtual function
|
|
1183
|
+
virtual void processVirtualData() = 0;
|
|
1184
|
+
|
|
1185
|
+
// Static member function
|
|
1186
|
+
static std::shared_ptr<KeywordDemonstration> createInstance(const std::string& name);
|
|
1187
|
+
|
|
1188
|
+
// Const member function
|
|
1189
|
+
const std::string& getName() const noexcept {
|
|
1190
|
+
return name_;
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
// Template member function with constexpr
|
|
1194
|
+
template<typename T>
|
|
1195
|
+
constexpr auto calculateValue(T input) const -> decltype(input * 2) {
|
|
1196
|
+
return input * 2;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
// Function with exception specification
|
|
1200
|
+
void riskyOperation() noexcept(false) {
|
|
1201
|
+
throw std::runtime_error("Something went wrong");
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
protected:
|
|
1205
|
+
std::string name_;
|
|
1206
|
+
mutable int cached_value_ = 0;
|
|
1207
|
+
|
|
1208
|
+
private:
|
|
1209
|
+
// Private virtual function
|
|
1210
|
+
virtual void internalProcess() {}
|
|
1211
|
+
};
|
|
1212
|
+
|
|
1213
|
+
// Derived class with inheritance keywords
|
|
1214
|
+
class ConcreteImplementation final : public KeywordDemonstration {
|
|
1215
|
+
public:
|
|
1216
|
+
explicit ConcreteImplementation(const std::string& name)
|
|
1217
|
+
: KeywordDemonstration(name) {}
|
|
1218
|
+
|
|
1219
|
+
// Override virtual function
|
|
1220
|
+
void processVirtualData() override final {
|
|
1221
|
+
std::cout << "Processing data in concrete implementation" << std::endl;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
// Deleted function
|
|
1225
|
+
ConcreteImplementation(const ConcreteImplementation&) = delete;
|
|
1226
|
+
ConcreteImplementation& operator=(const ConcreteImplementation&) = delete;
|
|
1227
|
+
|
|
1228
|
+
// Default move operations
|
|
1229
|
+
ConcreteImplementation(ConcreteImplementation&&) = default;
|
|
1230
|
+
ConcreteImplementation& operator=(ConcreteImplementation&&) = default;
|
|
1231
|
+
};
|
|
1232
|
+
|
|
1233
|
+
// Function template with concept-like requirements
|
|
1234
|
+
template<typename T>
|
|
1235
|
+
void processTemplate(T&& value) {
|
|
1236
|
+
static_assert(std::is_arithmetic_v<std::decay_t<T>>, "T must be arithmetic");
|
|
1237
|
+
|
|
1238
|
+
if constexpr (std::is_integral_v<T>) {
|
|
1239
|
+
std::cout << "Processing integral type" << std::endl;
|
|
1240
|
+
} else if constexpr (std::is_floating_point_v<T>) {
|
|
1241
|
+
std::cout << "Processing floating point type" << std::endl;
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
// Lambda with various keywords
|
|
1246
|
+
auto createLambda() {
|
|
1247
|
+
return [](auto&& value) mutable noexcept -> decltype(auto) {
|
|
1248
|
+
return std::forward<decltype(value)>(value);
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
int main() {
|
|
1253
|
+
// Auto keyword usage
|
|
1254
|
+
auto instance = std::make_unique<ConcreteImplementation>("test");
|
|
1255
|
+
|
|
1256
|
+
// Range-based for with auto
|
|
1257
|
+
std::vector<int> values{1, 2, 3, 4, 5};
|
|
1258
|
+
for (const auto& value : values) {
|
|
1259
|
+
processTemplate(value);
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
return 0;
|
|
1263
|
+
}
|
|
1264
|
+
"#;
|
|
1265
|
+
|
|
1266
|
+
fs::write(&test_file, content)?;
|
|
1267
|
+
|
|
1268
|
+
let ctx = TestContext::new();
|
|
1269
|
+
let output = ctx.run_probe(&[
|
|
1270
|
+
"search",
|
|
1271
|
+
"virtual", // Search for specific C++ keyword
|
|
1272
|
+
test_file.to_str().unwrap(),
|
|
1273
|
+
"--format",
|
|
1274
|
+
"outline",
|
|
1275
|
+
])?;
|
|
1276
|
+
|
|
1277
|
+
// Should find the keyword in context
|
|
1278
|
+
assert!(
|
|
1279
|
+
output.contains("virtual"),
|
|
1280
|
+
"Should contain 'virtual' keyword in search results - output: {}",
|
|
1281
|
+
output
|
|
1282
|
+
);
|
|
1283
|
+
|
|
1284
|
+
// Should show C++ class and inheritance structure
|
|
1285
|
+
assert!(
|
|
1286
|
+
output.contains("class") && (output.contains("public") || output.contains("private")),
|
|
1287
|
+
"Should show C++ class structure with access specifiers - output: {}",
|
|
1288
|
+
output
|
|
1289
|
+
);
|
|
1290
|
+
|
|
1291
|
+
// Test another keyword search
|
|
1292
|
+
let ctx2 = TestContext::new();
|
|
1293
|
+
let output2 = ctx2.run_probe(&[
|
|
1294
|
+
"search",
|
|
1295
|
+
"template",
|
|
1296
|
+
test_file.to_str().unwrap(),
|
|
1297
|
+
"--format",
|
|
1298
|
+
"outline",
|
|
1299
|
+
])?;
|
|
1300
|
+
|
|
1301
|
+
assert!(
|
|
1302
|
+
output2.contains("template"),
|
|
1303
|
+
"Should contain 'template' keyword - output: {}",
|
|
1304
|
+
output2
|
|
1305
|
+
);
|
|
1306
|
+
|
|
1307
|
+
// Test constexpr keyword search
|
|
1308
|
+
let ctx3 = TestContext::new();
|
|
1309
|
+
let output3 = ctx3.run_probe(&[
|
|
1310
|
+
"search",
|
|
1311
|
+
"constexpr",
|
|
1312
|
+
test_file.to_str().unwrap(),
|
|
1313
|
+
"--format",
|
|
1314
|
+
"outline",
|
|
1315
|
+
])?;
|
|
1316
|
+
|
|
1317
|
+
assert!(
|
|
1318
|
+
output3.contains("constexpr"),
|
|
1319
|
+
"Should contain 'constexpr' keyword - output: {}",
|
|
1320
|
+
output3
|
|
1321
|
+
);
|
|
1322
|
+
|
|
1323
|
+
Ok(())
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
#[test]
|
|
1327
|
+
fn test_cpp_stl_container_truncation_with_keyword_preservation() -> Result<()> {
|
|
1328
|
+
let temp_dir = TempDir::new()?;
|
|
1329
|
+
let test_file = temp_dir.path().join("stl_truncation.cpp");
|
|
1330
|
+
|
|
1331
|
+
let content = r#"#include <vector>
|
|
1332
|
+
#include <map>
|
|
1333
|
+
#include <unordered_map>
|
|
1334
|
+
#include <string>
|
|
1335
|
+
#include <algorithm>
|
|
1336
|
+
#include <iterator>
|
|
1337
|
+
|
|
1338
|
+
// Function with large STL container literals that should be truncated while preserving keywords
|
|
1339
|
+
class STLDemonstration {
|
|
1340
|
+
public:
|
|
1341
|
+
// Large vector with search keywords
|
|
1342
|
+
std::vector<std::string> createSearchKeywords() {
|
|
1343
|
+
return {
|
|
1344
|
+
"search", "find", "locate", "discover", "identify", "detect", "browse",
|
|
1345
|
+
"explore", "investigate", "examine", "scrutinize", "analyze", "study",
|
|
1346
|
+
"research", "query", "request", "ask", "question", "seek", "hunt",
|
|
1347
|
+
"track", "trace", "follow", "pursue", "chase", "stalk", "scout",
|
|
1348
|
+
"survey", "scan", "probe", "test", "check", "verify", "validate",
|
|
1349
|
+
"confirm", "authenticate", "authorize", "approve", "accept", "allow",
|
|
1350
|
+
"permit", "enable", "activate", "trigger", "initiate", "start",
|
|
1351
|
+
"begin", "commence", "launch", "execute", "run", "perform", "operate",
|
|
1352
|
+
"function", "work", "process", "handle", "manage", "control", "direct",
|
|
1353
|
+
"guide", "lead", "conduct", "coordinate", "organize", "arrange",
|
|
1354
|
+
"structure", "format", "design", "create", "build", "construct",
|
|
1355
|
+
"develop", "implement", "establish", "setup", "configure", "customize",
|
|
1356
|
+
"modify", "change", "alter", "adjust", "adapt", "transform", "convert"
|
|
1357
|
+
};
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
// Large map with mixed keywords
|
|
1361
|
+
std::map<std::string, int> createKeywordFrequencies() {
|
|
1362
|
+
return {
|
|
1363
|
+
{"algorithm", 150}, {"data", 200}, {"structure", 180}, {"search", 250},
|
|
1364
|
+
{"sort", 175}, {"find", 220}, {"insert", 190}, {"delete", 165},
|
|
1365
|
+
{"update", 140}, {"query", 210}, {"index", 185}, {"key", 195},
|
|
1366
|
+
{"value", 205}, {"hash", 160}, {"tree", 170}, {"graph", 155},
|
|
1367
|
+
{"node", 145}, {"edge", 135}, {"vertex", 125}, {"path", 115},
|
|
1368
|
+
{"distance", 105}, {"weight", 95}, {"cost", 85}, {"benefit", 75},
|
|
1369
|
+
{"optimization", 65}, {"performance", 255}, {"efficiency", 245},
|
|
1370
|
+
{"complexity", 235}, {"analysis", 225}, {"design", 215}, {"pattern", 185},
|
|
1371
|
+
{"template", 175}, {"generic", 165}, {"polymorphism", 155}, {"inheritance", 145},
|
|
1372
|
+
{"encapsulation", 135}, {"abstraction", 125}, {"interface", 115}, {"implementation", 105}
|
|
1373
|
+
};
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
// Large unordered_map with keyword patterns
|
|
1377
|
+
std::unordered_map<std::string, std::vector<std::string>> createCategoryKeywords() {
|
|
1378
|
+
return {
|
|
1379
|
+
{"search", {"find", "locate", "discover", "identify", "detect", "browse", "explore", "investigate"}},
|
|
1380
|
+
{"sorting", {"sort", "order", "arrange", "organize", "rank", "priority", "sequence", "classification"}},
|
|
1381
|
+
{"data", {"information", "content", "value", "record", "entry", "item", "element", "object"}},
|
|
1382
|
+
{"structure", {"organization", "arrangement", "layout", "format", "design", "architecture", "framework"}},
|
|
1383
|
+
{"algorithm", {"procedure", "method", "technique", "approach", "strategy", "solution", "process"}},
|
|
1384
|
+
{"performance", {"speed", "efficiency", "optimization", "throughput", "latency", "benchmark", "metrics"}},
|
|
1385
|
+
{"testing", {"validation", "verification", "checking", "debugging", "analysis", "evaluation", "assessment"}},
|
|
1386
|
+
{"development", {"programming", "coding", "implementation", "construction", "creation", "building"}},
|
|
1387
|
+
{"maintenance", {"update", "modify", "repair", "fix", "enhance", "improve", "refactor", "optimize"}}
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
// Function that processes search terms
|
|
1392
|
+
void processSearchTerms(const std::string& searchTerm) {
|
|
1393
|
+
auto keywords = createSearchKeywords();
|
|
1394
|
+
auto frequencies = createKeywordFrequencies();
|
|
1395
|
+
auto categories = createCategoryKeywords();
|
|
1396
|
+
|
|
1397
|
+
// Search through keywords
|
|
1398
|
+
auto it = std::find(keywords.begin(), keywords.end(), searchTerm);
|
|
1399
|
+
if (it != keywords.end()) {
|
|
1400
|
+
std::cout << "Found search term: " << searchTerm << std::endl;
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
// Check frequency
|
|
1404
|
+
if (frequencies.find(searchTerm) != frequencies.end()) {
|
|
1405
|
+
std::cout << "Frequency for " << searchTerm << ": " << frequencies[searchTerm] << std::endl;
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
// Check categories
|
|
1409
|
+
for (const auto& [category, terms] : categories) {
|
|
1410
|
+
if (std::find(terms.begin(), terms.end(), searchTerm) != terms.end()) {
|
|
1411
|
+
std::cout << "Found " << searchTerm << " in category: " << category << std::endl;
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
// Template function with complex STL usage
|
|
1417
|
+
template<typename Container, typename Predicate>
|
|
1418
|
+
auto filterAndSearch(const Container& container, Predicate pred, const std::string& searchKey) {
|
|
1419
|
+
std::vector<typename Container::value_type> filtered;
|
|
1420
|
+
|
|
1421
|
+
std::copy_if(container.begin(), container.end(),
|
|
1422
|
+
std::back_inserter(filtered),
|
|
1423
|
+
pred);
|
|
1424
|
+
|
|
1425
|
+
auto searchResult = std::find_if(filtered.begin(), filtered.end(),
|
|
1426
|
+
[&searchKey](const auto& item) {
|
|
1427
|
+
return item.find(searchKey) != std::string::npos;
|
|
1428
|
+
});
|
|
1429
|
+
|
|
1430
|
+
return searchResult != filtered.end();
|
|
1431
|
+
}
|
|
1432
|
+
};
|
|
1433
|
+
|
|
1434
|
+
// Global search function with large initialization
|
|
1435
|
+
void performGlobalSearch(const std::string& query) {
|
|
1436
|
+
// Large static data with search-related keywords
|
|
1437
|
+
static std::vector<std::string> searchDomains = {
|
|
1438
|
+
"web", "database", "filesystem", "network", "cache", "index", "catalog",
|
|
1439
|
+
"directory", "registry", "repository", "archive", "library", "collection",
|
|
1440
|
+
"dataset", "datastore", "warehouse", "mart", "lake", "stream", "queue",
|
|
1441
|
+
"buffer", "pool", "heap", "stack", "tree", "graph", "table", "view",
|
|
1442
|
+
"search", "find", "locate", "discover", "identify", "detect", "browse"
|
|
1443
|
+
};
|
|
1444
|
+
|
|
1445
|
+
STLDemonstration demo;
|
|
1446
|
+
demo.processSearchTerms(query);
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
int main() {
|
|
1450
|
+
performGlobalSearch("search");
|
|
1451
|
+
return 0;
|
|
1452
|
+
}
|
|
1453
|
+
"#;
|
|
1454
|
+
|
|
1455
|
+
fs::write(&test_file, content)?;
|
|
1456
|
+
|
|
1457
|
+
let ctx = TestContext::new();
|
|
1458
|
+
let output = ctx.run_probe(&[
|
|
1459
|
+
"search",
|
|
1460
|
+
"search", // Search for the keyword "search"
|
|
1461
|
+
test_file.to_str().unwrap(),
|
|
1462
|
+
"--format",
|
|
1463
|
+
"outline",
|
|
1464
|
+
])?;
|
|
1465
|
+
|
|
1466
|
+
// Should find the search keyword
|
|
1467
|
+
assert!(
|
|
1468
|
+
output.contains("search"),
|
|
1469
|
+
"Should contain 'search' keyword - output: {}",
|
|
1470
|
+
output
|
|
1471
|
+
);
|
|
1472
|
+
|
|
1473
|
+
// Should show large STL containers (they may be truncated or fully shown)
|
|
1474
|
+
assert!(
|
|
1475
|
+
output.contains("std::vector") || output.contains("vector") || output.len() > 1000,
|
|
1476
|
+
"Should contain STL container code or show substantial content - output: {}",
|
|
1477
|
+
output
|
|
1478
|
+
);
|
|
1479
|
+
|
|
1480
|
+
// Should preserve the search keyword even in truncated containers
|
|
1481
|
+
// The output should have reasonable length (not thousands of lines)
|
|
1482
|
+
let line_count = output.lines().count();
|
|
1483
|
+
assert!(
|
|
1484
|
+
line_count < 300,
|
|
1485
|
+
"Output should be truncated to reasonable size, got {} lines",
|
|
1486
|
+
line_count
|
|
1487
|
+
);
|
|
1488
|
+
|
|
1489
|
+
// Should contain STL container types
|
|
1490
|
+
assert!(
|
|
1491
|
+
output.contains("std::vector")
|
|
1492
|
+
|| output.contains("std::map")
|
|
1493
|
+
|| output.contains("vector")
|
|
1494
|
+
|| output.contains("map"),
|
|
1495
|
+
"Should contain STL container types - output: {}",
|
|
1496
|
+
output
|
|
1497
|
+
);
|
|
1498
|
+
|
|
1499
|
+
// Should show template and class structures
|
|
1500
|
+
assert!(
|
|
1501
|
+
output.contains("template") || output.contains("class"),
|
|
1502
|
+
"Should show C++ structural elements - output: {}",
|
|
1503
|
+
output
|
|
1504
|
+
);
|
|
1505
|
+
|
|
1506
|
+
Ok(())
|
|
1507
|
+
}
|