Path: csiph.com!weretis.net!feeder4.news.weretis.net!ecngs!testfeeder.ecngs.de!81.171.118.64.MISMATCH!peer04.fr7!news.highwinds-media.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c++ Subject: Re: TDD can be useful even when it doesn't achieve what you want Date: Thu, 18 Feb 2016 21:17:48 +1300 Lines: 41 Message-ID: References: <56c34b5c$0$18569$e4fe514c@newszilla.xs4all.nl> <56c4b474$0$4233$e4fe514c@newszilla.xs4all.nl> <56c4ef61$0$4197$e4fe514c@newszilla.xs4all.nl> <56c573ab$0$4031$e4fe514c@newszilla.xs4all.nl> <56c5798b$0$4048$e4fe514c@newszilla.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net v6Hc50554tYz26m7e9K+TwpcLbwLZnuZQ8rtu4Sp1lTwJ1Wx2v Cancel-Lock: sha1:ywt6BO+kI5L+xKHRMhTsX/3gt6U= User-Agent: Mozilla/5.0 (X11; SunOS i86pc; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: <56c5798b$0$4048$e4fe514c@newszilla.xs4all.nl> X-Received-Bytes: 2901 X-Received-Body-CRC: 2507881400 Xref: csiph.com comp.lang.c++:41023 Wouter van Ooijen wrote: > Op 18-Feb-16 om 8:42 AM schreef Ian Collins: >> Wouter van Ooijen wrote: >>> Op 17-Feb-16 om 11:19 PM schreef Ian Collins: >>>> >>>> Let me ask you why you wouldn't obey the rules for say a device driver? >>>> I certainly do and for such low level fiddly code I find TDD to be an >>>> ideal tool. I like to step through, almost bit by bit, tasks such as >>>> setting up device registers. The steps, both conceptually and in code, >>>> are small and ideally suited to an incremental test/code/refactor cycle >>>> such as TDD. Being close to a pure coding exercise, any objections to >>>> TDD and design are irrelevant at this level. >>> >>> Let's say I write code for a UART to transmit data at a (run-time) >>> specified baudrate. What would your (first) test be? >> >> It wouldn't be the first test (there would be more generic configuration >> to test first), > > such as? That depends on the device, if the UART is stand alone, there might not be any but if it is part of a processor, there will probably configuration registers that have to be setup before the UART can be used. >> but the last test for the requirement would be that the >> drive sits the correct bits in the the appropriate configuration >> register(s). > > But how do you determine what is the correct setting (or: how do you > make sure that the settings you have determined have the desired effect)? The device specification! I actually wrote tests for a UART driver on an ARM STM32 processor last year. To verify the settings I had a block of mapped memory at the appropriate address for the device registers and simply tested for the correct values getting written. -- Ian Collins