@@ -554,3 +554,66 @@ func TestBoardMatching(t *testing.T) {
554554 "lemons" : "XXX" ,
555555 })))
556556}
557+
558+ func TestBoardConfigMatching (t * testing.T ) {
559+ brd01 := & Board {
560+ Properties : properties .NewFromHashmap (map [string ]string {
561+ "upload_port.pid" : "0x0010" ,
562+ "upload_port.vid" : "0x2341" ,
563+ "menu.cpu.atmega1280" : "ATmega1280" ,
564+ "menu.cpu.atmega1280.upload_port.cpu" : "atmega1280" ,
565+ "menu.cpu.atmega1280.build_cpu" : "atmega1280" ,
566+ "menu.cpu.atmega2560" : "ATmega2560" ,
567+ "menu.cpu.atmega2560.upload_port.cpu" : "atmega2560" ,
568+ "menu.cpu.atmega2560.build_cpu" : "atmega2560" ,
569+ "menu.mem.1k" : "1KB" ,
570+ "menu.mem.1k.upload_port.mem" : "1" ,
571+ "menu.mem.1k.build_mem" : "1024" ,
572+ "menu.mem.2k" : "2KB" ,
573+ "menu.mem.2k.upload_port.1.mem" : "2" ,
574+ "menu.mem.2k.upload_port.2.ab" : "ef" ,
575+ "menu.mem.2k.upload_port.2.cd" : "gh" ,
576+ "menu.mem.2k.build_mem" : "2048" ,
577+ }),
578+ PlatformRelease : & PlatformRelease {
579+ Platform : & Platform {
580+ Architecture : "avr" ,
581+ Package : & Package {
582+ Name : "arduino" ,
583+ },
584+ },
585+ Menus : properties .NewFromHashmap (map [string ]string {
586+ "cpu" : "Processor" ,
587+ "mem" : "Memory" ,
588+ }),
589+ },
590+ }
591+ require .True (t , brd01 .IsBoardMatchingIDProperties (properties .NewFromHashmap (map [string ]string {
592+ "pid" : "0x0010" ,
593+ "vid" : "0x2341" ,
594+ })))
595+ res := brd01 .IdentifyBoardConfiguration (properties .NewFromHashmap (map [string ]string {
596+ "cpu" : "atmega2560" ,
597+ }))
598+ require .EqualValues (t , map [string ]string {"cpu" : "atmega2560" }, res .AsMap ())
599+ res = brd01 .IdentifyBoardConfiguration (properties .NewFromHashmap (map [string ]string {
600+ "cpu" : "atmega1280" ,
601+ }))
602+ require .EqualValues (t , map [string ]string {"cpu" : "atmega1280" }, res .AsMap ())
603+ res = brd01 .IdentifyBoardConfiguration (properties .NewFromHashmap (map [string ]string {
604+ "cpu" : "atmega1280" ,
605+ "mem" : "1" ,
606+ }))
607+ require .EqualValues (t , map [string ]string {"cpu" : "atmega1280" , "mem" : "1k" }, res .AsMap ())
608+ res = brd01 .IdentifyBoardConfiguration (properties .NewFromHashmap (map [string ]string {
609+ "cpu" : "atmega1280" ,
610+ "ab" : "ef" ,
611+ }))
612+ require .EqualValues (t , map [string ]string {"cpu" : "atmega1280" }, res .AsMap ())
613+ res = brd01 .IdentifyBoardConfiguration (properties .NewFromHashmap (map [string ]string {
614+ "cpu" : "atmega1280" ,
615+ "ab" : "ef" ,
616+ "cd" : "gh" ,
617+ }))
618+ require .EqualValues (t , map [string ]string {"cpu" : "atmega1280" , "mem" : "2k" }, res .AsMap ())
619+ }
0 commit comments