PageRenderTime 11ms CodeModel.GetById 6ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/test/lib/string/test_fixed.e

http://github.com/tybor/Liberty
Specman e | 44 lines | 35 code | 8 blank | 1 comment | 1 complexity | 2ac41499b7203bfefeb398820616c99e MD5 | raw file
 1class TEST_FIXED
 2   -- Stress fixed strings obtained from C, to discover possible memory leaks or double freeing of memory.
 3
 4insert
 5   MEMORY
 6   EXCEPTIONS
 7   EIFFELTEST_TOOLS
 8
 9create {}
10   make
11
12feature {}
13   make
14      local
15         mem_usage: INTEGER
16      do
17         mem_usage := allocated_bytes
18         n.times(agent
19            do
20               n.times(agent
21                  do
22                     create foo.from_external(foo_ptr)
23                  end)
24               full_collect
25            end)
26
27         debug
28            print("Memory usage for " + (n * n).out + " allocations: " + (allocated_bytes - mem_usage).out + " bytes.%N")
29         end
30         assert(foo.is_equal("my-const-string"))
31      end
32
33   n: INTEGER_32 16
34
35   foo: FIXED_STRING
36
37   foo_ptr: POINTER
38      external "C inline"
39      alias "[
40         "my-const-string"
41         ]"
42      end
43
44end -- class TEST_FIXED