cs50python icon indicating copy to clipboard operation
cs50python copied to clipboard

set5

Open rohit20032003 opened this issue 1 year ago • 0 comments

test_fuel correct code import pytest from fuel import convert, gauge

Test cases for convert function

def test_convert_valid_fraction(): assert convert("3/4") == 75

def test_convert_zero_division_error(): with pytest.raises(ZeroDivisionError): convert("1/0")

def test_convert_value_error(): with pytest.raises(ValueError): convert("2.5/3")

def test_convert_x_greater_than_y(): with pytest.raises(ValueError): convert("5/3")

Test cases for gauge function

def test_gauge_less_than_1(): assert gauge(1) == "E" assert gauge(0) == "E"

def test_gauge_greater_than_99(): assert gauge(99) == "F" assert gauge(100) == "F"

def test_gauge_between_1_and_99(): assert gauge(50) == "50%" assert gauge(75) == "75%"

Additional test cases as needed

Run the tests with pytest

if name == "main": pytest.main()

rohit20032003 avatar Jun 28 '24 10:06 rohit20032003