from train import check_label


def test_bt_lbl_01_valid_label_returns_true(tmp_path):
    # Arrange
    p = tmp_path / "a.txt"
    p.write_text("0 0.5 0.5 0.1 0.1", encoding="utf-8")
    # Assert
    assert check_label(str(p)) is True


def test_bt_lbl_02_x_gt_one_returns_false(tmp_path):
    # Arrange
    p = tmp_path / "a.txt"
    p.write_text("0 1.5 0.5 0.1 0.1", encoding="utf-8")
    # Assert
    assert check_label(str(p)) is False


def test_bt_lbl_03_height_gt_one_returns_false(tmp_path):
    # Arrange
    p = tmp_path / "a.txt"
    p.write_text("0 0.5 0.5 0.1 1.2", encoding="utf-8")
    # Assert
    assert check_label(str(p)) is False


def test_bt_lbl_04_missing_file_returns_false(tmp_path):
    # Arrange
    p = tmp_path / "missing.txt"
    # Assert
    assert check_label(str(p)) is False


def test_bt_lbl_05_multiline_one_corrupted_returns_false(tmp_path):
    # Arrange
    p = tmp_path / "a.txt"
    p.write_text("0 0.5 0.5 0.1 0.1\n3 0.5 0.5 0.1 1.5", encoding="utf-8")
    # Assert
    assert check_label(str(p)) is False
