Add tests for ndigits (issue #8266).