@@ -160,53 +160,3 @@ export function generateAlphaAbbreviation(word: string): string | null {
160160 return null ;
161161}
162162
163- /*** Test isValidAlphaAbbreviation function */
164- console . log ( '\n=== Testing isValidAlphaAbbreviation ===' ) ;
165- // Example 1 from the README
166- const test1 = isValidAlphaAbbreviation ( 'internationalization' , 'imzdn' ) ;
167- console . log ( 'Test 1 (internationalization, imzdn):' , test1 ? 'PASS' : 'FAIL' ) ;
168- // i + (m=13 chars) + z + (d=4 chars) + n
169- // i + nternationaliza + z + atio + n = internationalization
170- // Example 2 from the README
171- const test2 = isValidAlphaAbbreviation ( 'substitution' , 'sjn' ) ;
172- console . log ( 'Test 2 (substitution, sjn):' , test2 ? 'PASS' : 'FAIL' ) ;
173- // s + (j=10 chars) + n
174- // s + ubstitutio + n = substitution
175- // Invalid example from the README
176- const test3 = isValidAlphaAbbreviation ( 'test' , 'ab' ) ;
177- console . log ( 'Test 3 (test, ab):' , ! test3 ? 'PASS' : 'FAIL' ) ;
178- // Adjacent letters 'a' and 'b' would represent adjacent abbreviated substrings
179- // Edge cases
180- console . log ( 'Test 4 (apple, aple):' , isValidAlphaAbbreviation ( 'apple' , 'aple' ) === false ? 'PASS' : 'FAIL' ) ;
181- console . log ( 'Test 5 (apple, ae):' , isValidAlphaAbbreviation ( 'apple' , 'ae' ) === true ? 'PASS' : 'FAIL' ) ;
182- // a + (e=5 chars) = apple (but there are only 4 chars after 'a', so this should fail)
183- console . log ( 'Test 6 (a, a):' , isValidAlphaAbbreviation ( 'a' , 'a' ) === true ? 'PASS' : 'FAIL' ) ;
184- console . log ( 'Test 7 (a, b):' , isValidAlphaAbbreviation ( 'a' , 'b' ) === false ? 'PASS' : 'FAIL' ) ;
185- /**
186- * Test createFirstLetterAbbreviation function
187- */
188- console . log ( '\n=== Testing createFirstLetterAbbreviation ===' ) ;
189- console . log ( 'Test 8 (world wide web):' , createFirstLetterAbbreviation ( 'world wide web' ) === 'www' ? 'PASS' : 'FAIL' ) ;
190- console . log ( 'Test 9 (United States of America):' , createFirstLetterAbbreviation ( 'United States of America' ) === 'USoA' ? 'PASS' : 'FAIL' ) ;
191- console . log ( 'Test 10 (empty string):' , createFirstLetterAbbreviation ( '' ) === '' ? 'PASS' : 'FAIL' ) ;
192- console . log ( 'Test 11 (single word):' , createFirstLetterAbbreviation ( 'hello' ) === 'h' ? 'PASS' : 'FAIL' ) ;
193- /**
194- * Test generateAlphaAbbreviation function
195- */
196- console . log ( '\n=== Testing generateAlphaAbbreviation ===' ) ;
197- // Test short words
198- console . log ( 'Test 12 (abc):' , generateAlphaAbbreviation ( 'abc' ) === 'abc' ? 'PASS' : 'FAIL' ) ;
199- // Test medium words
200- const test13 = generateAlphaAbbreviation ( 'laptop' ) ;
201- console . log ( 'Test 13 (laptop):' , isValidAlphaAbbreviation ( 'laptop' , test13 ! ) ? 'PASS' : 'FAIL' ) ;
202- // Test longer words
203- const test14 = generateAlphaAbbreviation ( 'internationalization' ) ;
204- console . log ( 'Test 14 (internationalization):' ,
205- test14 !== null && isValidAlphaAbbreviation ( 'internationalization' , test14 ) ? 'PASS' : 'FAIL' ) ;
206- // Show the generated abbreviations
207- console . log ( '\n=== Generated Abbreviations ===' ) ;
208- console . log ( 'laptop:' , generateAlphaAbbreviation ( 'laptop' ) ) ;
209- console . log ( 'internationalization:' , generateAlphaAbbreviation ( 'internationalization' ) ) ;
210- console . log ( 'programming:' , generateAlphaAbbreviation ( 'programming' ) ) ;
211- console . log ( 'typescript:' , generateAlphaAbbreviation ( 'typescript' ) ) ;
212-
0 commit comments