Short answer
Paint two coats onto a large piece of primed board rather than straight onto the wall, and move that board around the room over several days. A board can be held against the floor, the skirting and the furniture, and can be viewed on the bright wall and the shaded one — none of which a patch painted onto a single wall allows.
A patch painted directly onto the wall is compromised in three ways at once: it is fixed to one wall with one light condition, it is surrounded by the old colour which shifts how it reads through simultaneous contrast, and the old colour usually shows through a thin coat. A movable board with two full coats removes all three problems, which is why it is the method decorators use.
Use A2 or larger primed board, or lining paper stuck to card. An unprimed brown or grey board changes the colour of anything painted on it, particularly with pale or thin colours.
One coat is not the finished colour. Most paints only reach their intended depth and opacity on the second coat, and pale colours over a white primer can look markedly weaker at one coat.
Wet paint looks darker and glossier than dry paint, and emulsions in particular lighten and flatten as they cure. Judging a sample while it is still wet is judging a different colour.
A margin of white board around the colour gives the eye a neutral reference and stops the surrounding wall colour tinting your reading of the sample.
Try it on the wall opposite the window, the wall containing the window, and in the darkest corner. Stand it on the floor against the skirting to judge it beside the flooring, and beside any fixed material you are working around.
Morning, mid-afternoon and after dark with the room's own lights on. A colour that only works at one of those is not the right colour for that room.
Place the shortlisted boards side by side. Judged alone, almost any colour looks acceptable, because the eye adapts to whatever it is shown.
Treat small printed colour cards as a way to shortlist, never to decide. Printed inks and paint pigments behave differently, and a card is viewed at a scale and under a light that bear no relation to a wall. Digital previews on a screen are further removed still — an emitted screen colour is not a prediction of a reflected surface colour.
How to test it
If you can only do one thing: two coats, large board, three positions, three times of day. That combination catches nearly every problem that would otherwise appear after the room is painted.
Undertone
Undertones only reveal themselves in comparison. A single sample viewed alone will look neutral almost regardless of what it is — put it beside a sheet of plain white paper and the warm or cool cast becomes obvious.
Lighting
Never make the final decision under a single light source. The most common regret is a colour approved under a warm bulb in the evening and seen for the first time in daylight the following morning.
Finish
Test in the finish you intend to use. A matt sample tells you very little about how the same colour will look in eggshell or satin, both of which read deeper and reflect more.
Whatever a calculation or a chart says, view a physical sample in the actual location before committing to a large surface.
Colourwise editorial guidance, drawn from conventional decorating practice and from the physical behaviour of light and surfaces described in the linked lighting and finish guides. Not manufacturer advice — always follow the specific instructions supplied with any product you use.