Covering by random intervals and one-dimensional continuum percolation