Ticket #250: regression_fix_1_of_1_rev_01c8cc076b08_Issue__250__Smalltak_X_is_reading_Windows_Registry_only_in_ASCII_but_registry_is_UTF16.patch

File regression_fix_1_of_1_rev_01c8cc076b08_Issue__250__Smalltak_X_is_reading_Windows_Registry_only_in_ASCII_but_registry_is_UTF16.patch, 18.1 KB (added by patrik.svestka@…, 5 years ago)

additiona tests for index methods

  • RegressionTests__Win32OperatingSystemTest.st

    # HG changeset patch
    # User Patrik Svestka <patrik.svestka@gmail.com>
    # Date 1544543094 -3600
    #      Tue Dec 11 16:44:54 2018 +0100
    # Branch jv
    # Node ID 01c8cc076b087fc0575704fd6f31a5ff45315cc9
    # Parent  8e0b72418799ccb1446265ac293e83d8cc87cfa4
    Issue #250: Smalltak/X is reading Windows Registry only in ASCII but registry is UTF16
     - adding tests for index methods where the index is trying to get non-existent value/subKey -> nil is returned
    
    diff -r 8e0b72418799 -r 01c8cc076b08 RegressionTests__Win32OperatingSystemTest.st
    a b  
    400400
    401401!Win32OperatingSystemTest methodsFor:'tests-unicodeRead'!
    402402
    403 testReadSubKeyAtIndex
     403testReadSubKeyAtIndex_01
    404404    "Reading subKeys at certain index
    405405    WARNING: subKeyAtIndex: is zero based!!!!!!"
    406406
     
    415415    self assert: (readData path copyAfterLast: $\) = ' ルすしか'
    416416
    417417    "
    418      self run:#testReadSubKeyAtIndex
    419      self new testReadSubKeyAtIndex
     418     self run:#testReadSubKeyAtIndex_01
     419     self new testReadSubKeyAtIndex_01
    420420    "
    421421
    422     "Created: / 05-12-2018 / 12:39:45 / svestkap"
     422    "Created: / 11-12-2018 / 14:51:12 / svestkap"
    423423!
    424424
    425 testReadSubKeyAtIndex_MaxPath
    426     "reading subKeyAtIndex with max Path
    427      Note: This test acually breaks the limit that Microsoft specified in MSDN - registry key name should be maximum 255 characters including absolute path
    428      MSDN link: https://docs.microsoft.com/en-us/windows/desktop/sysinfo/registry-element-size-limits"
     425testReadSubKeyAtIndex_02
     426    "Reading subKeys at certain index - reading non-existent subKey
     427    WARNING: subKeyAtIndex: is zero based!!!!!!"
    429428
    430429    | readData testingRegistryPath |
    431430
    432     "/readData := Unicode16String new.   
    433     testingRegistryPath := Win32OperatingSystem registryEntry key:
    434         (registryPath,'\', ' ルすしか\256_chars_max_long|arsdfasdfjljljasdf;jl;jljsfasdfasdfljaslkdfjkasdfljalsd;jfa;lsdjflkasjdflkajsdflkjasdflkjsadlfjasldfjlsadjflksdjflksadjflkajsdflkjasdlfjalskdjflkasdjflkasdfkj;sdaf;kljkkjkklkjjjjkas|1asdfjsldfjlasdlfjlasdjfljasdlfjalsdjflajdfsdsasdfa|end').       
    435    
    436     readData := testingRegistryPath subKeyAtIndex: 0.
     431    readData := Unicode16String new.   
     432    testingRegistryPath := Win32OperatingSystem registryEntry key: registryPath.
     433
     434    readData := testingRegistryPath subKeyAtIndex: 10.
    437435
    438     self assert: readData path notEmptyOrNil.
    439     self assert:(readData path endsWith: '|end').   
     436    self assert: readData isNil
    440437
    441     "/ this is maximum path size which can be reached if the SubKey is reached via index
    442     self assert: readData path size = 563. "/ there is one backslash (for path) more compared to testReadSubKeyNamesAndClassesAtIndex_MaxPath_01
    443    
    444438    "
    445      self run:#testReadSubKeyAtIndex_MaxPath
    446      self new testReadSubKeyAtIndex_MaxPath
     439     self run:#testReadSubKeyAtIndex_02
     440     self new testReadSubKeyAtIndex_02
    447441    "
    448442
    449     "Created: / 05-12-2018 / 12:39:54 / svestkap"
     443    "Created: / 11-12-2018 / 14:49:03 / svestkap"
    450444!
    451445
    452 testReadSubKeyNamesAndClassesAtIndex_MaxPath
    453     "reading SubKeyNamesAndClasses with max Path
    454      Note: This test acually breaks the limit that Microsoft specified in MSDN - registry key name should be maximum 255 characters including absolute path
    455      MSDN link: https://docs.microsoft.com/en-us/windows/desktop/sysinfo/registry-element-size-limits"
     446testReadSubKeyNamesAndClassesAtIndex_01
     447    "reading SubKeyNamesAndClasses - reading non-existent subKey"
    456448
    457449    | readData testingRegistryPath |
    458450
     
    460452    testingRegistryPath := Win32OperatingSystem registryEntry key:
    461453        (registryPath,'\', ' ルすしか\256_chars_max_long|arsdfasdfjljljasdf;jl;jljsfasdfasdfljaslkdfjkasdfljalsd;jfa;lsdjflkasjdflkajsdflkjasdflkjsadlfjasldfjlsadjflksdjflksadjflkajsdflkjasdlfjalskdjflkasdjflkasdfkj;sdaf;kljkkjkklkjjjjkas|1asdfjsldfjlasdlfjlasdjfljasdlfjalsdjflajdfsdsasdfa|end').       
    462454   
    463     readData := testingRegistryPath subKeyNameAndClassAtIndex: 0.
    464 
    465     self assert: readData notEmptyOrNil.
    466     self assert:(readData first endsWith: '|end').
    467     self assert: readData first = '256_chars_max_long|arsdfasdfjljljasdf;jl;jljsfasdfasdfljaslkdfjkasdfljalsd;jfa;lsdjflkasjdflkajsdflkjasdflkjsadlfjasldfjlsadjflksdjflksadjflkajsdflkjasdlfjalskdjflkasdjflkasdfkj;sdaf;kljkkjkklkjjjjkas|1asdfjsldfjlasdlfjlasdjfljasdlfjalsdjflajdfsdsasdfa|end'.       
     455    readData := testingRegistryPath subKeyNameAndClassAtIndex: 10.
    468456
    469     "/ this is maximum path size which can be reached if the SubKey is reached via index
    470     self assert: (testingRegistryPath path size + readData first size) = 562.
    471    
     457    self assert: readData isNil.       
    472458    "
    473      self run:#testReadSubKeyNamesAndClassesAtIndex_MaxPath
    474      self new testReadSubKeyNamesAndClassesAtIndex_MaxPath
     459     self run:#testReadSubKeyNamesAndClassesAtIndex_01
     460     self new testReadSubKeyNamesAndClassesAtIndex_01
    475461    "
    476462
    477     "Created: / 05-12-2018 / 12:40:08 / svestkap"
     463    "Created: / 11-12-2018 / 14:49:48 / svestkap"
    478464!
    479465
    480 testReadTooLongPath
    481     "Trying to read too long path - if you try to read such a long path it just returns nil"
    482 
    483     | testingRegistryPath |
    484    
    485     testingRegistryPath := Win32OperatingSystem registryEntry key:
    486             (registryPath,'\', ' ルすしか\256_chars_max_long|arsdfasdfjljljasdf;jl;jljsfasdfasdfljaslkdfjkasdfljalsd;jfa;lsdjflkasjdflkajsdflkjasdflkjsadlfjasldfjlsadjflksdjflksadjflkajsdflkjasdlfjalskdjflkasdjflkasdfkj;sdaf;kljkkjkklkjjjjkas|1asdfjsldfjlasdlfjlasdjfljasdlfjalsdjflajdfsdsasdfa
    487             |end','\','256_chars_max_long|arsdfasdfjljljasdf;jl;jljsfasdfasdfljaslkdfjkasdfljalsd;jfa;lsdjflkasjdflkajsdflkjasdflkjsadlfjasldfjlsadjflksdjflksadjflkajsdflkjasdlfjalskdjflkasdjflkasdfkj;sdaf;kljkkjkklkjjjjkas|1asdfjsldfjlasdlfjlasdjfljasdlfjalsdjflajdfsdsasdfa|end').       
    488 
    489     self assert: testingRegistryPath isNil           
    490    
    491     "
    492      self run:#testReadTooLongPath
    493      self new testReadTooLongPath
    494     "
    495 
    496     "Created: / 22-11-2018 / 11:19:51 / svestkap"
    497     "Modified (format): / 05-12-2018 / 12:38:58 / svestkap"
    498 !
    499 
    500 testReadValueNameAtIndex
     466testReadValueNameAtIndex_01
    501467    "Reading values (#valueNameAtIndex:) at certain index
    502468    WARNING: #valueNameAtIndex: is zero based!!!!!!
    503469    Note: This test acually breaks the limit that Microsoft specified in MSDN - registry key name should be maximum 255 characters including absolute path
     
    518484     self new testReadValueNameAtIndex
    519485    "
    520486
    521     "Created: / 05-12-2018 / 12:40:21 / svestkap"
    522 !
    523 
    524 testReadValueNamed_REG_BINARY_01
    525     "Testing if REG_BINARY values are read correctly via valueNamed:"
    526 
    527     | readData testingRegistryPath |
    528        
    529     testingRegistryPath := Win32OperatingSystem registryEntry key: registryPath.
    530      
    531     readData := testingRegistryPath valueNamed: 'zero'.
    532        
    533     self assert: readData = ByteArray new.
    534 
    535     "
    536      self run:#testReadValueNamed_REG_BINARY_01
    537      self new testReadValueNamed_REG_BINARY_01
    538     "
    539 
    540     "Created: / 16-11-2018 / 12:37:50 / svestkap"
    541 !
    542 
    543 testReadValueNamed_REG_BINARY_02
    544     "Testing if REG_BINARY values are read correctly via valueNamed:"
    545 
    546     | testingRegistryPath readData readDataHex |
    547        
    548     testingRegistryPath := Win32OperatingSystem registryEntry key: registryPath.
    549      
    550     readData := testingRegistryPath valueNamed: 'non-zero'.       
    551     readDataHex := readData hexPrintStringWithSeparator: $|.
    552    
    553     self assert: readData = #[17 16]. "/ ByteArray
    554     self assert: readDataHex = '11|10' "/ hex   
    555    
    556     "
    557      self run:#testReadValueNamed_REG_BINARY_02
    558      self new testReadValueNamed_REG_BINARY_02
    559     "
    560 
    561     "Created: / 16-11-2018 / 12:39:33 / svestkap"
    562 !
    563 
    564 testReadValueNamed_REG_DWORD_01
    565     "Testing if REG_DWORD values are read correctly via valueNamed:"
    566 
    567     | readData testingRegistryPath |
    568    
    569     readData := Unicode16String new.   
    570     testingRegistryPath := Win32OperatingSystem registryEntry key: registryPath.
    571      
    572     readData := testingRegistryPath valueNamed: 'dword_value'.
    573        
    574     self assert: readData = 9135.
    575 
    576     "
    577      self run:#testReadValueNamed_REG_DWORD_01
    578      self new testReadValueNamed_REG_DWORD_01
    579     "
    580 
    581     "Created: / 16-11-2018 / 12:24:26 / svestkap"
    582 !
    583 
    584 testReadValueNamed_REG_DWORD_02
    585     "Testing if REG_DWORD values are read correctly via valueNamed:"
    586 
    587     | readData testingRegistryPath |
    588    
    589     readData := Unicode16String new.   
    590     testingRegistryPath := Win32OperatingSystem registryEntry key: registryPath.
    591      
    592     readData := testingRegistryPath valueNamed: 'き'.
    593        
    594     self assert: readData = 591541423.
    595 
    596     "
    597      self run:#testReadValueNamed_REG_DWORD_02
    598      self new testReadValueNamed_REG_DWORD_02
    599     "
    600 
    601     "Created: / 16-11-2018 / 12:24:43 / svestkap"
     487    "Created: / 11-12-2018 / 14:54:37 / svestkap"
    602488!
    603489
    604 testReadValueNamed_REG_EXPAND_SZ_01
    605     "Testing if REG_EXPAND_SZ values are read correctly via valueNamed:"
    606 
    607     | readData testingRegistryPath |
    608    
    609     readData := Unicode16String new.   
    610     testingRegistryPath := Win32OperatingSystem registryEntry key: registryPath.
    611      
    612     readData := testingRegistryPath valueNamed: ' č ルすしか'.
    613        
    614     self assert: readData = '''Testing Unicode chars ř ž č ルすしかき'').          '.
    615 
    616     "
    617      self run:#testReadValueNamed_REG_EXPAND_SZ_01
    618      self new testReadValueNamed_REG_EXPAND_SZ_01
    619     "
    620 
    621     "Created: / 16-11-2018 / 12:27:58 / svestkap"
    622 !
    623 
    624 testReadValueNamed_REG_EXPAND_SZ_02
    625     "Testing if REG_EXPAND_SZ values are read correctly via valueNamed:"
    626 
    627     | readData testingRegistryPath |
    628    
    629     readData := Unicode16String new.   
    630     testingRegistryPath := Win32OperatingSystem registryEntry key: registryPath.
    631      
    632     readData := testingRegistryPath valueNamed: 'Ugh'.
    633        
    634     self assert: readData = '''Testing Unicode chars ř ž č ルすしかき'').          '.
    635 
    636     "
    637      self run:#testReadValueNamed_REG_EXPAND_SZ_02
    638      self new testReadValueNamed_REG_EXPAND_SZ_02
    639     "
    640 
    641     "Created: / 16-11-2018 / 12:29:52 / svestkap"
    642 !
    643 
    644 testReadValueNamed_REG_MULTI_SZ_01
    645     "Testing if REG_MULTI_SZ values are read correctly via valueNamed:"
    646 
    647     | readData testingRegistryPath |
    648        
    649     testingRegistryPath := Win32OperatingSystem registryEntry key: registryPath.
    650      
    651     readData := testingRegistryPath valueNamed: 'Font_Leelawadee UI Bold'.
    652        
    653     self assert: readData = #('SEGOEUIB.TTF,Segoe UI Bold,110,82' 'SEGOEUIB.TTF,Segoe UI Bold' 'MEIRYOB.TTC,Meiryo UI Bold,120,96'
    654                               'MEIRYOB.TTC,Meiryo UI Bold' 'MSJHBD.TTC,Microsoft JhengHei UI Bold,120,96' 'MSJHBD.TTC,Microsoft JhengHei UI Bold'
    655                               'MSYHBD.TTC,Microsoft YaHei UI Bold,128,96' 'MSYHBD.TTC,Microsoft YaHei UI Bold' 'MALGUNBD.TTF,Malgun Gothic Bold,118,96'
    656                               'MALGUNBD.TTF,Malgun Gothic Bold' 'YUGOTHB.TTC,Yu Gothic UI Bold,128,96' 'YUGOTHB.TTC,Yu Gothic UI Bold' 'SEGUISYM.TTF,Segoe UI Symbol')
    657 
    658     "
    659      self run:#testReadValueNamed_REG_MULTI_SZ_01
    660      self new testReadValueNamed_REG_MULTI_SZ_01
    661     "
    662 
    663     "Created: / 16-11-2018 / 12:30:24 / svestkap"
    664 !
    665 
    666 testReadValueNamed_REG_MULTI_SZ_02
    667     "Testing if REG_MULTI_SZ values are read correctly via valueNamed:"
    668 
    669     | readData testingRegistryPath |
    670        
    671     testingRegistryPath := Win32OperatingSystem registryEntry key: registryPath.
    672      
    673     readData := testingRegistryPath valueNamed: 'ř ž č ルすしか'.
    674        
    675     self assert: readData = #('''Testing Unicode chars ř ž č ルすしかき'')'
    676                               'SEGOEUIB.TTF,Segoe UI Bold,110,82' 'SEGOEUIB.TTF,Segoe UI Bold' 'MEIRYOB.TTC,Meiryo UI Bold,120,96'
    677                               'MEIRYOB.TTC,Meiryo UI Bold' 'MSJHBD.TTC,Microsoft JhengHei UI Bold,120,96' 'MSJHBD.TTC,Microsoft JhengHei UI Bold'
    678                               'MSYHBD.TTC,Microsoft YaHei UI Bold,128,96' 'MSYHBD.TTC,Microsoft YaHei UI Bold' 'MALGUNBD.TTF,Malgun Gothic Bold,118,96'
    679                               'MALGUNBD.TTF,Malgun Gothic Bold' 'YUGOTHB.TTC,Yu Gothic UI Bold,128,96' 'YUGOTHB.TTC,Yu Gothic UI Bold' 'SEGUISYM.TTF,Segoe UI Symbol')
    680 
    681     "
    682      self run:#testReadValueNamed_REG_MULTI_SZ_02
    683      self new testReadValueNamed_REG_MULTI_SZ_02
    684     "
    685 
    686     "Created: / 16-11-2018 / 12:35:57 / svestkap"
    687 !
    688 
    689 testReadValueNamed_REG_MULTI_SZ_03
    690     "Testing if empty REG_MULTI_SZ value is read correctly via valueNamed:"
     490testReadValueNameAtIndex_02
     491    "Reading values (#valueNameAtIndex:) at certain index - non-existent value"
    691492
    692493    | readData testingRegistryPath |
    693        
    694     testingRegistryPath := Win32OperatingSystem registryEntry key: registryPath.
    695      
    696     readData := testingRegistryPath valueNamed: 'testEmptyMultiSZ'.
    697    
    698     self assert: readData isEmpty
    699494
    700     "
    701      self run:#testReadValueNamed_REG_MULTI_SZ_03
    702      self new testReadValueNamed_REG_MULTI_SZ_03
    703     "
     495    readData := Unicode16String new.   
     496    testingRegistryPath := Win32OperatingSystem registryEntry key: (registryPath,'\', ' ルすしか').
    704497
    705     "Created: / 03-12-2018 / 10:59:48 / svestkap"
    706 !
    707 
    708 testReadValueNamed_REG_QWORD_01
    709     "Testing if REG_QWORD values are read correctly via valueNamed:
    710      The read value is a QWORD maximum value"
     498    readData := testingRegistryPath valueNameAtIndex: 100.
    711499
    712     | readData testingRegistryPath |
    713    
    714     readData := Unicode16String new.   
    715     testingRegistryPath := Win32OperatingSystem registryEntry key: registryPath.
    716      
    717     readData := testingRegistryPath valueNamed: 'qword_max'.
    718        
    719     self assert: readData = 18446744073709551615.
     500    self assert: readData isNil   
    720501
    721502    "
    722      self run:#testReadValueNamed_REG_QWORD_01
    723      self new testReadValueNamed_REG_QWORD_01
    724     "
    725 
    726     "Created: / 16-11-2018 / 12:25:47 / svestkap"
    727     "Modified (comment): / 05-12-2018 / 12:38:09 / svestkap"
    728 !
    729 
    730 testReadValueNamed_REG_QWORD_02
    731     "Testing if REG_QWORD values are read correctly via valueNamed:"
    732 
    733     | readData testingRegistryPath |
    734    
    735     readData := Unicode16String new.   
    736     testingRegistryPath := Win32OperatingSystem registryEntry key: registryPath.
    737      
    738     readData := testingRegistryPath valueNamed: 'qwordvalue'.
    739        
    740     self assert: readData = 8751636011737964973.
    741 
    742     "
    743      self run:#testReadValueNamed_REG_QWORD_02
    744      self new testReadValueNamed_REG_QWORD_02
    745     "
    746 
    747     "Created: / 16-11-2018 / 12:26:23 / svestkap"
    748 !
    749 
    750 testReadValueNamed_REG_QWORD_03
    751     "Testing if REG_QWORD values are read correctly via valueNamed:"
    752 
    753     | readData testingRegistryPath |
    754    
    755     readData := Unicode16String new.   
    756     testingRegistryPath := Win32OperatingSystem registryEntry key: registryPath.
    757      
    758     readData := testingRegistryPath valueNamed: 'すし'.
    759        
    760     self assert: readData asSmallInteger = 44527.
    761 
    762     "
    763      self run:#testReadValueNamed_REG_QWORD_03
    764      self new testReadValueNamed_REG_QWORD_03
     503     self run:#testReadValueNameAtIndex_02
     504     self new testReadValueNameAtIndex_02
    765505    "
    766506
    767     "Created: / 16-11-2018 / 12:27:17 / svestkap"
    768     "Modified: / 20-11-2018 / 12:25:05 / svestkap"
    769 !
    770 
    771 testReadValueNamed_REG_SZ_01
    772     "Testing if REG_SZ values are read correctly via valueNamed:"
    773 
    774     | readData testingRegistryPath |
    775    
    776     readData := Unicode16String new.   
    777     testingRegistryPath := Win32OperatingSystem registryEntry key: registryPath.
    778      
    779     readData := testingRegistryPath valueNamed: 'bledesu'.
    780    
    781     self assert: readData = '''Testing Unicode chars ř ž č ルすしかき'').          '.
    782    
    783     "
    784      self run:#testReadValueNamed_REG_SZ_01
    785      self new testReadValueNamed_REG_SZ_01
    786     "
    787 
    788     "Created: / 16-11-2018 / 12:14:59 / svestkap"
    789 !
    790 
    791 testReadValueNamed_REG_SZ_02
    792     "Testing if REG_SZ values are read correctly via valueNamed:"
    793 
    794     | readData testingRegistryPath |
    795    
    796     readData := Unicode16String new.   
    797     testingRegistryPath := Win32OperatingSystem registryEntry key: registryPath.
    798      
    799     readData := testingRegistryPath valueNamed: ' ř ž č ル.          '.
    800        
    801     self assert: readData = 'Testing Unicode chars ř ž č ルすしかき'.   
    802 
    803     "
    804      self run:#testReadValueNamed_REG_SZ_02
    805      self new testReadValueNamed_REG_SZ_02
    806     "
    807 
    808     "Created: / 16-11-2018 / 12:15:17 / svestkap"
    809 !
    810 
    811 testReadValueNamed_REG_SZ_03
    812     "Testing if REG_SZ values are read correctly via valueNamed:"
    813 
    814     | readData testingRegistryPath |
    815    
    816     readData := Unicode16String new.   
    817     testingRegistryPath := Win32OperatingSystem registryEntry key: registryPath.
    818      
    819     readData := testingRegistryPath valueNamed: 'しかき    '.
    820        
    821     self assert: readData = 'Testus gradus'.
    822 
    823     "
    824      self run:#testReadValueNamed_REG_SZ_03
    825      self new testReadValueNamed_REG_SZ_03
    826     "
    827 
    828     "Created: / 16-11-2018 / 12:21:59 / svestkap"
    829 !
    830 
    831 testReadValueNamed_REG_SZ_04
    832     "Testing if empty REG_SZ value is read correctly via valueNamed:"
    833 
    834     | readData testingRegistryPath |
    835    
    836     readData := Unicode16String new.   
    837     testingRegistryPath := Win32OperatingSystem registryEntry key: registryPath.
    838      
    839     readData := testingRegistryPath valueNamed: 'emptyToTest'.
    840    
    841     self assert: readData isEmpty.
    842    
    843     "
    844      self run:#testReadValueNamed_REG_SZ_04
    845      self new testReadValueNamed_REG_SZ_04
    846     "
    847 
    848     "Created: / 03-12-2018 / 10:56:11 / svestkap"
    849 !
    850 
    851 testReadValueNamed_nonStringValue
    852     "Testing reading non-string value from Registry via valueNamed
    853      User should see a warning message in Transcript"
    854 
    855     | testingRegistryPath |
    856    
    857     testingRegistryPath := Win32OperatingSystem registryEntry key: registryPath.
    858    
    859     self should: [ testingRegistryPath valueNamed: 11 ] raise: Error
    860 
    861     "
    862      self run:#testReadValueNamed_nonStringValue
    863      self new testReadValueNamed_nonStringValue
    864     "
    865 
    866     "Created: / 05-12-2018 / 12:40:31 / svestkap"
    867     "Modified: / 10-12-2018 / 15:47:37 / svestkap"
     507    "Created: / 11-12-2018 / 14:54:29 / svestkap"
    868508! !
    869509
    870510!Win32OperatingSystemTest methodsFor:'tests-unicodeReadEnumeration'!