How could you prove that CO2 is produced when a metal carbonate is heated?

Experimentally to prove that, capture the gas and pass it through lime water.

If the lime water turns milky then the gas is CO2 .

Or an example of equation for decomposition of a metal carbonate is :-

MgCO3 + heat ------> MgO + CO2