// Path: src/main/java/com/tiemens/secretshare/engine/SecretShare.java
// public static final class ParanoidInput
// {
//     // maximum combine operations to perform - negative means "all", null means "all"
//     private BigInteger maximumCombinationsAllowedToTest = null;
//     // for output/debug purposes, output a line every "this percentage"
//     private int percentEvery = 30;  // or 10 for every 10%
//     // stop processing when any answer hits this count (should be greater than 1)
//     private Integer stopCombiningWhenAnyCount = null;
//     // limit the number of "combine.N" lines printed
//     private Integer limitPrint = null;
// 
//     @Override
//     public String toString()
//     {
//         return "ParanoidInput [" +
//                 "maximumCombinationsAllowedToTest=" + maximumCombinationsAllowedToTest +
//                 ", percentEvery=" + percentEvery +
//                 ", stopCombiningWhenAnyCount=" + stopCombiningWhenAnyCount +
//                 ", limitPrint=" + limitPrint +
//                 "]";
//     }
// 
// 
//     // split only allows <number> or the string "all"
//     public static ParanoidInput parseForSplit(String argumentName, String arg)
//     {
//         ParanoidInput ret = new ParanoidInput();
//         if ("all".equals(arg))
//         {
//             ret.maximumCombinationsAllowedToTest = null;
//         }
//         else
//         {
//             ret.maximumCombinationsAllowedToTest = new BigInteger(arg);
//         }
//         return ret;
//     }
// 
//     // combine allows <number>|"all" followed by other options
//     public static ParanoidInput parseForCombine(String argumentName, String arg)
//     {
//         ParanoidInput ret = new ParanoidInput();
//         String[] pieces = arg.split(",");
//         for (String piece : pieces)
//         {
//             Integer v;
//             v = parse(piece, "limitPrint=");
//             if (v != null)
//             {
//                 ret.limitPrint = v;
//             }
//             else
//             {
//                 v = parse(piece, "stopCombiningWhenAnyCount=");
//                 if (v != null)
//                 {
//                     ret.stopCombiningWhenAnyCount = v;
//                 }
//                 else
//                 {
//                     v = parse(piece, "");
//                     if (v == null)
//                     {
//                         v = parse(piece, "maxCombinationsAllowedToTest=");
//                     }
//                     if (v != null)
//                     {
//                         ret.maximumCombinationsAllowedToTest = BigInteger.valueOf(v);
//                     }
//                     else
//                     {
//                         throw new SecretShareException("Failed to parse piece '" + piece +
//                                                        "' as part of argument '" + arg + "'");
//                     }
//                 }
//             }
//         }
// 
//         return ret;
//     }
// 
//     private static Integer parse(String arg, String lookfor)
//     {
//         arg = arg.toLowerCase();
//         lookfor = lookfor.toLowerCase();
// 
//         Integer ret = null;
//         if (arg.startsWith(lookfor))
//         {
//             String rest = arg.substring(lookfor.length());
//             try
//             {
//                 ret = Integer.parseInt(rest);
//             }
//             catch (NumberFormatException e)
//             {
// 
//             }
//         }
//         return ret;
//     }
// 
//     public static ParanoidInput createAll()
//     {
//         // null == "All"
//         return create(null);
//     }
// 
//     public static ParanoidInput create(BigInteger max)
//     {
//         ParanoidInput ret = new ParanoidInput();
//         ret.maximumCombinationsAllowedToTest = max;
//         return ret;
//     }
// 
//     private ParanoidInput()
//     {
// 
//     }
// 
//     public BigInteger getMaximumCombinationsToTest()
//     {
//         return maximumCombinationsAllowedToTest;
//     }
// 
//     public void setOutputEvery(int percentage0to100)
//     {
//         percentEvery = percentage0to100;
//     }
// 
//     public BigInteger getMaximumCombinationsAllowedToTest()
//     {
//         return maximumCombinationsAllowedToTest;
//     }
// 
//     public int getPercentEvery()
//     {
//         return percentEvery;
//     }
// 
//     public Integer getStopCombiningWhenAnyCount()
//     {
//         return stopCombiningWhenAnyCount;
//     }
// 
//     public Integer getLimitPrint()
//     {
//         return limitPrint;
//     }
// }


import java.math.BigInteger;
import org.junit.Assert;
import org.junit.Test;
import com.tiemens.secretshare.engine.SecretShare.ParanoidInput;
/*******************************************************************************
 * Copyright (c) 2009, 2014 Tim Tiemens.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 *
 * Contributors:
 *     Tim Tiemens - initial API and implementation
 *******************************************************************************/
package com.tiemens.secretshare.engine;




public class SecretShareParanoidInputTest
{

    // ==================================================
    // class static data
    // ==================================================

    // ==================================================
    // class static methods
    // ==================================================

    // ==================================================
    // instance data
    // ==================================================

    // ==================================================
    // factories
    // ==================================================

    // ==================================================
    // constructors
    // ==================================================

    // @Before


    // ==================================================
    // public methods
    // ==================================================


    @Test
    public void testJustMax()
    {
        validate("5", 5, null, null);
        validate("50,stopCombiningWhenAnyCount=4,limitPrint=22", 50, 4, 22);
        validate("50,limitPrint=22", 50, null, 22);
        validate("limitPrint=22,50", 50, null, 22);
        validate("maxCombinationsAllowedToTest=50,limitPrint=22", 50, null, 22);
        validate("maxCombinationsAllowedToTest=50,stopCombiningWhenAnyCount=3,limitPrint=22", 50, 3, 22);
    }

    // ==================================================
    // non public methods
    // ==================================================


    private void validate(String arg,
                          Integer expectMaxInt,
                          Integer expectStopWhenCount,
                          Integer expectLimitPrint)
    {
// Path: src/main/java/com/tiemens/secretshare/engine/SecretShare.java
// public static final class ParanoidInput
// {
//     // maximum combine operations to perform - negative means "all", null means "all"
//     private BigInteger maximumCombinationsAllowedToTest = null;
//     // for output/debug purposes, output a line every "this percentage"
//     private int percentEvery = 30;  // or 10 for every 10%
//     // stop processing when any answer hits this count (should be greater than 1)
//     private Integer stopCombiningWhenAnyCount = null;
//     // limit the number of "combine.N" lines printed
//     private Integer limitPrint = null;
// 
//     @Override
//     public String toString()
//     {
//         return "ParanoidInput [" +
//                 "maximumCombinationsAllowedToTest=" + maximumCombinationsAllowedToTest +
//                 ", percentEvery=" + percentEvery +
//                 ", stopCombiningWhenAnyCount=" + stopCombiningWhenAnyCount +
//                 ", limitPrint=" + limitPrint +
//                 "]";
//     }
// 
// 
//     // split only allows <number> or the string "all"
//     public static ParanoidInput parseForSplit(String argumentName, String arg)
//     {
//         ParanoidInput ret = new ParanoidInput();
//         if ("all".equals(arg))
//         {
//             ret.maximumCombinationsAllowedToTest = null;
//         }
//         else
//         {
//             ret.maximumCombinationsAllowedToTest = new BigInteger(arg);
//         }
//         return ret;
//     }
// 
//     // combine allows <number>|"all" followed by other options
//     public static ParanoidInput parseForCombine(String argumentName, String arg)
//     {
//         ParanoidInput ret = new ParanoidInput();
//         String[] pieces = arg.split(",");
//         for (String piece : pieces)
//         {
//             Integer v;
//             v = parse(piece, "limitPrint=");
//             if (v != null)
//             {
//                 ret.limitPrint = v;
//             }
//             else
//             {
//                 v = parse(piece, "stopCombiningWhenAnyCount=");
//                 if (v != null)
//                 {
//                     ret.stopCombiningWhenAnyCount = v;
//                 }
//                 else
//                 {
//                     v = parse(piece, "");
//                     if (v == null)
//                     {
//                         v = parse(piece, "maxCombinationsAllowedToTest=");
//                     }
//                     if (v != null)
//                     {
//                         ret.maximumCombinationsAllowedToTest = BigInteger.valueOf(v);
//                     }
//                     else
//                     {
//                         throw new SecretShareException("Failed to parse piece '" + piece +
//                                                        "' as part of argument '" + arg + "'");
//                     }
//                 }
//             }
//         }
// 
//         return ret;
//     }
// 
//     private static Integer parse(String arg, String lookfor)
//     {
//         arg = arg.toLowerCase();
//         lookfor = lookfor.toLowerCase();
// 
//         Integer ret = null;
//         if (arg.startsWith(lookfor))
//         {
//             String rest = arg.substring(lookfor.length());
//             try
//             {
//                 ret = Integer.parseInt(rest);
//             }
//             catch (NumberFormatException e)
//             {
// 
//             }
//         }
//         return ret;
//     }
// 
//     public static ParanoidInput createAll()
//     {
//         // null == "All"
//         return create(null);
//     }
// 
//     public static ParanoidInput create(BigInteger max)
//     {
//         ParanoidInput ret = new ParanoidInput();
//         ret.maximumCombinationsAllowedToTest = max;
//         return ret;
//     }
// 
//     private ParanoidInput()
//     {
// 
//     }
// 
//     public BigInteger getMaximumCombinationsToTest()
//     {
//         return maximumCombinationsAllowedToTest;
//     }
// 
//     public void setOutputEvery(int percentage0to100)
//     {
//         percentEvery = percentage0to100;
//     }
// 
//     public BigInteger getMaximumCombinationsAllowedToTest()
//     {
//         return maximumCombinationsAllowedToTest;
//     }
// 
//     public int getPercentEvery()
//     {
//         return percentEvery;
//     }
// 
//     public Integer getStopCombiningWhenAnyCount()
//     {
//         return stopCombiningWhenAnyCount;
//     }
// 
//     public Integer getLimitPrint()
//     {
//         return limitPrint;
//     }
// }


// Path: src/test/java/com/tiemens/secretshare/engine/SecretShareParanoidInputTest.java
import java.math.BigInteger;
import org.junit.Assert;
import org.junit.Test;
import com.tiemens.secretshare.engine.SecretShare.ParanoidInput;

/*******************************************************************************
 * Copyright (c) 2009, 2014 Tim Tiemens.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 *
 * Contributors:
 *     Tim Tiemens - initial API and implementation
 *******************************************************************************/
package com.tiemens.secretshare.engine;




public class SecretShareParanoidInputTest
{

    // ==================================================
    // class static data
    // ==================================================

    // ==================================================
    // class static methods
    // ==================================================

    // ==================================================
    // instance data
    // ==================================================

    // ==================================================
    // factories
    // ==================================================

    // ==================================================
    // constructors
    // ==================================================

    // @Before


    // ==================================================
    // public methods
    // ==================================================


    @Test
    public void testJustMax()
    {
        validate("5", 5, null, null);
        validate("50,stopCombiningWhenAnyCount=4,limitPrint=22", 50, 4, 22);
        validate("50,limitPrint=22", 50, null, 22);
        validate("limitPrint=22,50", 50, null, 22);
        validate("maxCombinationsAllowedToTest=50,limitPrint=22", 50, null, 22);
        validate("maxCombinationsAllowedToTest=50,stopCombiningWhenAnyCount=3,limitPrint=22", 50, 3, 22);
    }

    // ==================================================
    // non public methods
    // ==================================================


    private void validate(String arg,
                          Integer expectMaxInt,
                          Integer expectStopWhenCount,
                          Integer expectLimitPrint)
    {
        ParanoidInput actual = ParanoidInput.parseForCombine("paranoid", arg);