Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

マウスホイールでのフォントサイズ変更をパーセンテージに基づいて行うようにする #1513

Merged
Merged
Prev Previous commit
Next Next commit
レビュー指摘対応
* ズーム設定の正当性判定関数をtest-zoom.cppに移動する
  • Loading branch information
suconbu committed Feb 8, 2021
commit 7cc9f004a4a4b791250eb88ca330e853499cbe71
10 changes: 0 additions & 10 deletions sakura_core/util/zoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@
#include <algorithm>
#include <cmath>

/*!
@brief 設定値の正当性判定
*/
bool ZoomSetting::IsValid() const
{
return (m_nValueMin <= m_nValueMax)
&& (0.0 <= m_nValueUnit)
&& std::is_sorted( m_vZoomFactors.begin(), m_vZoomFactors.end() );
}

/*!
@brief 値テーブル上における指定値の位置を取得
@param[in] vTable 値テーブル
Expand Down
2 changes: 0 additions & 2 deletions sakura_core/util/zoom.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ struct ZoomSetting
const double m_nValueMin;
const double m_nValueMax;
const double m_nValueUnit;

[[nodiscard]] bool IsValid() const;
};

bool GetZoomedValue( const ZoomSetting& zoomSetting, double nBaseValue, double nCurrentZoom, int nSteps, double* pnValueOut, double* pnZoomOut );
Expand Down
20 changes: 15 additions & 5 deletions tests/unittests/test-zoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,35 @@
#include <gtest/gtest.h>
#include "util/zoom.h"

/*!
@brief 設定値の正当性判定
*/
bool ZoomSettingIsValid( const ZoomSetting& zoomSetting )
{
return (zoomSetting.m_nValueMin <= zoomSetting.m_nValueMax)
&& (0.0 <= zoomSetting.m_nValueUnit)
&& std::is_sorted( zoomSetting.m_vZoomFactors.begin(), zoomSetting.m_vZoomFactors.end() );
}

/*!
* @brief ZoomSetting構造体のテスト
*/
TEST( zoom, ZoomSetting )
{
// 不正な引数 - テーブルが昇順になっていない
EXPECT_EQ( false, ZoomSetting( {0.0, 2.0, 1.0}, 0.0, 0.0, 1.0 ).IsValid() );
EXPECT_EQ( false, ZoomSettingIsValid( ZoomSetting( {0.0, 2.0, 1.0}, 0.0, 0.0, 1.0 ) ) );

// 不正な引数 - 最大最小があべこべ
EXPECT_EQ( false, ZoomSetting( {1.0}, 1.0, 0.0, 1.0 ).IsValid() );
EXPECT_EQ( false, ZoomSettingIsValid( ZoomSetting( {1.0}, 1.0, 0.0, 1.0 ) ) );

// 不正な引数 - 解像度が負数
EXPECT_EQ( false, ZoomSetting( {1.0}, 0.0, 0.0, -1.0 ).IsValid() );
EXPECT_EQ( false, ZoomSettingIsValid( ZoomSetting( {1.0}, 0.0, 0.0, -1.0 ) ) );

// 正しい引数 - テーブルに同一値が含まれる
EXPECT_EQ( true, ZoomSetting( {0.0, 1.0, 1.0, 2.0}, 0.0, 0.0, 1.0 ).IsValid() );
EXPECT_EQ( true, ZoomSettingIsValid( ZoomSetting( {0.0, 1.0, 1.0, 2.0}, 0.0, 0.0, 1.0 ) ) );

// 正しい引数 - 解像度が0
EXPECT_EQ( true, ZoomSetting( {0.0}, 0.0, 0.0, 0.0 ).IsValid() );
EXPECT_EQ( true, ZoomSettingIsValid( ZoomSetting( {0.0}, 0.0, 0.0, 0.0 ) ) );
}

/*!
Expand Down