public static String getOptName(Opt opt, Field f) { Set<String> names = new HashSet<String>(); if (opt != null && !opt.name().equals("[unassigned]")) { return opt.name(); } return f.getName(); }
@Test public void test値オプション() { Opt opt = new Opt(new String[] {"-b1"}, "Fb:c:fn:qr"); assertThat(opt.get(), is((int) 'b')); assertThat(opt.getOpt(), is((int) 'b')); assertThat(opt.getArg(), is("1")); opt = new Opt(new String[] {"-b11"}, "Fb:c:fn:qr"); assertThat(opt.get(), is((int) 'b')); assertThat(opt.getOpt(), is((int) 'b')); assertThat(opt.getArg(), is("11")); opt = new Opt(new String[] {"-b"}, "Fb:c:fn:qr"); assertThat(opt.get(), is((int) '?')); assertThat(opt.getOpt(), is((int) 'b')); }
@Test public void testGetMoveDeltaWhenN_0_1() throws Exception { setUp(); when(problem.getDistance(0, 1)).thenReturn(10.0); when(problem.getDistance(1, 0)).thenReturn(10.0); when(problem.getDistance(0, dim - 1)).thenReturn(50.0); when(problem.getDistance(1, dim - 1)).thenReturn(22.0); when(problem.getDistance(1, 2)).thenReturn(15.0); when(problem.getDistance(0, 2)).thenReturn(393.0); assertEquals(-50.0 - 15.0 + 22.0 + 393.0, mover.getMoveDelta(0, 1, solution), Environment.eps); }
public String gen(RandomSource randomSource, String[] args) throws GenException { Opt opt = opt(); String res = GeneratorTool.defaultProcess(opt, args); if (res != null) { return res; } String keypairString = opt.getStringValue("keypair"); int certainty = opt.getIntValue("-cert", DEFAULT_CERT); try { SignatureKeyPair keypair = Marshalizer.unmarshalHexAux_SignatureKeyPair(keypairString, randomSource, certainty); return Marshalizer.marshalToHexHuman(keypair.getPKey(), opt.getBooleanValue("-v")); } catch (EIOException eioe) { throw new GenException("Malformed key pair!", eioe); } }
/** * Generates an option instance containing suitable options and description. * * @return Option instance representing valid inputs to this instance. */ protected Opt opt() { Opt opt = GeneratorTool.defaultOpt(SignaturePKey.class.getSimpleName(), 1); opt.setUsageComment( "(where " + SignaturePKey.class.getSimpleName() + " = " + SignaturePKey.class.getName() + ")"); opt.addParameter("keypair", "Signature key pair " + "(vfork.crypto.SignatureKeyPair)."); opt.addOption( "-cert", "value", "Determines the probability that the input key pair " + "is malformed, i.e., a value " + "of t gives a bound of 2^(-t)." + " Defaults to " + DEFAULT_CERT + "."); String s = "Extracts a signature public key from a key pair."; opt.appendToUsageForm(1, "#-cert#keypair#"); opt.appendDescription(s); return opt; }
@Test public void testオプションの連続記入() { Opt opt = new Opt(new String[] {"-Fb100"}, "Fb:c:fn:qr"); assertThat(opt.get(), is((int) 'F')); assertThat(opt.getOpt(), is((int) 'F')); assertThat(opt.get(), is((int) 'b')); assertThat(opt.getOpt(), is((int) 'b')); assertThat(opt.getArg(), is("100")); }
@Test public void testGetMoveDeltaWhenN_1_4() throws Exception { setUp(); when(problem.getDistance(1, 0)).thenReturn(10.0); when(problem.getDistance(1, 2)).thenReturn(121.0); when(problem.getDistance(4, 5)).thenReturn(50.0); when(problem.getDistance(4, 3)).thenReturn(23.0); when(problem.getDistance(4, 0)).thenReturn(76.0); when(problem.getDistance(4, 2)).thenReturn(8.0); when(problem.getDistance(1, 3)).thenReturn(89.0); when(problem.getDistance(1, 5)).thenReturn(142.0); assertEquals( -10.0 - 121.0 - 50.0 - 23.0 + 76.0 + 8.0 + 89.0 + 142.0, mover.getMoveDelta(1, 4, solution), Environment.eps); }
private void testMove(int i, int j) { setUp(); ArrayList<Integer> expected = new ArrayList<>(); for (int k = 0; k < i; k++) { expected.add(k); } expected.add(j); for (int k = i + 1; k < j; k++) { expected.add(k); } expected.add(i); for (int k = j + 1; k < dim; k++) { expected.add(k); } mover.move(i, j, solution); assertArrayEquals(expected.toArray(), solution.getSolution().toArray()); }
@Test public void testオプション0() { Opt opt = new Opt(new String[] {}, "Fb:c:fn:qr"); assertThat(opt.get(), is(-1)); }
@Test public void testオプション全指定() { Opt opt = new Opt(new String[] {"-Fb100", "-c", "200", "-f", "-n300", "-qr"}, "Fb:c:fn:qr"); assertThat(opt.get(), is((int) 'F')); assertThat(opt.getOpt(), is((int) 'F')); assertThat(opt.get(), is((int) 'b')); assertThat(opt.getOpt(), is((int) 'b')); assertThat(opt.getArg(), is("100")); assertThat(opt.get(), is((int) 'c')); assertThat(opt.getOpt(), is((int) 'c')); assertThat(opt.getArg(), is("200")); assertThat(opt.get(), is((int) 'f')); assertThat(opt.getOpt(), is((int) 'f')); assertThat(opt.get(), is((int) 'n')); assertThat(opt.getOpt(), is((int) 'n')); assertThat(opt.getArg(), is("300")); assertThat(opt.get(), is((int) 'q')); assertThat(opt.getOpt(), is((int) 'q')); assertThat(opt.get(), is((int) 'r')); assertThat(opt.getOpt(), is((int) 'r')); }
@Test public void testオプション1() { Opt opt = new Opt(new String[] {"-F"}, "Fb:c:fn:qr"); assertThat(opt.get(), is((int) 'F')); assertThat(opt.getOpt(), is((int) 'F')); }
/* 209: */ /* 210: */ public void write(File outputFile) /* 211: */ throws IOException /* 212: */ { /* 213:406 */ if (this.origin == Origin.WRITE) /* 214: */ { /* 215:408 */ DggContainer dggContainer = new DggContainer(); /* 216: */ /* 217:410 */ Dgg dgg = new Dgg(this.numBlips + this.numCharts + 1, this.numBlips); /* 218: */ /* 219:412 */ dgg.addCluster(1, 0); /* 220:413 */ dgg.addCluster(this.numBlips + 1, 0); /* 221: */ /* 222:415 */ dggContainer.add(dgg); /* 223: */ /* 224:417 */ int drawingsAdded = 0; /* 225:418 */ BStoreContainer bstoreCont = new BStoreContainer(); /* 226:421 */ for (Iterator i = this.drawings.iterator(); i.hasNext(); ) /* 227: */ { /* 228:423 */ Object o = i.next(); /* 229:424 */ if ((o instanceof Drawing)) /* 230: */ { /* 231:426 */ Drawing d = (Drawing) o; /* 232:427 */ BlipStoreEntry bse = new BlipStoreEntry(d); /* 233: */ /* 234:429 */ bstoreCont.add(bse); /* 235:430 */ drawingsAdded++; /* 236: */ } /* 237: */ } /* 238:433 */ if (drawingsAdded > 0) /* 239: */ { /* 240:435 */ bstoreCont.setNumBlips(drawingsAdded); /* 241:436 */ dggContainer.add(bstoreCont); /* 242: */ } /* 243:439 */ Opt opt = new Opt(); /* 244: */ /* 245:441 */ dggContainer.add(opt); /* 246: */ /* 247:443 */ SplitMenuColors splitMenuColors = new SplitMenuColors(); /* 248:444 */ dggContainer.add(splitMenuColors); /* 249: */ /* 250:446 */ this.drawingData = dggContainer.getData(); /* 251: */ } /* 252:448 */ else if (this.origin == Origin.READ_WRITE) /* 253: */ { /* 254:450 */ DggContainer dggContainer = new DggContainer(); /* 255: */ /* 256:452 */ Dgg dgg = new Dgg(this.numBlips + this.numCharts + 1, this.numBlips); /* 257: */ /* 258:454 */ dgg.addCluster(1, 0); /* 259:455 */ dgg.addCluster(this.drawingGroupId + this.numBlips + 1, 0); /* 260: */ /* 261:457 */ dggContainer.add(dgg); /* 262: */ /* 263:459 */ BStoreContainer bstoreCont = new BStoreContainer(); /* 264:460 */ bstoreCont.setNumBlips(this.numBlips); /* 265: */ /* 266: */ /* 267:463 */ BStoreContainer readBStoreContainer = getBStoreContainer(); /* 268:465 */ if (readBStoreContainer != null) /* 269: */ { /* 270:467 */ EscherRecord[] children = readBStoreContainer.getChildren(); /* 271:468 */ for (int i = 0; i < children.length; i++) /* 272: */ { /* 273:470 */ BlipStoreEntry bse = (BlipStoreEntry) children[i]; /* 274:471 */ bstoreCont.add(bse); /* 275: */ } /* 276: */ } /* 277:476 */ for (Iterator i = this.drawings.iterator(); i.hasNext(); ) /* 278: */ { /* 279:478 */ DrawingGroupObject dgo = (DrawingGroupObject) i.next(); /* 280:479 */ if ((dgo instanceof Drawing)) /* 281: */ { /* 282:481 */ Drawing d = (Drawing) dgo; /* 283:482 */ if (d.getOrigin() == Origin.WRITE) /* 284: */ { /* 285:484 */ BlipStoreEntry bse = new BlipStoreEntry(d); /* 286:485 */ bstoreCont.add(bse); /* 287: */ } /* 288: */ } /* 289: */ } /* 290:490 */ dggContainer.add(bstoreCont); /* 291: */ /* 292:492 */ Opt opt = new Opt(); /* 293: */ /* 294:494 */ opt.addProperty(191, false, false, 524296); /* 295:495 */ opt.addProperty(385, false, false, 134217737); /* 296:496 */ opt.addProperty(448, false, false, 134217792); /* 297: */ /* 298:498 */ dggContainer.add(opt); /* 299: */ /* 300:500 */ SplitMenuColors splitMenuColors = new SplitMenuColors(); /* 301:501 */ dggContainer.add(splitMenuColors); /* 302: */ /* 303:503 */ this.drawingData = dggContainer.getData(); /* 304: */ } /* 305:506 */ MsoDrawingGroupRecord msodg = new MsoDrawingGroupRecord(this.drawingData); /* 306:507 */ outputFile.write(msodg); /* 307: */ }