Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- note
- description: "Test BIRTHDAY_BOOK"
- author: ""
- date: "$Date$"
- revision: "$Revision$"
- class
- TESTS
- inherit
- ES_TEST
- create
- make
- feature {NONE} -- Initialization
- make
- -- create test suite
- do
- add_boolean_case (agent t1)
- add_boolean_case (agent t2)
- add_boolean_case (agent t3)
- add_boolean_case (agent t4)
- end
- feature -- tests
- t1: BOOLEAN
- local
- app : APP[INTEGER,STRING]
- a : ARRAY[INTEGER]
- do
- create app.make
- create a.make_empty
- Result:= not (app.item_exists (10, a))
- check Result end
- end
- t2: BOOLEAN
- local
- app : APP[INTEGER,STRING]
- do
- create app.make
- Result := app.item_exists2 (2, <<6,4,8,3,2>>)
- check Result end
- end
- t3: BOOLEAN
- local
- app : APP[INTEGER,STRING]
- do
- create app.make
- Result := app.item_exists3 (2, <<6,4,8,3,2>>)
- check Result end
- end
- t4: BOOLEAN
- local
- app : APP[INTEGER,STRING]
- do
- create app.make_from_array (<<1,2,3,4,5,5>>, <<"one","two","three","four">>)
- Result := not(app.is_function)
- check Result end
- end
- -- t1: BOOLEAN
- -- local
- -- feb17: BIRTHDAY
- -- bb: BIRTHDAY_BOOK
- -- bb2: BIRTHDAY_BOOK
- -- singleton : BIRTHDAY_BOOK_SINGLE
- -- a: ARRAY[NAME]
- -- l_name: NAME
- -- l_birthday: BIRTHDAY
- -- jack,jill,max: NAME
- -- list: LIST_NAMES
- -- do
- -- comment("t1: test birthday book")
- -- create jack.make ("Jack"); create jill.make ("Jill")
- -- create max.make ("Max")
- -- create feb17.make (02, 17) -- Feb 17
- -- bb.put (jack, [14,01]) -- Jan 14
- ---- bb.put (jill, [17,02]) -- Feb 17
- ---- Result := bb.model.count = 2
- ---- and bb.model[jack].as_array.at (1) ~ [14,01]
- ---- and bb.model[jill].as_array.at (1) ~ [17,02]
- ---- and bb.out ~ "{ Jack -> (14,1), Jill -> (17,2) }"
- ---- check Result end
- ---- create list.make
- ---- Result:= list.list (bb) ~ "Jack Jill "
- ---- check Result end
- ------ -- Add birthday for Max
- ------ bb.put (max, [17,02])
- ------ assert_equal ("Max's birthday", bb.model[max], feb17)
- ------ -- Whose birthday is Feb 17th?
- ------ a := bb.remind ([17,02])
- ------ Result := a.count = 2
- ------ and a.has (max)
- ------ and a.has (jill)
- ------ and not a.has (jack)
- ------ check Result end
- ------ -- check efficienthash table implementation
- ------ across bb.model as cursor loop
- ------ l_name := cursor.item.first
- ------ l_birthday := cursor.item.second
- ------ check
- ------ bb.imp.has (l_name)
- ------ and then bb.imp[l_name] ~ l_birthday
- ------ end
- ------ end
- ---- end
- -- t2: BOOLEAN
- -- local
- -- newbb : BIRTHDAY_BOOK
- -- jack,jim,max : NAME
- -- b,j,m : BIRTHDAY
- -- list : LIST_NAMES
- -- do
- -- comment("t2: eiffel is the devil")
- -- create newbb.make
- -- create jack.make ("Jack")
- -- create jim.make ("Jim")
- -- create max.make ("Max")
- -- create b.make(2, 23)
- -- create j.make(1, 3)
- -- create m.make(12, 4)
- -- newbb.put (jack, b)
- -- newbb.put (jim, j)
- -- newbb.put (max, m)
- -- create list.make
- -- Result := ("Jack Jim Max " ~ list.list(newbb).out)
- -- check Result end
- -- end
- -- t3: BOOLEAN
- -- local
- -- newbbsingle : BIRTHDAY_BOOK_SINGLE
- -- newbb1 : BIRTHDAY_BOOK
- -- newbb2 : BIRTHDAY_BOOK
- -- newbb3 : BIRTHDAY_BOOK
- -- jack,jim,max : NAME
- -- b,j,m : BIRTHDAY
- -- list : LIST_NAMES
- -- do
- -- comment("t3: compile = zero marks")
- -- newbb1 := newbbsingle.execute
- -- newbb2 := newbbsingle.execute
- -- create newbb3.make
- -- Result:= (newbb1 ~ newbb2)
- -- check Result end
- -- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement