If statement gas problem

Hi, i experienced a problem with my smart-contracts.

To make it simple, i have :

function getRandomNumber() internal view returns(uint256) {
return randomNumberBetween_1_and_10;

function store() public {
if (getRandomNumber == 1) {
costGas += 1;

So when my randomNumber is 1, function store is failing because -> Warning! Error encountered during contract execution [ out of gas ]

I understand that the blockchain return the last cost of the function, so 0 if number <> 1. Is this a way to force check the if statement to get the correct gas amount ?