diff --git a/test/tests/test_sampler.cpp b/test/tests/test_sampler.cpp index 18dc144..2f129f4 100644 --- a/test/tests/test_sampler.cpp +++ b/test/tests/test_sampler.cpp @@ -14,7 +14,7 @@ int GetESRSupplyR() return 22000; } -TEST(Sampler, TestDcBehavior) +TEST(Sampler, TestDc) { Sampler dut; @@ -23,7 +23,7 @@ TEST(Sampler, TestDcBehavior) data.PumpCurrentVoltage = 1.75f; constexpr float virtualGroundVoltage = 1.65f; - for (size_t i = 0; i < 10; i++) + for (size_t i = 0; i < 5000; i++) { dut.ApplySample(data, virtualGroundVoltage); } @@ -31,5 +31,31 @@ TEST(Sampler, TestDcBehavior) // not exactly 0 because of filtering EXPECT_NEAR(0, dut.GetNernstAc(), 1e-3); EXPECT_FLOAT_EQ(0.45f, dut.GetNernstDc()); - EXPECT_NEAR(-0.0295, dut.GetPumpNominalCurrent(), 1e-3); + EXPECT_NEAR(-0.1616, dut.GetPumpNominalCurrent(), 1e-3); +} + +TEST(Sampler, TestAc) +{ + Sampler dut; + + AnalogChannelResult dataLow; + dataLow.NernstVoltage = 0.45f - 0.1f; + dataLow.PumpCurrentVoltage = 1.75f; + + AnalogChannelResult dataHigh; + dataHigh.NernstVoltage = 0.45f + 0.1f; + dataHigh.PumpCurrentVoltage = 1.75f; + + constexpr float virtualGroundVoltage = 1.65f; + + for (size_t i = 0; i < 5000; i++) + { + dut.ApplySample(dataLow, virtualGroundVoltage); + dut.ApplySample(dataHigh, virtualGroundVoltage); + } + + // not exactly 0 because of filtering + EXPECT_NEAR(0.2, dut.GetNernstAc(), 1e-3); + EXPECT_FLOAT_EQ(0.45f, dut.GetNernstDc()); + EXPECT_NEAR(-0.1616, dut.GetPumpNominalCurrent(), 1e-3); }