mirror of
https://github.com/SFML/SFML.git
synced 2025-01-18 23:35:11 +08:00
Improve const correctness
This commit is contained in:
parent
e44a4b305d
commit
939ec267df
@ -18,14 +18,14 @@ TEST_CASE("[System] sf::Vector2")
|
||||
{
|
||||
SUBCASE("Default constructor")
|
||||
{
|
||||
sf::Vector2i vector;
|
||||
const sf::Vector2i vector;
|
||||
CHECK(vector.x == 0);
|
||||
CHECK(vector.y == 0);
|
||||
}
|
||||
|
||||
SUBCASE("(x, y) coordinate constructor")
|
||||
{
|
||||
sf::Vector2i vector(1, 2);
|
||||
const sf::Vector2i vector(1, 2);
|
||||
CHECK(vector.x == 1);
|
||||
CHECK(vector.y == 2);
|
||||
}
|
||||
@ -146,7 +146,7 @@ TEST_CASE("[System] sf::Vector2")
|
||||
SUBCASE("Arithmetic operations between vector and scalar value")
|
||||
{
|
||||
sf::Vector2i vector(26, 12);
|
||||
int scalar = 2;
|
||||
const int scalar = 2;
|
||||
|
||||
SUBCASE("vector * scalar")
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ TEST_CASE("[System] sf::Vector3")
|
||||
{
|
||||
SUBCASE("Default constructor")
|
||||
{
|
||||
sf::Vector3i vector;
|
||||
const sf::Vector3i vector;
|
||||
CHECK(vector.x == 0);
|
||||
CHECK(vector.y == 0);
|
||||
CHECK(vector.z == 0);
|
||||
@ -22,7 +22,7 @@ TEST_CASE("[System] sf::Vector3")
|
||||
|
||||
SUBCASE("(x, y, z) coordinate constructor")
|
||||
{
|
||||
sf::Vector3i vector(1, 2, 3);
|
||||
const sf::Vector3i vector(1, 2, 3);
|
||||
CHECK(vector.x == 1);
|
||||
CHECK(vector.y == 2);
|
||||
CHECK(vector.z == 3);
|
||||
@ -30,8 +30,8 @@ TEST_CASE("[System] sf::Vector3")
|
||||
|
||||
SUBCASE("Conversion constructor")
|
||||
{
|
||||
sf::Vector3f sourceVector(1.0f, 2.0f, 3.0f);
|
||||
sf::Vector3i vector(sourceVector);
|
||||
const sf::Vector3f sourceVector(1.0f, 2.0f, 3.0f);
|
||||
const sf::Vector3i vector(sourceVector);
|
||||
|
||||
CHECK(vector.x == static_cast<int>(sourceVector.x));
|
||||
CHECK(vector.y == static_cast<int>(sourceVector.y));
|
||||
@ -43,8 +43,8 @@ TEST_CASE("[System] sf::Vector3")
|
||||
{
|
||||
SUBCASE("-vector")
|
||||
{
|
||||
sf::Vector3i vector(1, 2, 3);
|
||||
sf::Vector3i negatedVector = -vector;
|
||||
const sf::Vector3i vector(1, 2, 3);
|
||||
const sf::Vector3i negatedVector = -vector;
|
||||
|
||||
CHECK(negatedVector.x == -1);
|
||||
CHECK(negatedVector.y == -2);
|
||||
@ -54,8 +54,8 @@ TEST_CASE("[System] sf::Vector3")
|
||||
|
||||
SUBCASE("Arithmetic operations between two vectors")
|
||||
{
|
||||
sf::Vector3i firstVector(2, 5, 6);
|
||||
sf::Vector3i secondVector(8, 3, 7);
|
||||
sf::Vector3i firstVector(2, 5, 6);
|
||||
const sf::Vector3i secondVector(8, 3, 7);
|
||||
|
||||
SUBCASE("vector += vector")
|
||||
{
|
||||
@ -77,7 +77,7 @@ TEST_CASE("[System] sf::Vector3")
|
||||
|
||||
SUBCASE("vector + vector")
|
||||
{
|
||||
sf::Vector3i result = firstVector + secondVector;
|
||||
const sf::Vector3i result = firstVector + secondVector;
|
||||
|
||||
CHECK(result.x == 10);
|
||||
CHECK(result.y == 8);
|
||||
@ -86,7 +86,7 @@ TEST_CASE("[System] sf::Vector3")
|
||||
|
||||
SUBCASE("vector - vector")
|
||||
{
|
||||
sf::Vector3i result = firstVector - secondVector;
|
||||
const sf::Vector3i result = firstVector - secondVector;
|
||||
|
||||
CHECK(result.x == -6);
|
||||
CHECK(result.y == 2);
|
||||
@ -97,7 +97,7 @@ TEST_CASE("[System] sf::Vector3")
|
||||
SUBCASE("Arithmetic operations between vector and scalar value")
|
||||
{
|
||||
sf::Vector3i vector(26, 12, 6);
|
||||
int scalar = 2;
|
||||
const int scalar = 2;
|
||||
|
||||
SUBCASE("vector * scalar")
|
||||
{
|
||||
@ -147,9 +147,9 @@ TEST_CASE("[System] sf::Vector3")
|
||||
|
||||
SUBCASE("Comparison operations (two equal and one different vector)")
|
||||
{
|
||||
sf::Vector3i firstEqualVector(1, 5, 6);
|
||||
sf::Vector3i secondEqualVector(1, 5, 6);
|
||||
sf::Vector3i differentVector(6, 9, 7);
|
||||
const sf::Vector3i firstEqualVector(1, 5, 6);
|
||||
const sf::Vector3i secondEqualVector(1, 5, 6);
|
||||
const sf::Vector3i differentVector(6, 9, 7);
|
||||
|
||||
SUBCASE("vector == vector")
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user