Ideas for simplifying tabular UTF-7 tests?

Alex Henrie alexhenrie24 at gmail.com
Sat Nov 8 02:00:14 CST 2014


Hi,

I have two patches for adding tabular UTF-7 tests at
https://github.com/alexhenrie/wine/commits/master

However, before I submit them to wine-patches, I'd like to ask for
wider feedback. Sebastian Lackner has commented:

* too many values for each test, difficult to maintain, and looks redundant
* initializing big structures on the stack should be avoided

The problem is that I don't see a good way to simplify this any further:

* The chars_written variable (number of characters actually written)
cannot be eliminated and determined implicitly from the len and dstlen
variables alone. See the second-to-last encoding test case, where len
is 0 and dstlen is 4, but chars_written is 3.
* The dst variable (destination buffer) is almost always set to the
output variable, but one test requires dst to be NULL.
* These are just tests, so I'm not worried about complicating the code
in order to improve performance.

I've tried replacing chars_written and dst with a set of flags
(ONE_NOT_WRITTEN and NULL_DST) and corresponding if statements, but
this looks ugly to me. Furthermore, removing the output variable from
the table obscures the reason why dstlen is usually set to
sizeof(output) - 1. All in all, I think that writing out all the
parameters explicitly is the most intuitive way to go.

What do the rest of you think? How would you write this code?

-Alex



More information about the wine-devel mailing list