File: 022-gslist.lua

package info (click to toggle)
lua-gtk 0.8%2B20080510%2Bdash-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 1,236 kB
  • ctags: 1,308
  • sloc: ansic: 6,659; sh: 717; makefile: 114
file content (28 lines) | stat: -rwxr-xr-x 527 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#! /usr/bin/env lua
require "gtk"

-- Test GSList and gtk_stock_list_ids().

list = gtk.stock_list_ids()
list2 = list

n = 0
while list2 do
	s = list2.data:cast("string")
	assert(type(s) == "string")
	list2 = list2:nth(1)
	n = n + 1
end

-- near 100
assert(n > 50)

-- frees the whole list including the strings in it (handled by an override),
-- and the list itself.
list:free()

-- must now be something like "GSList at 0x80a1cdc/(nil)"
s = tostring(list)
assert(string.find(s, "nil"), "GSList hasn't been freed properly")