/[eiffelstudio]/trunk/eweasel/tests/list003/test.e
ViewVC logotype

Annotation of /trunk/eweasel/tests/list003/test.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 77623 - (hide annotations)
Fri Mar 6 22:14:15 2009 UTC (10 years, 7 months ago) by manus
File size: 2156 byte(s)
Added test for `copy' that can sometime wipe out the content of a LINKED_LIST if you apply `copy' to
  yourself and that you are not empty.

1 manus 65296 class
2     TEST
3    
4     create
5    
6     make
7    
8     feature {NONE} -- Initialization
9    
10     make is
11     -- Execute test.
12     local
13     i: INTEGER
14     do
15     from
16     i := 1
17     until
18     i > Implementations
19     loop
20 manus 77623 test_twin (new_list (i), False)
21     test_twin (new_list (i), True)
22     test_copy (new_list (i), new_list (i), new_list (i), False)
23     test_copy (new_list (i), new_list (i), new_list (i), True)
24 manus 65296 i := i + 1
25     end
26     end
27    
28     feature {NONE} -- Constants
29    
30     Implementations: INTEGER is 3
31    
32     feature {NONE} -- Initialization
33    
34    
35 manus 77623 new_list (i: INTEGER): LIST [STRING] is
36 manus 65296 -- Create implementiation `i' of list.
37     require
38     defined_implementation: i >= 1 and i <= Implementations
39     do
40     inspect
41     i
42     when 1 then
43 manus 77623 create {LINKED_LIST [STRING]} Result.make
44 manus 65296 when 2 then
45 manus 77623 create {ARRAYED_LIST [STRING]} Result.make (5)
46 manus 65296 when 3 then
47 manus 77623 create {FIXED_LIST [STRING]} Result.make (5)
48 manus 65296 end
49     end
50    
51 manus 77623 test_twin (a_list: LIST [STRING]; obj_comparison: BOOLEAN) is
52 manus 65296 -- Run twin test.
53 manus 77623 -- Set comparison mode of `a_list' to `obj_comparison'.
54     local
55     l2: LIST [STRING]
56 manus 65296 do
57     if obj_comparison then
58 manus 77623 a_list.compare_objects
59 manus 65296 else
60 manus 77623 a_list.compare_references
61 manus 65296 end
62 manus 77623 a_list.extend ("foo")
63     a_list.extend ("bar")
64     a_list.extend ("baz")
65    
66     l2 := a_list.twin
67     if a_list /~ l2 then
68     io.put_string ("Failure%N")
69     end
70 manus 65296 end
71 manus 77623
72     test_copy (a_list1, a_list2, a_list3: LIST [STRING]; obj_comparison: BOOLEAN) is
73     -- Run copy test.
74     -- Set comparison mode of `a_list1' and `a_list2' to `obj_comparison'.
75     do
76     if obj_comparison then
77     a_list1.compare_objects
78     a_list2.compare_objects
79     else
80     a_list1.compare_references
81     a_list2.compare_references
82     end
83     a_list1.extend ("foo")
84     a_list1.extend ("bar")
85     a_list1.extend ("baz")
86    
87     a_list2.copy (a_list1)
88     if a_list1 /~ a_list2 then
89     io.put_string ("Failure%N")
90     end
91    
92     a_list3.extend ("bar")
93     a_list3.copy (a_list1)
94     if a_list1 /~ a_list3 then
95     io.put_string ("Failure%N")
96     end
97    
98     if a_list1.is_empty then
99     io.put_string ("Failure%N")
100     end
101     a_list1.copy (a_list1)
102     if a_list1.is_empty then
103     io.put_string ("Failure%N")
104     end
105     end
106    
107 manus 65296 end -- class TEST
108    
109    

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23