@@ -53,7 +53,8 @@ function runTests() {
5353 assert ( typeof libCacheSim . runSim === 'function' , 'runSim function exists' ) &&
5454 assert ( typeof libCacheSim . runSimulation === 'function' , 'runSimulation function exists' ) &&
5555 assert ( typeof libCacheSim . getSupportedAlgorithms === 'function' , 'getSupportedAlgorithms function exists' ) &&
56- assert ( typeof libCacheSim . getSupportedTraceTypes === 'function' , 'getSupportedTraceTypes function exists' ) ;
56+ assert ( typeof libCacheSim . getSupportedTraceTypes === 'function' , 'getSupportedTraceTypes function exists' ) &&
57+ assert ( typeof libCacheSim . getVersion === 'function' , 'getVersion function exists' ) ;
5758 } ) ;
5859
5960 // Test 2: Check supported algorithms
@@ -75,7 +76,15 @@ function runTests() {
7576 assert ( traceTypes . includes ( 'csv' ) , 'Includes CSV' ) ;
7677 } ) ;
7778
78- // Test 4: Run default simulation
79+ // Test 4: Check version function
80+ test ( 'Get version' , ( ) => {
81+ const version = libCacheSim . getVersion ( ) ;
82+ return assert ( typeof version === 'string' , 'Returns a string' ) &&
83+ assert ( version . length > 0 , 'Version is not empty' ) &&
84+ assert ( / ^ \d + \. \d + \. \d + / . test ( version ) , 'Version follows semantic versioning format' ) ;
85+ } ) ;
86+
87+ // Test 5: Run default simulation
7988 test ( 'Run default simulation' , ( ) => {
8089 const result = libCacheSim . runSim ( ) ;
8190 return assert ( typeof result === 'object' , 'Returns an object' ) &&
@@ -88,7 +97,7 @@ function runTests() {
8897 assert ( Math . abs ( result . hitRatio + result . missRatio - 1.0 ) < 0.0001 , 'Hit ratio + miss ratio ≈ 1.0' ) ;
8998 } ) ;
9099
91- // Test 5 : Run custom simulation with different algorithms
100+ // Test 6 : Run custom simulation with different algorithms
92101 test ( 'Run custom simulations with different algorithms' , ( ) => {
93102 const algorithms = [ 'lru' , 'fifo' , 's3fifo' ] ;
94103 let allPassed = true ;
@@ -110,7 +119,7 @@ function runTests() {
110119 return allPassed ;
111120 } ) ;
112121
113- // Test 6 : Test different cache sizes
122+ // Test 7 : Test different cache sizes
114123 test ( 'Test different cache sizes' , ( ) => {
115124 const sizes = [ '512kb' , '1mb' , '2mb' ] ;
116125 let allPassed = true ;
@@ -131,7 +140,7 @@ function runTests() {
131140 return allPassed ;
132141 } ) ;
133142
134- // Test 7 : Error handling - invalid trace file
143+ // Test 8 : Error handling - invalid trace file
135144 test ( 'Error handling for invalid trace file' , ( ) => {
136145 try {
137146 libCacheSim . runSimulation ( '/nonexistent/file.vscsi' , 'vscsi' , 'lru' , '1mb' ) ;
@@ -141,7 +150,7 @@ function runTests() {
141150 }
142151 } ) ;
143152
144- // Test 8 : Error handling - invalid algorithm
153+ // Test 9 : Error handling - invalid algorithm
145154 test ( 'Error handling for invalid algorithm' , ( ) => {
146155 try {
147156 libCacheSim . runSimulation ( '../data/cloudPhysicsIO.vscsi' , 'vscsi' , 'invalid_algo' , '1mb' ) ;
@@ -151,7 +160,7 @@ function runTests() {
151160 }
152161 } ) ;
153162
154- // Test 9 : Error handling - invalid trace type
163+ // Test 10 : Error handling - invalid trace type
155164 test ( 'Error handling for invalid trace type' , ( ) => {
156165 try {
157166 libCacheSim . runSimulation ( '../data/cloudPhysicsIO.vscsi' , 'invalid_type' , 'lru' , '1mb' ) ;
@@ -161,7 +170,7 @@ function runTests() {
161170 }
162171 } ) ;
163172
164- // Test 10 : Performance test - measure execution time
173+ // Test 11 : Performance test - measure execution time
165174 test ( 'Performance measurement' , ( ) => {
166175 const startTime = process . hrtime . bigint ( ) ;
167176 const result = libCacheSim . runSim ( ) ;
0 commit comments