void RegressionTest::charComparisonForOccurrence(const std::string& keyword, int occurrence1, int occurrence2) const {
    ecl_kw_type* ecl_kw1 = nullptr;
    ecl_kw_type* ecl_kw2 = nullptr;
    const unsigned int numCells = getEclKeywordData(ecl_kw1, ecl_kw2, keyword, occurrence1, occurrence2);
    for (size_t cell = 0; cell < numCells; cell++) {
        std::string data1(ecl_kw_iget_char_ptr(ecl_kw1, cell));
        std::string data2(ecl_kw_iget_char_ptr(ecl_kw2, cell));
        if (data1.compare(data2) != 0) {
            printValuesForCell(keyword, occurrence1, occurrence2, cell, data1, data2);
            OPM_THROW(std::runtime_error, "Values of char type differ.");
        }
    }
}
Beispiel #2
0
void test_cmp_string() {
  ecl_kw_type * ecl_kw = ecl_kw_alloc( "HEADER" , 1 , ECL_CHAR);

  ecl_kw_iset_string8( ecl_kw , 0 , "ABCD");

  test_assert_int_equal( 0 , strcmp( ecl_kw_iget_char_ptr( ecl_kw , 0 ) , "ABCD    "));
  test_assert_true(ecl_kw_icmp_string( ecl_kw , 0 , "ABCD"));
  test_assert_true(ecl_kw_icmp_string( ecl_kw , 0 , "ABCD    "));
  test_assert_true(ecl_kw_icmp_string( ecl_kw , 0 , "ABCD "));

  test_assert_false( ecl_kw_icmp_string( ecl_kw , 0 , "Different"));
  test_assert_false( ecl_kw_icmp_string( ecl_kw , 0 , ""));
  test_assert_false( ecl_kw_icmp_string( ecl_kw , 0 , ""));

}