From 6621dee7481bfec7e4e988f9cbe27a3b29978908 Mon Sep 17 00:00:00 2001 From: ollo Date: Wed, 1 Mar 2017 18:28:37 +0100 Subject: [PATCH] All tests calculating the length of the word passed --- unit/testWordClock.lua | 11 +++++++++-- wordclock.lua | 13 ++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/unit/testWordClock.lua b/unit/testWordClock.lua index 7390bc7..e722669 100644 --- a/unit/testWordClock.lua +++ b/unit/testWordClock.lua @@ -56,7 +56,7 @@ expected.itis=1 expected.one=1 expected.clock=1 checkWords(leds, expected, 1, 0) -checkCharacter(display_countwords_de(leds), 12) +checkCharacter(display_countwords_de(leds), 11) leds=display_timestat(2,5) expected={} @@ -142,7 +142,7 @@ checkCharacter(display_countwords_de(leds), 12) leds=display_timestat(12,55) expected={} -expected.one=1 +expected.oneLong=1 expected.fiveMin=1 expected.before=1 checkWords(leds, expected, 12 , 55) @@ -164,6 +164,7 @@ expected.two=1 expected.min1=1 expected.clock=1 checkWords(leds, expected, 14 , 01) +checkCharacter(display_countwords_de(leds), 12) leds=display_timestat(15,02) expected={} @@ -172,6 +173,7 @@ expected.three=1 expected.min2=1 expected.clock=1 checkWords(leds, expected, 15 , 02) +checkCharacter(display_countwords_de(leds), 12) leds=display_timestat(16,03) expected={} @@ -180,6 +182,7 @@ expected.four=1 expected.min3=1 expected.clock=1 checkWords(leds, expected, 16 , 03) +checkCharacter(display_countwords_de(leds), 12) leds=display_timestat(17,04) expected={} @@ -188,6 +191,7 @@ expected.five=1 expected.min4=1 expected.clock=1 checkWords(leds, expected, 17 , 04) +checkCharacter(display_countwords_de(leds), 12) leds=display_timestat(18,06) expected={} @@ -196,6 +200,7 @@ expected.after=1 expected.min1=1 expected.six=1 checkWords(leds, expected, 18 , 06) +checkCharacter(display_countwords_de(leds), 13) leds=display_timestat(19,09) expected={} @@ -204,6 +209,7 @@ expected.after=1 expected.min4=1 expected.seven=1 checkWords(leds, expected, 19 , 09) +checkCharacter(display_countwords_de(leds), 14) leds=display_timestat(20,17) expected={} @@ -212,6 +218,7 @@ expected.after=1 expected.min2=1 expected.eight=1 checkWords(leds, expected, 20 , 17) +checkCharacter(display_countwords_de(leds), 15) diff --git a/wordclock.lua b/wordclock.lua index 00648d2..f99d815 100755 --- a/wordclock.lua +++ b/wordclock.lua @@ -13,8 +13,8 @@ function display_timestat(hours, minutes, longmode) -- generate an empty return type local ret = { itis=0, fiveMin=0, tenMin=0, after=0, before=0, threeHour=0, quater=0, threequater=0, half=0, s=0, - one=0, two=0, three=0, four=0, five=0, six=0, seven=0, eight=0, nine=0, ten=0, eleven=0, twelve=0, - twenty=0, + one=0, oneLong=0, two=0, three=0, four=0, five=0, six=0, seven=0, eight=0, nine=0, ten=0, eleven=0, twelve=0, + twenty=0, clock=0, sr_nc=0, min1=0, min2=0, min3=0, min4=0 } -- return black screen if there is no real time given @@ -104,7 +104,11 @@ function display_timestat(hours, minutes, longmode) end if (hours == 1) then - ret.one=1 + if (ret.before == 1) then + ret.oneLong = 1 + else + ret.one=1 + end elseif (hours == 2) then ret.two=1 elseif (hours == 3) then @@ -172,6 +176,9 @@ function display_countwords_de(words) amount = amount + 6 end if (words.one == 1) then + amount = amount + 3 + end + if (words.oneLong == 1) then amount = amount + 4 end if (words.two == 1) then