mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-30 23:23:07 +00:00 
			
		
		
		
	Adding some more unit tests for various components.
This commit is contained in:
		| @@ -3,6 +3,7 @@ | ||||
|  | ||||
| int main() { | ||||
|     int64_t i; | ||||
|     dst_init(); | ||||
|     DstArray *array = dst_array(10); | ||||
|     assert(array->capacity == 10); | ||||
|     assert(array->count == 0); | ||||
|   | ||||
							
								
								
									
										19
									
								
								unittests/buffer_test.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								unittests/buffer_test.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| #include "unit.h" | ||||
| #include <dst/dst.h> | ||||
|  | ||||
| int main() { | ||||
|     dst_init(); | ||||
|     DstBuffer *buffer = dst_buffer(100); | ||||
|     assert(buffer->count == 0); | ||||
|     assert(buffer->capacity == 100); | ||||
|     dst_buffer_push_u8(buffer, 'h'); | ||||
|     dst_buffer_push_u8(buffer, 'e'); | ||||
|     dst_buffer_push_u8(buffer, 'l'); | ||||
|     dst_buffer_push_u8(buffer, 'l'); | ||||
|     dst_buffer_push_u8(buffer, 'o'); | ||||
|     assert(dst_equals( | ||||
|         dst_wrap_string(dst_cstring("hello")), | ||||
|         dst_wrap_string(dst_string(buffer->data, buffer->count)) | ||||
|     )); | ||||
|     return 0; | ||||
| } | ||||
							
								
								
									
										15
									
								
								unittests/table_test.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								unittests/table_test.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | ||||
| #include "unit.h" | ||||
| #include <dst/dst.h> | ||||
|  | ||||
| int main() { | ||||
|     dst_init(); | ||||
|     DstTable *table = dst_table(10); | ||||
|     assert(table->count == 0); | ||||
|     dst_table_put(table, dst_cstringv("a"), dst_cstringv("b")); | ||||
|     dst_table_put(table, dst_cstringv("b"), dst_cstringv("a")); | ||||
|     dst_table_put(table, dst_cstringv("a"), dst_cstringv("c")); | ||||
|     assert(table->count == 2); | ||||
|     dst_table_remove(table, dst_cstringv("a")); | ||||
|     assert(table->count == 1); | ||||
|     return 0; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 bakpakin
					bakpakin