Subversion Repositories display

Rev

Rev 260 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*
 * Copyright (C) 2011.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3 as
 * published by the Free Software Foundation.
 *
 * 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
 * General Public License for more details.
 */

package test.display.check;

import static test.display.check.Log.error;

/**
* @author Steve Ratcliffe
*/

public class BoundChecker {
                private String name;
                private int max;
                private int last;

                public BoundChecker(String name, int numberOfRecords) {
                        this.name = name;
                        max = numberOfRecords;
                }

                public void update(int number, int val) {
                        if (last == 0 && val != 1 && val != 0)
                                error("%d %s; first value not 1 was %d", number, name, val);
                       
                        if (val < last && val != 0)
                                error("%d %s; value %d less than last %d", number, name, val, last);

                        if (val > max && max != 0)
                                error("%d %s; value %d greater than max %d", number, name, val, max);
                        if (val != 0)
                                last = val;
                }
        }