From 6e58e6086a2e92fb3ffa66206134c489e2fc26ba Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Tue, 12 Dec 2023 17:49:35 +0000 Subject: [PATCH] JAL-4353 bigger tighter test --- test/jalview/bin/argparser/ArgParserTest.java | 122 +++++++++++++++++++++++-- 1 file changed, 114 insertions(+), 8 deletions(-) diff --git a/test/jalview/bin/argparser/ArgParserTest.java b/test/jalview/bin/argparser/ArgParserTest.java index b29b4e9..89c034a 100644 --- a/test/jalview/bin/argparser/ArgParserTest.java +++ b/test/jalview/bin/argparser/ArgParserTest.java @@ -484,7 +484,9 @@ public class ArgParserTest areEqualSets(avals.values, ArgValuesMap.toValues(parsed_ArgValues)), "Primary arg (" + primaryArg.toString() - + ") does not have the expected values"); + + ") does not have the expected values. Expected " + + avals.values + " and got " + + ArgValuesMap.toValues(parsed_ArgValues)); for (int i = 0; i < parsed_ArgValues.size(); i++) { @@ -503,11 +505,19 @@ public class ArgParserTest Arg auxArg = aux_aval.arg; List auxValues = aux_aval.values; + String parsed_auxValue = avm.getFromSubValArgOrPref(auxArg, + ArgValuesMap.Position.AFTER, parsed_ArgValue, null, null, + null, null); + + if (auxValues.isEmpty()) + { + Assert.assertTrue(parsed_auxValue == null, + "Not expecting to parse a value for '" + auxArg + + "' but found '" + parsed_auxValue + "'"); + } + for (String auxValue : auxValues) { - String parsed_auxValue = avm.getFromSubValArgOrPref(auxArg, - ArgValuesMap.Position.AFTER, parsed_ArgValue, null, null, - null, null); Console.debug("- + primary aux arg '" + auxArg + "' = '" + auxValue + "'"); @@ -556,11 +566,19 @@ public class ArgParserTest Arg secondary_auxArg = secondary_aux_aval.arg; List secondary_auxValues = secondary_aux_aval.values; - for (String secondary_auxValue : secondary_auxValues) + String parsed_secondary_auxValue = avm.getValueFromSubValOrArg( + parsed_secondaryArgValue, secondary_auxArg, null); + + if (secondary_auxValues.isEmpty()) { - String parsed_secondary_auxValue = avm.getValueFromSubValOrArg( - parsed_secondaryArgValue, secondary_auxArg, null); + Assert.assertTrue(parsed_secondary_auxValue == null, + "Not expecting to parse a value for '" + + secondary_auxArg + "' but found '" + + parsed_secondary_auxValue + "'"); + } + for (String secondary_auxValue : secondary_auxValues) + { Console.debug("-- + secondary aux arg '" + secondary_auxArg + "' for value '" + secondary_auxValue + "'"); @@ -661,6 +679,92 @@ public class ArgParserTest }, // } // } // + }, // + { // + "--open=alignment.fa --wrap --colour=gecose-flower" + // structure0 + + " --structure=structure0.pdb" + + " --structureimage=image0a.png --bgcolour=bg0a --scale=3" + + " --structureimage=image0b.png --imagecolour=col0b --scale=4" + + " --structureviewer=sv0 --paematrix=pae0" // + + " --structureimage=image0c.png" + // structure1 + + " --structure=structure1.pdb" + + " --structureviewer=sv1 --paematrix=pae1" + + " --structureimage=image1a.png" + + " --structureimage=image1b.png --bgcolour=bg1b --imagecolour=col1b" + + " --structureimage=image1c.png --bgcolour=bg1c --imagecolour=col1c --scale=5" + + " --structureimage=image1d.png --imagecolour=col1d --scale=6" + + " --structureimage=image1e.png --bgcolour=bg1e" + // structure2 + + " --structure=structure2.pdb" + + " --structureimage=image2a.png --bgcolour=bg2a --scale=23" + + " --all --bgcolour=pineapple --imagecolour=banana --scale=2" // + , + // stuff + new Object[] + { av(Arg.STRUCTURE, "structure0.pdb", "structure1.pdb", + "structure2.pdb"), + new ArgAndValues[][] + { // + { av(Arg.STRUCTUREVIEWER, "sv0"), + av(Arg.PAEMATRIX, "pae0") }, + { av(Arg.STRUCTUREVIEWER, "sv1"), + av(Arg.PAEMATRIX, "pae1") }, + { av(Arg.STRUCTUREVIEWER), av(Arg.PAEMATRIX) } // + }, // + new Object[][] + { // + { // + av(Arg.STRUCTUREIMAGE, "image0a.png", "image0b.png", + "image0c.png"), // + new ArgAndValues[][] + { // + { av(Arg.BGCOLOUR, "bg0a"), + av(Arg.IMAGECOLOUR, "banana"), + av(Arg.SCALE, "3") }, + { av(Arg.BGCOLOUR, "pineapple"), + av(Arg.IMAGECOLOUR, "col0b"), + av(Arg.SCALE, "4") }, + { av(Arg.BGCOLOUR, "pineapple"), + av(Arg.IMAGECOLOUR, "banana"), + av(Arg.SCALE, "2") }, // + }, // + }, // + { // + av(Arg.STRUCTUREIMAGE, "image1a.png", "image1b.png", + "image1c.png", "image1d.png", + "image1e.png"), + new ArgAndValues[][] + { // + { av(Arg.BGCOLOUR, "pineapple"), + av(Arg.IMAGECOLOUR, "banana"), + av(Arg.SCALE, "2") }, + { av(Arg.BGCOLOUR, "bg1b"), + av(Arg.IMAGECOLOUR, "col1b"), + av(Arg.SCALE, "2") }, + { av(Arg.BGCOLOUR, "bg1c"), + av(Arg.IMAGECOLOUR, "col1c"), + av(Arg.SCALE, "5") }, + { av(Arg.BGCOLOUR, "pineapple"), + av(Arg.IMAGECOLOUR, "col1d"), + av(Arg.SCALE, "6") }, + { av(Arg.BGCOLOUR, "bg1e"), + av(Arg.IMAGECOLOUR, "banana"), + av(Arg.SCALE, "2") } // + }, // + }, // + { // + av(Arg.STRUCTUREIMAGE, "image2a.png"), + new ArgAndValues[][] + { // + { av(Arg.BGCOLOUR, "bg2a"), + av(Arg.IMAGECOLOUR, "banana"), + av(Arg.SCALE, "23") }, // + }, // + }, // + } // + } // } // }; } @@ -704,11 +808,13 @@ public class ArgParserTest { if (l1 == null && l2 == null) { + Console.info( + "Comparing null lists, should be okay but you might want to know"); return true; } if (l1 == null || l2 == null) { - return true; + return false; } return new HashSet(l1).equals(new HashSet(l2)); } -- 1.7.10.2