EDNE June 2012 - (Page 29)

LISTING 1 ZUNE CODE static void SetYearAndDayOfYear(RtcTime * time) { int days = time->daysSince1980; int year = STARTING_YEAR; while (days > 365) { if (IsLeapYear(year)) { if (days > 366) { days -= 366; year += 1; } } else { days -= 365; year += 1; } } time->dayOfYear = days; time->year = year; } LISTING 2 TEST CODE TEST(RtcTime, 2008_12_31_last_day_of_leap_year) { int yearStart = daysSince1980ForYear(2008); rtcTime = RtcTime_Create(yearStart+366); assertDate(2008, 12, 31, Wednesday); } dEvELopmENT CyCLE TDD is most effective when the build-and-test cycle takes only a handful of seconds. This approach rules out having target hardware in the loop for most programmers. The need for fast feedback leads you to move the TDD microcycle off the target to run natively on the development system. Figure 5 shows a TDD cycle that limits the dual-target risks and provides the benefit of a fast TDD feedback loop. By going through the stages listed in Table 1, you expect to find problems at the appropriate stage. For example, you STAGE 1 STAGE 2 STAGE 3 RUN TESTS IN THE EVALUATION HARDWARE OR SIMULATOR STAGE 4 STAGE 5 WRITE A TEST MAKE IT PASS REFACTOR COMPILE FOR TARGET PROCESSOR RUN TESTS IN TARGET HARDWARE RUN ACCEPTANCE TESTS IN TARGET MORE FREQUENT LESS FREQUENT Figure 5 The need for fast feedback leads you to move the TDD microcycle off the target to run natively on the development system. A TDD cycle limits dual-target risks and provides the benefit of a fast TDD feedback loop. www.edn-europe.com JUNE 2012 | EDN EUROPE 29 http://digikey.com/europe http://www.edn-europe.com

Table of Contents for the Digital Edition of EDNE June 2012

Cover
Agilent Technologies
Contents
International Rectifier
RS Components
Masthead
International Rectifier
Comment
Pulse
Analog Devices
Digi-Key
Farnell
NXP
Test & Measurement
Silicon Labs
Digi-Key
Test-driven development for embedded C: why debug?
Digi-Key
Baker’s best
Cover story
Rohde & Schwarz
Rohde & Schwarz
Rohde & Schwarz
Rohde & Schwarz
Rohde & Schwarz
Pico-projector design uses color LEDs
Digital isolation in smart energy metering applications
Mechatronics in design
Teardown
Design Idea
Product Roundup
Tales from the cube

EDNE June 2012

https://www.nxtbook.com/reedbusiness/edne/2013EDNEFebruary
https://www.nxtbook.com/reedbusiness/edne/2013EDNJanuary
https://www.nxtbook.com/reedbusiness/edne/2012EDNEDecember
https://www.nxtbook.com/reedbusiness/edne/2012EDNENovember
https://www.nxtbook.com/reedbusiness/edne/2012EDNEOctober
https://www.nxtbook.com/reedbusiness/edne/2012EDNESeptember
https://www.nxtbook.com/reedbusiness/edne/2012EDNEAugust
https://www.nxtbook.com/reedbusiness/edne/2012EDNEJuly
https://www.nxtbook.com/reedbusiness/edne/2012EDNEJuin
https://www.nxtbook.com/reedbusiness/edne/2012EDNEMay
https://www.nxtbook.com/reedbusiness/edne/2012EDNEApril
https://www.nxtbookmedia.com