On Sun, Sep 17, 2017 at 6:43 PM, David Fetter <da...@fetter.org> wrote:
> On Sat, Sep 16, 2017 at 10:42:49PM +0000, Douglas Doole wrote: > > Oliver, I took a look at your tests and they look thorough to me. > > > > One recommendation, instead of having 3999 separate selects to test every > > legal roman numeral, why not just do something like this: > > > > do $$ > > declare > > i int; > > rn text; > > rn_val int; > > begin > > for i in 1..3999 loop > > rn := trim(to_char(i, 'rn')); > > rn_val := to_number(rn, 'rn'); > > if (i <> rn_val) then > > raise notice 'Mismatch: i=% rn=% rn_val=%', i, rn, rn_val; > > end if; > > end loop; > > raise notice 'Tested roman numerals 1..3999'; > > end; > > $$; > > > > It's a lot easier to maintain than separate selects. > > Why not just one SELECT, as in: > > SELECT i, to_char(i, 'rn'), to_number(to_char(i, 'rn'), 'rn'); > FROM generate_series(1,3999) i > Question: What is our definition of a legal Roman numeral? For example sometimes IXX appears in the corpus to refer to 19 even though our standardised notation would be XIX. > > Best, > David. > -- > David Fetter <david(at)fetter(dot)org> http://fetter.org/ > Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter > Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com > > Remember to vote! > Consider donating to Postgres: http://www.postgresql.org/about/donate > > > -- > Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-hackers > -- Best Regards, Chris Travers Database Administrator Tel: +49 162 9037 210 | Skype: einhverfr | www.adjust.com Saarbrücker Straße 37a, 10405 Berlin