Advertisement
Guest User

Untitled

a guest
Apr 8th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Eiffel 3.59 KB | None | 0 0
  1. note
  2.     description: "Test BIRTHDAY_BOOK"
  3.     author: ""
  4.     date: "$Date$"
  5.     revision: "$Revision$"
  6.  
  7. class
  8.     TESTS
  9. inherit
  10.     ES_TEST
  11.  
  12. create
  13.     make
  14.  
  15. feature {NONE} -- Initialization
  16.  
  17.     make
  18.             -- create test suite
  19.         do
  20.             add_boolean_case (agent t1)
  21.             add_boolean_case (agent t2)
  22.             add_boolean_case (agent t3)
  23.             add_boolean_case (agent t4)
  24.         end
  25.  
  26. feature -- tests
  27.  
  28.     t1: BOOLEAN
  29.         local
  30.             app : APP[INTEGER,STRING]
  31.             a : ARRAY[INTEGER]
  32.         do
  33.             create app.make
  34.             create a.make_empty
  35.  
  36.             Result:= not (app.item_exists (10, a))
  37.  
  38.             check Result end
  39.         end
  40.  
  41.     t2: BOOLEAN
  42.         local
  43.             app : APP[INTEGER,STRING]
  44.         do
  45.             create app.make
  46.  
  47.             Result := app.item_exists2 (2, <<6,4,8,3,2>>)
  48.  
  49.             check Result end
  50.         end
  51.  
  52.     t3: BOOLEAN
  53.         local
  54.             app : APP[INTEGER,STRING]
  55.         do
  56.             create app.make
  57.  
  58.             Result := app.item_exists3 (2, <<6,4,8,3,2>>)
  59.  
  60.             check Result end
  61.         end
  62.  
  63.     t4: BOOLEAN
  64.         local
  65.             app : APP[INTEGER,STRING]
  66.         do
  67.             create app.make_from_array (<<1,2,3,4,5,5>>, <<"one","two","three","four">>)
  68.  
  69.             Result := not(app.is_function)
  70.  
  71.             check Result end
  72.         end
  73.  
  74. --  t1: BOOLEAN
  75. --      local
  76. --          feb17: BIRTHDAY
  77. --          bb: BIRTHDAY_BOOK
  78. --          bb2: BIRTHDAY_BOOK
  79. --          singleton : BIRTHDAY_BOOK_SINGLE
  80. --          a: ARRAY[NAME]
  81. --          l_name: NAME
  82. --          l_birthday: BIRTHDAY
  83. --          jack,jill,max: NAME
  84. --          list: LIST_NAMES
  85. --      do
  86. --          comment("t1: test birthday book")
  87. --          create jack.make ("Jack"); create jill.make ("Jill")
  88. --          create max.make ("Max")
  89. --          create feb17.make (02, 17) -- Feb 17
  90.  
  91.  
  92. --          bb.put (jack, [14,01])  -- Jan 14
  93. ----            bb.put (jill, [17,02])  -- Feb 17
  94. ----            Result := bb.model.count = 2
  95. ----                and bb.model[jack].as_array.at (1) ~ [14,01]
  96. ----                and bb.model[jill].as_array.at (1) ~ [17,02]
  97. ----                and bb.out ~ "{ Jack -> (14,1), Jill -> (17,2) }"
  98. ----            check Result end
  99. ----            create list.make
  100.  
  101. ----            Result:= list.list (bb) ~ "Jack Jill "
  102. ----            check Result end
  103.  
  104. ------          -- Add birthday for Max
  105. ------          bb.put (max, [17,02])
  106. ------          assert_equal ("Max's birthday", bb.model[max], feb17)
  107. ------          -- Whose birthday is Feb 17th?
  108. ------          a := bb.remind ([17,02])
  109. ------          Result := a.count = 2
  110. ------              and a.has (max)
  111. ------              and a.has (jill)
  112. ------              and not a.has (jack)
  113. ------          check Result end
  114. ------          -- check efficienthash table implementation
  115. ------          across bb.model as cursor loop
  116. ------              l_name := cursor.item.first
  117. ------              l_birthday := cursor.item.second
  118. ------              check
  119. ------                  bb.imp.has (l_name)
  120. ------                  and then bb.imp[l_name] ~ l_birthday
  121. ------              end
  122. ------          end
  123. ----        end
  124.  
  125. --      t2: BOOLEAN
  126. --      local
  127. --          newbb : BIRTHDAY_BOOK
  128. --          jack,jim,max : NAME
  129. --          b,j,m : BIRTHDAY
  130. --          list : LIST_NAMES
  131. --      do
  132. --          comment("t2: eiffel is the devil")
  133. --          create newbb.make
  134. --          create jack.make ("Jack")
  135. --          create jim.make ("Jim")
  136. --          create max.make ("Max")
  137.  
  138. --          create b.make(2, 23)
  139. --          create j.make(1, 3)
  140. --          create m.make(12, 4)
  141.  
  142. --          newbb.put (jack, b)
  143. --          newbb.put (jim, j)
  144. --          newbb.put (max, m)
  145.  
  146. --          create list.make
  147.  
  148. --          Result := ("Jack Jim Max " ~ list.list(newbb).out)
  149.  
  150. --          check Result end
  151. --      end
  152.  
  153. --      t3: BOOLEAN
  154. --      local
  155.  
  156. --          newbbsingle : BIRTHDAY_BOOK_SINGLE
  157. --          newbb1 : BIRTHDAY_BOOK
  158. --          newbb2 : BIRTHDAY_BOOK
  159. --          newbb3 : BIRTHDAY_BOOK
  160. --          jack,jim,max : NAME
  161. --          b,j,m : BIRTHDAY
  162. --          list : LIST_NAMES
  163. --      do
  164. --          comment("t3: compile = zero marks")
  165.  
  166. --          newbb1 := newbbsingle.execute
  167. --          newbb2 := newbbsingle.execute
  168.  
  169. --          create newbb3.make
  170.  
  171. --          Result:= (newbb1 ~ newbb2)
  172.  
  173. --          check Result end
  174. --      end
  175.  
  176. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement