We report on an experimental test of classical and quantum dimension. We have used a dimension witness that can distinguish between quantum and classical systems of dimensions two, three, and four and performed the experiment for all five cases. The witness we have chosen is a base of semi-device-independent cryptographic and randomness expansion protocols. Therefore, the part of the experiment in which qubits were used is a realization of these protocols. In our work we also present an analytic method for finding the maximum quantum value of the witness along with corresponding measurements and preparations. This method is quite general and can be applied to any linear dimension witness.