star-hitran

Load line-by-line data from the HITRAN database
git clone git://git.meso-star.fr/star-hitran.git
Log | Files | Refs | README | LICENSE

test_shtr_molecule_id.c (3583B)


      1 /* Copyright (C) 2022, 2025, 2026 |Méso|Star> (contact@meso-star.com)
      2  * Copyright (C) 2025, 2026 Université de Lorraine
      3  * Copyright (C) 2022 Centre National de la Recherche Scientifique
      4  * Copyright (C) 2022 Université Paul Sabatier
      5  *
      6  * This program is free software: you can redistribute it and/or modify
      7  * it under the terms of the GNU General Public License as published by
      8  * the Free Software Foundation, either version 3 of the License, or
      9  * (at your option) any later version.
     10  *
     11  * This program is distributed in the hope that it will be useful,
     12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     14  * GNU General Public License for more details.
     15  *
     16  * You should have received a copy of the GNU General Public License
     17  * along with this program. If not, see <http://www.gnu.org/licenses/>. */
     18 
     19 #include "shtr.h"
     20 #include <string.h>
     21 
     22 static const char*
     23 id2cstr(const enum shtr_molecule_id id)
     24 {
     25   const char* cstr = NULL;
     26   switch(id) {
     27     case SHTR_H2O: cstr = "H2O"; break;
     28     case SHTR_CO2: cstr = "CO2"; break;
     29     case SHTR_O3: cstr = "O3"; break;
     30     case SHTR_N2O: cstr = "N2O"; break;
     31     case SHTR_CO: cstr = "CO"; break;
     32     case SHTR_CH4: cstr = "CH4"; break;
     33     case SHTR_O2: cstr = "O2"; break;
     34     case SHTR_NO: cstr = "NO"; break;
     35     case SHTR_SO2: cstr = "SO2"; break;
     36     case SHTR_NO2: cstr = "NO2"; break;
     37     case SHTR_NH3: cstr = "NH3"; break;
     38     case SHTR_HNO3: cstr = "HNO3"; break;
     39     case SHTR_OH: cstr = "OH"; break;
     40     case SHTR_HF: cstr = "HF"; break;
     41     case SHTR_HCl: cstr = "HCl"; break;
     42     case SHTR_HBr: cstr = "HBr"; break;
     43     case SHTR_HI: cstr = "HI"; break;
     44     case SHTR_ClO: cstr = "ClO"; break;
     45     case SHTR_OCS: cstr = "OCS"; break;
     46     case SHTR_H2CO: cstr = "H2CO"; break;
     47     case SHTR_HOCl: cstr = "HOCl"; break;
     48     case SHTR_N2: cstr = "N2"; break;
     49     case SHTR_HCN: cstr = "HCN"; break;
     50     case SHTR_CH3Cl: cstr = "CH3Cl"; break;
     51     case SHTR_H2O2: cstr = "H2O2"; break;
     52     case SHTR_C2H2: cstr = "C2H2"; break;
     53     case SHTR_C2H6: cstr = "C2H6"; break;
     54     case SHTR_PH3: cstr = "PH3"; break;
     55     case SHTR_COF2: cstr = "COF2"; break;
     56     case SHTR_SF6: cstr = "SF6"; break;
     57     case SHTR_H2S: cstr = "H2S"; break;
     58     case SHTR_HCOOH: cstr = "HCOOH"; break;
     59     case SHTR_HO2: cstr = "HO2"; break;
     60     case SHTR_O: cstr = "O"; break;
     61     case SHTR_ClONO2: cstr = "ClONO2"; break;
     62     case SHTR_NOplus: cstr = "NO+"; break;
     63     case SHTR_HOBr: cstr = "HOBr"; break;
     64     case SHTR_C2H4: cstr = "C2H4"; break;
     65     case SHTR_CH3OH: cstr = "CH3OH"; break;
     66     case SHTR_CH3Br: cstr = "CH3Br"; break;
     67     case SHTR_CH3CN: cstr = "CH3CN"; break;
     68     case SHTR_CF4: cstr = "CF4"; break;
     69     case SHTR_C4H2: cstr = "C4H2"; break;
     70     case SHTR_HC3N: cstr = "HC3N"; break;
     71     case SHTR_H2: cstr = "H2"; break;
     72     case SHTR_CS: cstr = "CS"; break;
     73     case SHTR_SO3: cstr = "SO3"; break;
     74     case SHTR_C2N2: cstr = "C2N2"; break;
     75     case SHTR_COCl2: cstr = "COCl2"; break;
     76     case SHTR_SO: cstr = "SO"; break;
     77     case SHTR_CH3F: cstr = "CH3F"; break;
     78     case SHTR_GeH4: cstr = "GeH4"; break;
     79     case SHTR_CS2: cstr = "CS2"; break;
     80     case SHTR_CH3I: cstr = "CH3I"; break;
     81     case SHTR_NF3: cstr = "NF3"; break;
     82     default: FATAL("Unreachable code\n"); break;
     83   }
     84   return cstr;
     85 }
     86 
     87 int
     88 main(void)
     89 {
     90   int i = 0;
     91 
     92   CHK(SHTR_MOLECULE_ID_NULL == 0);
     93 
     94   FOR_EACH(i, 1, SHTR_MAX_MOLECULE_COUNT) {
     95     const char* cstr0 = shtr_molecule_cstr(i);
     96     const char* cstr1 = id2cstr(i);
     97     CHK(!strcmp(cstr0, cstr1));
     98   }
     99   return 0;
    100 }