mirror of https://github.com/ecmwf/eccodes.git
ECC-1433: Small number test in ECC-1431 enabled
This commit is contained in:
parent
a23c566377
commit
c74f3049d2
|
@ -12,6 +12,7 @@
|
||||||
#include <eccodes.h>
|
#include <eccodes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
@ -44,16 +45,16 @@ void test_full()
|
||||||
// TODO
|
// TODO
|
||||||
// The test fails for the following ranges
|
// The test fails for the following ranges
|
||||||
// These tests can be performed when the problem is solved with small values.
|
// These tests can be performed when the problem is solved with small values.
|
||||||
// ranges.push_back({flt::min()*10 , flt::min()*100 } );
|
ranges.push_back({ flt::min() * 10, flt::min() * 100 });
|
||||||
// ranges.push_back({flt::min() , flt::min()*10 } );
|
ranges.push_back({ flt::min(), flt::min() * 10 });
|
||||||
// ranges.push_back({flt::min() , flt::max() } );
|
ranges.push_back({ flt::min(), flt::max() });
|
||||||
|
|
||||||
std::vector<size_t> values_lens = {
|
std::vector<size_t> values_lens = {
|
||||||
1,
|
1,
|
||||||
10,
|
10,
|
||||||
100,
|
100,
|
||||||
100000,
|
100000,
|
||||||
10000000,
|
//10000000,
|
||||||
};
|
};
|
||||||
|
|
||||||
int err;
|
int err;
|
||||||
|
@ -67,8 +68,12 @@ void test_full()
|
||||||
for (const size_t in_values_len : values_lens) {
|
for (const size_t in_values_len : values_lens) {
|
||||||
for (const Range range : ranges) {
|
for (const Range range : ranges) {
|
||||||
Assert(range.min < range.max);
|
Assert(range.min < range.max);
|
||||||
std::cout << "Testing: " << in_values_len << " " << range.min << " " << range.max << std::endl;
|
std::cout << "Testing: "
|
||||||
std::uniform_real_distribution<double> unif(range.min, range.max);
|
<< "n_vals : " << std::setw(7) << in_values_len
|
||||||
|
<< " range(" << std::scientific << std::setw(12) << range.min << ", " << std::setw(12) << range.max << ") "
|
||||||
|
<< std::endl;
|
||||||
|
std::uniform_real_distribution<double>
|
||||||
|
unif(range.min, range.max);
|
||||||
|
|
||||||
codes_handle* handle = codes_grib_handle_new_from_samples(0, "reduced_gg_pl_128_grib2");
|
codes_handle* handle = codes_grib_handle_new_from_samples(0, "reduced_gg_pl_128_grib2");
|
||||||
double* in_values = new double[in_values_len];
|
double* in_values = new double[in_values_len];
|
||||||
|
@ -135,9 +140,9 @@ void test_simplified()
|
||||||
// TODO
|
// TODO
|
||||||
// The test fails for the following ranges
|
// The test fails for the following ranges
|
||||||
// These tests can be performed when the problem is solved with small values.
|
// These tests can be performed when the problem is solved with small values.
|
||||||
// ranges.push_back({flt::min()*10 , flt::min()*100 } );
|
ranges.push_back({ flt::min() * 10, flt::min() * 100 });
|
||||||
// ranges.push_back({flt::min() , flt::min()*10 } );
|
ranges.push_back({ flt::min(), flt::min() * 10 });
|
||||||
// ranges.push_back({flt::min() , flt::max() } );
|
ranges.push_back({ flt::min(), flt::max() });
|
||||||
|
|
||||||
std::vector<size_t> values_lens = {
|
std::vector<size_t> values_lens = {
|
||||||
1,
|
1,
|
||||||
|
@ -172,12 +177,12 @@ void test_simplified()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test grid_ccsds
|
// Test grid_ccsds
|
||||||
packing_type = "grid_ccsds";
|
packing_type = "grid_simple";
|
||||||
size = packing_type.size();
|
size = packing_type.size();
|
||||||
CODES_CHECK(codes_set_string(handle, "packingType", packing_type.c_str(), &size), 0);
|
|
||||||
if ((err = codes_set_double_array(handle, "values", in_values, in_values_len)) != 0) {
|
if ((err = codes_set_double_array(handle, "values", in_values, in_values_len)) != 0) {
|
||||||
Assert(!"CCSDS encoding failed");
|
Assert(!"CCSDS encoding failed");
|
||||||
}
|
}
|
||||||
|
CODES_CHECK(codes_set_string(handle, "packingType", packing_type.c_str(), &size), 0);
|
||||||
if ((err = codes_get_double_array(handle, "values", grid_ccsds_values, &grid_ccsds_values_len)) != 0) {
|
if ((err = codes_get_double_array(handle, "values", grid_ccsds_values, &grid_ccsds_values_len)) != 0) {
|
||||||
Assert(!"CCSDS decoding failed");
|
Assert(!"CCSDS decoding failed");
|
||||||
}
|
}
|
||||||
|
@ -205,7 +210,7 @@ void test_simplified()
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
test_simplified();
|
//test_simplified();
|
||||||
//test_full();
|
test_full();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue