// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import "forge-std/Test.sol"; import "../contracts/LabHelper.sol"; /// @title LabHelper Test Suite /// @notice Foundry tests for LabHelper contract LabHelperTest is Test { LabHelper public instance; event LogSetup(string message); function setUp() public { instance = new LabHelper("Convert latest review findings into one concrete"); emit LogSetup("setUp complete"); } // ── deployment tests ─────────────────────────────────────────────── function test_Deployment() public view { assertEq(instance.topic(), "Convert latest review findings into one concrete", "initial topic mismatch"); } function test_DeploymentNonEmpty() public view { assertTrue(bytes(instance.topic()).length > 0, "topic should not be empty"); } // ── state mutation tests ─────────────────────────────────────────── function test_SetTopic() public { string memory next = "updated value"; instance.setTopic(next); assertEq(instance.topic(), next, "setTopic failed"); } function test_SetTopicEmpty() public { instance.setTopic(""); assertEq(instance.topic(), "", "setting empty topic failed"); } function test_SetTopicTwice() public { instance.setTopic("first"); instance.setTopic("second"); assertEq(instance.topic(), "second", "double set failed"); } // ── fuzz tests ──────────────────────────────────────────────────── function testFuzz_SetTopic(string calldata newTopic) public { instance.setTopic(newTopic); assertEq(instance.topic(), newTopic, "fuzz setTopic mismatch"); } // ── gas benchmarks ──────────────────────────────────────────────── function test_SetTopicGas() public { uint256 gasBefore = gasleft(); instance.setTopic("gas benchmark"); uint256 gasUsed = gasBefore - gasleft(); assertTrue(gasUsed < 100_000, "setTopic gas too high"); } }