envBool
Signature
Section titled “Signature”function envBool(string calldata key) external returns (bool value);function envBool( string calldata key, string calldata delimiter) external returns (bool[] memory values);Description
Section titled “Description”Read an environment variable as bool or bool[].
- For
true, use either “true” or “True” for the environment variable value. - For
false, use either “false” or “False” for the environment variable value. - For arrays, you can specify the delimiter used to separate the values with the
delimiterparameter.
Examples
Section titled “Examples”Single Value
Section titled “Single Value”With environment variable BOOL_VALUE=true,
string memory key = "BOOL_VALUE";bool expected = true;bool output = cheats.envBool(key);assert(output == expected);With environment variable BOOL_VALUES=true,false,True,False,
string memory key = "BOOL_VALUES";string memory delimiter = ",";bool[4] memory expected = [true, false, true, false];bool[] memory output = cheats.envBool(key, delimiter);assert(keccak256(abi.encodePacked((output))) == keccak256(abi.encodePacked((expected))));