Permalink
Browse files

Added test and changed impl so that MaxFree also works when marked slots

are not only booked by Id 1 now also any other Id
  • Loading branch information...
1 parent 68b4ede commit 3bdf61a5dffd28a31f6eacf99df9d13df8b8d299 gianfranco committed Apr 29, 2012
Showing with 8 additions and 2 deletions.
  1. +1 −1 Booking/booking.dyalog
  2. +7 −1 Booking/booking_unittests.dyalog
View
@@ -19,7 +19,7 @@ GETID ← { Lookup ⍵,2 }
Z MaxFree LookupTable;FreeSlots;MaxFreeSlots;Ids
Ids LookupTable[;1]
⎕ML3
- FreeSlots { (~) () } ¨ 1[2] LookupTable
+ FreeSlots { () } ¨ 0 = 1[2] LookupTable
MaxFreeSlots {/} ¨ FreeSlots
⎕ML0
Z ,/ Ids,[1.5]{(),1} ¨ MaxFreeSlots
@@ -24,6 +24,12 @@ UTTable ← ↑ (3 0 0 0) (1 0 0 0) (2 0 0 0)
Z Expected #.Booking.MaxFree UTTable2
+ Z UT5;UTTable2;Expected
+ UTTable2 (3 0 1 2 0 0) (1 5 7 0 0 0) (2 0 0 1 0 0)
+ Expected (3 2 4) (1 3 3) (2 2 4)
+ Z Expected #.Booking.MaxFree UTTable2
+
+
Z RunTest Name
Z Name
:If ~ Z
@@ -34,7 +40,7 @@ UTTable ← ↑ (3 0 0 0) (1 0 0 0) (2 0 0 0)
Z Test;Tests
- Tests 'UT1' 'UT2' 'UT3' 'UT4'
+ Tests 'UT1' 'UT2' 'UT3' 'UT4' 'UT5'
Z RunTest ¨ Tests
:if ^/ Z
'All ' ( Tests) 'tests passed'

0 comments on commit 3bdf61a

Please sign in to comment.