/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

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