mirror of
https://git.gfz-potsdam.de/naaice/poet.git
synced 2025-12-16 04:48:23 +01:00
feat: implement data clustering using PHT feat: implement interpolation refactor: use named vector for DHT species definition and significant digits data: remove unusable input scripts data: move Phreeqc database to benchmark dir refactor: rename dolomite benchmark directory refactor: remove DHT prop type from input script
80 lines
2.5 KiB
C++
80 lines
2.5 KiB
C++
#include <doctest/doctest.h>
|
|
|
|
#include "poet/Rounding.hpp"
|
|
|
|
TEST_CASE("Rounding") {
|
|
constexpr int signif = 3;
|
|
|
|
poet::DHT_Rounder rounder;
|
|
|
|
SUBCASE("+exp - +sig") {
|
|
double input = 1.2345;
|
|
auto rounded = rounder.round(input, signif, false);
|
|
CHECK_EQ(rounded.sc_notation.significant, 123);
|
|
CHECK_EQ(rounded.sc_notation.exp, 0);
|
|
}
|
|
|
|
SUBCASE("+exp - -sig") {
|
|
double input = -1.2345;
|
|
auto rounded = rounder.round(input, signif, false);
|
|
CHECK_EQ(rounded.sc_notation.significant, -123);
|
|
CHECK_EQ(rounded.sc_notation.exp, 0);
|
|
}
|
|
|
|
SUBCASE("-exp - +sig") {
|
|
double input = 1.23456789E-5;
|
|
auto rounded = rounder.round(input, signif, false);
|
|
CHECK_EQ(rounded.sc_notation.significant, 123);
|
|
CHECK_EQ(rounded.sc_notation.exp, -5);
|
|
}
|
|
|
|
SUBCASE("-exp - -sig") {
|
|
double input = -1.23456789E-5;
|
|
auto rounded = rounder.round(input, signif, false);
|
|
CHECK_EQ(rounded.sc_notation.significant, -123);
|
|
CHECK_EQ(rounded.sc_notation.exp, -5);
|
|
}
|
|
|
|
SUBCASE("-exp - +sig (exceeding aqueous minimum)") {
|
|
double input = 1.23456789E-14;
|
|
auto rounded = rounder.round(input, signif, false);
|
|
CHECK_EQ(rounded.sc_notation.significant, 0);
|
|
CHECK_EQ(rounded.sc_notation.exp, 0);
|
|
}
|
|
|
|
SUBCASE("-exp - -sig (exceeding aqueous minimum)") {
|
|
double input = -1.23456789E-14;
|
|
auto rounded = rounder.round(input, signif, false);
|
|
CHECK_EQ(rounded.sc_notation.significant, 0);
|
|
CHECK_EQ(rounded.sc_notation.exp, 0);
|
|
}
|
|
|
|
SUBCASE("-exp - +sig (diff exceeds aqueous minimum)") {
|
|
double input = 1.23456789E-13;
|
|
auto rounded = rounder.round(input, signif, false);
|
|
CHECK_EQ(rounded.sc_notation.significant, 1);
|
|
CHECK_EQ(rounded.sc_notation.exp, -13);
|
|
}
|
|
|
|
SUBCASE("-exp - -sig (diff exceeds aqueous minimum)") {
|
|
double input = -1.23456789E-13;
|
|
auto rounded = rounder.round(input, signif, false);
|
|
CHECK_EQ(rounded.sc_notation.significant, -1);
|
|
CHECK_EQ(rounded.sc_notation.exp, -13);
|
|
}
|
|
|
|
SUBCASE("-exp - +sig (diff exceeds aqueous minimum - but H or O)") {
|
|
double input = 1.23456789E-13;
|
|
auto rounded = rounder.round(input, signif, true);
|
|
CHECK_EQ(rounded.sc_notation.significant, 123);
|
|
CHECK_EQ(rounded.sc_notation.exp, -13);
|
|
}
|
|
|
|
SUBCASE("-exp - -sig (diff exceeds aqueous minimum - but H or O)") {
|
|
double input = -1.23456789E-13;
|
|
auto rounded = rounder.round(input, signif, true);
|
|
CHECK_EQ(rounded.sc_notation.significant, -123);
|
|
CHECK_EQ(rounded.sc_notation.exp, -13);
|
|
}
|
|
}
|