<s> import os <EOL> import unittest <EOL> import nordicsemi . dfu . nrfhex as nrfhex <EOL> import nordicsemi . dfu . intelhex as intelhex <EOL> class TestnRFHex ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> script_abspath = os . path . abspath ( __file__ ) <EOL> script_dirname = os . path . dirname ( script_abspath ) <EOL> os . chdir ( script_dirname ) <EOL> def comparefiles ( self , actual , wanted ) : <EOL> actualfile = intelhex . IntelHex ( ) <EOL> actualfile . loadfile ( actual , format = "<STR_LIT>" ) <EOL> wantedfile = intelhex . IntelHex ( ) <EOL> wantedfile . loadfile ( wanted , format = "<STR_LIT>" ) <EOL> self . assertEqual ( actualfile . minaddr ( ) , wantedfile . minaddr ( ) ) <EOL> self . assertEqual ( actualfile . maxaddr ( ) , wantedfile . maxaddr ( ) ) <EOL> minaddress = actualfile . minaddr ( ) <EOL> maxaddress = actualfile . maxaddr ( ) <EOL> length = maxaddress - minaddress <EOL> actualfile_data = actualfile . gets ( minaddress , length ) <EOL> wantedfile_data = wantedfile . gets ( minaddress , length ) <EOL> self . assertEqual ( actualfile_data , wantedfile_data ) <EOL> def test_tobinfile_single_file_without_uicr_content ( self ) : <EOL> nrf = nrfhex . nRFHex ( "<STR_LIT>" ) <EOL> nrf . tobinfile ( "<STR_LIT>" ) <EOL> self . comparefiles ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> def test_tobinfile_single_file_with_uicr_content ( self ) : <EOL> nrf = nrfhex . nRFHex ( "<STR_LIT>" ) <EOL> nrf . tobinfile ( "<STR_LIT>" ) <EOL> self . comparefiles ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> def test_tobinfile_single_bin_file ( self ) : <EOL> nrf = nrfhex . nRFHex ( "<STR_LIT>" ) <EOL> nrf . tobinfile ( "<STR_LIT>" ) <EOL> self . comparefiles ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> def test_tobinfile_two_hex_files ( self ) : <EOL> nrf = nrfhex . nRFHex ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> nrf . tobinfile ( "<STR_LIT>" ) <EOL> self . comparefiles ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> def test_tobinfile_one_hex_one_bin ( self ) : <EOL> nrf = nrfhex . nRFHex ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> nrf . tobinfile ( "<STR_LIT>" ) <EOL> self . comparefiles ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> def test_tobinfile_one_bin_one_hex ( self ) : <EOL> nrf = nrfhex . nRFHex ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> nrf . tobinfile ( "<STR_LIT>" ) <EOL> self . comparefiles ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> def test_tobinfile_two_bin ( self ) : <EOL> nrf = nrfhex . nRFHex ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> nrf . tobinfile ( "<STR_LIT>" ) <EOL> self . comparefiles ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> def test_sizes ( self ) : <EOL> nrf = nrfhex . nRFHex ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertEqual ( nrf . get_mbr_end_address ( ) , <NUM_LIT> ) <EOL> self . assertEqual ( nrf . minaddr ( ) , <NUM_LIT> ) <EOL> self . assertEqual ( nrf . size ( ) , <NUM_LIT> ) <EOL> self . assertEqual ( nrf . bootloadersize ( ) , <NUM_LIT> ) <EOL> nrf = nrfhex . nRFHex ( "<STR_LIT>" ) <EOL> self . assertEqual ( nrf . get_mbr_end_address ( ) , <NUM_LIT> ) <EOL> self . assertEqual ( nrf . minaddr ( ) , <NUM_LIT> ) <EOL> self . assertEqual ( nrf . size ( ) , <NUM_LIT> ) <EOL> self . assertEqual ( nrf . bootloadersize ( ) , <NUM_LIT:0> ) <EOL> def test_get_softdevice_variant ( self ) : <EOL> nrf = nrfhex . nRFHex ( "<STR_LIT>" ) <EOL> self . assertEqual ( nrf . get_softdevice_variant ( ) , "<STR_LIT>" ) <EOL> nrf = nrfhex . nRFHex ( "<STR_LIT>" ) <EOL> self . assertEqual ( nrf . get_softdevice_variant ( ) , "<STR_LIT>" ) <EOL> nrf = nrfhex . nRFHex ( "<STR_LIT>" ) <EOL> self . assertEqual ( nrf . get_softdevice_variant ( ) , "<STR_LIT>" ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
