mirror of
				https://github.com/Ukendio/jecs.git
				synced 2025-10-31 09:09:18 +00:00 
			
		
		
		
	Add null query unit tests (#69)
* Add null query unit test * Add unit test * Update unit tests * Remove __iter from already tested case
This commit is contained in:
		
							parent
							
								
									a62475471f
								
							
						
					
					
						commit
						706eded24f
					
				
					 1 changed files with 41 additions and 0 deletions
				
			
		|  | @ -471,6 +471,47 @@ TEST("world", function() | ||||||
| 		CHECK(world:get(e, B) == false) | 		CHECK(world:get(e, B) == false) | ||||||
| 		CHECK(world:get(e, C) == "hello world") | 		CHECK(world:get(e, C) == "hello world") | ||||||
| 	end | 	end | ||||||
|  | 
 | ||||||
|  | 	do CASE "should not iterate when nothing matches query" | ||||||
|  | 		local world = jecs.World.new() | ||||||
|  | 		local A = world:component() | ||||||
|  | 		local B = world:component() | ||||||
|  | 
 | ||||||
|  | 		local e1 = world:entity() | ||||||
|  | 		world:add(e1, A) | ||||||
|  | 
 | ||||||
|  | 		local count = 0 | ||||||
|  | 		for id in world:query(B) do | ||||||
|  | 			count += 1 | ||||||
|  | 		end | ||||||
|  | 
 | ||||||
|  | 		CHECK(count == 0) | ||||||
|  | 	end | ||||||
|  | 
 | ||||||
|  | 	do CASE "should return nothing for empty iteration" | ||||||
|  | 		local world = jecs.World.new() | ||||||
|  | 		local A = world:component() | ||||||
|  | 		local B = world:component() | ||||||
|  | 
 | ||||||
|  | 		local e1 = world:entity() | ||||||
|  | 		world:add(e1, A) | ||||||
|  | 
 | ||||||
|  | 		local query = world:query(B) | ||||||
|  | 		CHECK(query.next() == nil) | ||||||
|  | 		CHECK(query.replace() == nil) | ||||||
|  | 	end | ||||||
|  | 
 | ||||||
|  | 	do CASE "should properly handle query:without for empty iteration" | ||||||
|  | 		local world = jecs.World.new() | ||||||
|  | 		local A = world:component() | ||||||
|  | 		local B = world:component() | ||||||
|  | 
 | ||||||
|  | 		local e1 = world:entity() | ||||||
|  | 		world:add(e1, A) | ||||||
|  | 
 | ||||||
|  | 		local query = world:query(B) | ||||||
|  | 		CHECK(query == query:without()) | ||||||
|  | 	end | ||||||
| end) | end) | ||||||
| 
 | 
 | ||||||
| FINISH() | FINISH() | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue