File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ local res_type = world .get_type_by_name (" TestResourceWithVariousFields" )
2+ local res = world .get_resource (res_type )
3+
4+ local map = res .string_map
5+
6+ local count = 0
7+ local found_keys = {}
8+
9+ -- ipairs_clone on a map returns (index, [key, value]) where value is a list
10+ for i , entry in map :ipairs_clone () do
11+ assert (i == count + 1 , " Index should be sequential: expected " .. (count + 1 ) .. " , got " .. i )
12+
13+ -- entry should be a list with [key, value]
14+ assert (entry ~= nil , " Entry should not be nil" )
15+ assert (entry [1 ] ~= nil , " Key should not be nil" )
16+ assert (entry [2 ] ~= nil , " Value should not be nil" )
17+
18+ local key = entry [1 ]
19+ local value = entry [2 ]
20+
21+ count = count + 1
22+ found_keys [key ] = value
23+ end
24+
25+ assert (count == 2 , " Expected 2 entries, got " .. count )
26+ assert (found_keys [" foo" ] == " bar" , " Expected foo=>bar, got " .. tostring (found_keys [" foo" ]))
27+ assert (found_keys [" zoo" ] == " zed" , " Expected zoo=>zed, got " .. tostring (found_keys [" zoo" ]))
You can’t perform that action at this time.
0 commit comments