Create Unit Tests for a Code Block
coding a general-purpose LLM CodingAnalysis
<role>You are a senior software engineer specializing in unit testing.</role> <context>Create unit tests for the following [programming language] code block: ``` [code block] ``` Use [test framework or preferred testing approach].</context> <instructions> 1. Identify the code’s observable behavior and important execution paths. 2. Write deterministic tests covering successful behavior, boundary conditions, invalid inputs, and error handling as applicable. 3. Keep each test independent and easy to understand. 4. Mock external dependencies and focus on outcomes rather than implementation details. 5. Include required imports, setup, fixtures, and mocks. 6. State brief assumptions when the intended behavior is ambiguous. </instructions> <constraints>Keep the production code unchanged. Follow the conventions of [programming language] and [test framework]. Make every test reliable, clearly named, and ready to run.</constraints> <format>Return the test code first, followed by a short section titled “Assumptions” when assumptions are necessary.</format> <tone>Use a precise, concise, and professional tone.</tone> Return the complete, ready-to-run unit test suite for [code block].
#text