18 lines
681 B
C++
18 lines
681 B
C++
#include <gtest/gtest.h>
|
||
#include "panels/chart/ScatterHoverTip.hpp"
|
||
|
||
using geopro::app::scatterHoverText;
|
||
|
||
// 对齐原版 Plotly hovertemplate:
|
||
// <b>X:</b> %{x:.3f}<br><b>Y:</b> %{y:.3f}<br><b>值:</b> %{marker.color:.3f}
|
||
TEST(ScatterHoverTip, FormatsXYValueWith3Decimals) {
|
||
const QString t = scatterHoverText(12.3456, 24.0, 60.77);
|
||
EXPECT_EQ(t, QStringLiteral("<b>X:</b> 12.346<br><b>Y:</b> 24.000<br><b>值:</b> 60.770"));
|
||
}
|
||
|
||
TEST(ScatterHoverTip, RoundsAndPadsToFixed3) {
|
||
// 负值、整数、需补零各覆盖一次
|
||
EXPECT_EQ(scatterHoverText(-1.0, 0.5, 1.0),
|
||
QStringLiteral("<b>X:</b> -1.000<br><b>Y:</b> 0.500<br><b>值:</b> 1.000"));
|
||
}
|