package modules;

import com.google.common.collect.Range;
import io.github.mzmine.datamodel.IonizationType;
import io.github.mzmine.modules.tools.mzrangecalculator.MzRangeFormulaCalculatorModule;
import io.github.mzmine.parameters.parametertypes.tolerances.MZTolerance;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class MzRangeFormulaCalculatorModuleTest {

  @Test
  void getMzRangeFromFormula() {

    final MZTolerance tol = new MZTolerance(0.01, 5);
    Assertions.assertEquals(Range.closed(16.020751548090537, 16.04075154809054),
        MzRangeFormulaCalculatorModule.getMzRangeFromFormula("CH4", IonizationType.POSITIVE, tol));
    Assertions.assertEquals(Range.closed(16.021848707909456, 16.04184870790946),
        MzRangeFormulaCalculatorModule.getMzRangeFromFormula("CH4", IonizationType.NEGATIVE, tol));
    Assertions.assertEquals(Range.closed(17.028576127999997, 17.048576128),
        MzRangeFormulaCalculatorModule.getMzRangeFromFormula("CH4",
            IonizationType.POSITIVE_HYDROGEN, tol));
    Assertions.assertEquals(Range.closed(15.014024127999997, 15.034024127999997),
        MzRangeFormulaCalculatorModule.getMzRangeFromFormula("CH4",
            IonizationType.NEGATIVE_HYDROGEN, tol));
    Assertions.assertEquals(Range.closed(129.00688612800002, 129.026886128),
        MzRangeFormulaCalculatorModule.getMzRangeFromFormula("CH4", IonizationType.TRIFLUORACETATE,
            tol));
    Assertions.assertEquals(Range.closed(6.998374063999999, 7.018374063999999),
        MzRangeFormulaCalculatorModule.getMzRangeFromFormula("CH4", IonizationType.NAME_1, tol));
    Assertions.assertEquals(Range.closed(13.668357909333334, 13.688357909333334),
        MzRangeFormulaCalculatorModule.getMzRangeFromFormula("CH4", IonizationType.NAME7, tol));
  }
}

@@ -1,8 +1,803 @@
+/*%0A *  Copyright 2006-2022 The MZmine Development Team%0A *%0A *  This file is part of MZmine.%0A *%0A *  MZmine is free software; you can redistribute it and/or modify it under the terms of the GNU%0A *  General Public License as published by the Free Software Foundation; either version 2 of the%0A *  License, or (at your option) any later version.%0A *%0A *  MZmine is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even%0A *  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General%0A *  Public License for more details.%0A *%0A *  You should have received a copy of the GNU General Public License along with MZmine; if not,%0A *  write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301%0A *  USA%0A */%0A%0A
 package 
@@ -1342,11 +1342,10 @@
 8090
-537
+93
 , 16
@@ -1357,18 +1357,19 @@
 51548090
+93
 5
-4
 ),%0A     
@@ -1523,10 +1523,9 @@
 7909
-45
+0
 6, 1
@@ -1542,10 +1542,11 @@
 7909
-46
+065
 ),%0A 
@@ -1694,25 +1694,24 @@
 7.028576
-127999997
+58009093
 , 17.048
@@ -1713,19 +1713,25 @@
 7.048576
-128
+580090934
 ),%0A     
@@ -1899,38 +1899,38 @@
 1402
-4127999997, 15.034024127999997
+3675909064, 15.034023675909063
 ),%0A 
@@ -2103,17 +2103,17 @@
 0688
-612800002
+760790908
 , 12
@@ -2123,12 +2123,17 @@
 2688
-6128
+760790906
 ),%0A 
@@ -2302,37 +2302,37 @@
 9837
-4063999999, 7.018374063999999
+3611909065, 7.018373611909064
 ),%0A 
@@ -2479,24 +2479,24 @@
 .6683579
-09333334
+10757603
 , 13.688
@@ -2503,16 +2503,16 @@
 3579
-09333334
+10757603
 ),%0A 

fix test