/**********************************************************************
 * Copyright (c) by Heiner Jostkleigrewe
 * This program is free software: you can redistribute it and/or modify it under the terms of the 
 * GNU General Public License as published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 *
 *  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.
 *
 * You should have received a copy of the GNU General Public License along with this program.  If not, 
 * see <http://www.gnu.org/licenses/>.
 * 
 * heiner@jverein.de
 * www.jverein.de
 **********************************************************************/
package de.jost_net.JVerein.io;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.junit.jupiter.api.Test;
import de.jost_net.JVerein.util.VonBis;
import de.willuhn.util.ApplicationException;

class AltersgruppenParserTest
{
  @Test
  void test01() throws ApplicationException
  {
    AltersgruppenParser ap = new AltersgruppenParser(
        "0-5,6-10,11-16,17-25,26-100");
    VonBis vb = ap.getNext();
    assertEquals(0, vb.getVon());
    assertEquals(5, vb.getBis());
    vb = ap.getNext();
    assertEquals(6, vb.getVon());
    assertEquals(10, vb.getBis());
    vb = ap.getNext();
    assertEquals(11, vb.getVon());
    assertEquals(16, vb.getBis());
    vb = ap.getNext();
    assertEquals(17, vb.getVon());
    assertEquals(25, vb.getBis());
    vb = ap.getNext();
    assertEquals(26, vb.getVon());
    assertEquals(100, vb.getBis());
  }

  @Test
  void test02() throws ApplicationException
  {
    assertThrows(RuntimeException.class,
        () -> new AltersgruppenParser("0-5,4-99"));
  }

  @Test
  void test03() throws ApplicationException
  {
    assertThrows(RuntimeException.class,
        () -> new AltersgruppenParser("0-3,4-10"));
  }
}
