func TestDecodeGenericPlateLHPlate(t *testing.T) { //TODO jmanart, this really should have better set of tests swshp := wtype.NewShape("box", "mm", 8.2, 8.2, 41.3) welltype := wtype.NewLHWell("DSW96", "", "", "ul", 2000, 25, swshp, 3, 8.2, 8.2, 41.3, 4.7, "mm") plate := *wtype.NewLHPlate("DSW96", "Unknown", 8, 12, 44.1, "mm", welltype, 9, 9, 0.0, 0.0, 0.0) enc, err := json.Marshal(plate) if err != nil { t.Fatal(err) } out, err := DecodeGenericPlate(string(enc)) if err != nil { t.Fatal(err) } if reflect.TypeOf(out) != reflect.TypeOf(plate) { t.Fatal("expecting output type ", reflect.TypeOf(plate), " got ", reflect.TypeOf(out)) } else if !reflect.DeepEqual(out, plate) { //let's compare the json output wanted, _ := json.Marshal(plate) got, _ := json.Marshal(out) if strings.TrimSpace(string(wanted)) != strings.TrimSpace(string(got)) { // wanted, _ := json.MarshalIndent(plate, "", "\t") // got, _ := json.MarshalIndent(out, "", "\t") // fmt.Println(pretty.Compare(out, plate)) //cannot use this because it generates a closed loop inside the library // fmt.Println(diff.Diff(string(got), string(wanted))) t.Fatalf( // "The input and output contents are not the same.", "The input and output contents are not the same; Wanted \n%s\n got \n%s\n", string(got), string(wanted), ) } } }
// TODO plate dimensions are not correct func makePlateLibrary() map[string]*wtype.LHPlate { plates := make(map[string]*wtype.LHPlate) welltype := wtype.NewLHWell("DSW96", "", "", "ul", 2000, 25, 0, 3, 8.2, 8.2, 41.3, 4.7, "mm") plate := wtype.NewLHPlate("DSW96", "Unknown", 8, 12, 44.1, "mm", welltype, 9, 9, 0.0, 0.0, 0.0) plates[plate.Type] = plate welltype = wtype.NewLHWell("SRWFB96", "", "", "ul", 500, 10, 1, 0, 8.2, 8.2, 11, 1.0, "mm") plate = wtype.NewLHPlate("SRWFB96", "Unknown", 8, 12, 15, "mm", welltype, 9, 9, 0.0, 0.0, 0.0) plates[plate.Type] = plate welltype = wtype.NewLHWell("DWST12", "", "", "ul", 15000, 1000, 0, 3, 8.2, 72, 41.3, 4.7, "mm") plate = wtype.NewLHPlate("DWST12", "Unknown", 1, 12, 44.1, "mm", welltype, 9, 9, 0.0, 31.5, 0.0) plates[plate.Type] = plate welltype = wtype.NewLHWell("DWST8", "", "", "ul", 24000, 1000, 0, 3, 115, 8.2, 41.3, 4.7, "mm") plate = wtype.NewLHPlate("DWST8", "Unknown", 8, 1, 44.1, "mm", welltype, 9, 9, 49.5, 0.0, 0.0) plates[plate.Type] = plate welltype = wtype.NewLHWell("DWR1", "", "", "ul", 300000, 20000, 0, 3, 115, 72, 41.3, 4.7, "mm") plate = wtype.NewLHPlate("DWR1", "Unknown", 1, 1, 44.1, "mm", welltype, 9, 9, 49.5, 31.5, 0.0) plates[plate.Type] = plate welltype = wtype.NewLHWell("pcrplate", "", "", "ul", 300, 10, 1, 0, 8.2, 8.2, 11, 1.0, "mm") plate = wtype.NewLHPlate("pcrplate", "Unknown", 8, 12, 15, "mm", welltype, 9, 9, 0.0, 0.0, 6.0) plates[plate.Type] = plate return plates }