Skip to content
Snippets Groups Projects
Unverified Commit 38827dda authored by Henner Zeller's avatar Henner Zeller Committed by GitHub
Browse files

Fix types used in Hash() function used in tests. (#640)


Using `auto` seems to create a different output on different platforms.
Notably it was observed that aarch64 compiles return a different
value.

Fix the type of the characters iterated through the string.

Fixes #639

Signed-off-by: default avatarHenner Zeller <h.zeller@acm.org>
parent 6e059dad
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,7 @@ namespace ftxui { ...@@ -15,7 +15,7 @@ namespace ftxui {
namespace { namespace {
uint32_t Hash(const std::string s) { uint32_t Hash(const std::string s) {
uint32_t hash = 0; uint32_t hash = 0;
for (auto c : s) { for (uint8_t c : s) {
hash += c; hash += c;
hash *= 7; hash *= 7;
} }
...@@ -38,7 +38,7 @@ TEST(CanvasTest, GoldPoint) { ...@@ -38,7 +38,7 @@ TEST(CanvasTest, GoldPoint) {
}); });
Screen screen(30, 10); Screen screen(30, 10);
Render(screen, element); Render(screen, element);
EXPECT_EQ(Hash(screen.ToString()), 2143518726); EXPECT_EQ(Hash(screen.ToString()), 2085952774U) << screen.ToString();
} }
TEST(CanvasTest, GoldPointColor) { TEST(CanvasTest, GoldPointColor) {
...@@ -53,7 +53,7 @@ TEST(CanvasTest, GoldPointColor) { ...@@ -53,7 +53,7 @@ TEST(CanvasTest, GoldPointColor) {
}); });
Screen screen(30, 10); Screen screen(30, 10);
Render(screen, element); Render(screen, element);
EXPECT_EQ(Hash(screen.ToString()), 1264423298); EXPECT_EQ(Hash(screen.ToString()), 2295070594U) << screen.ToString();
} }
TEST(CanvasTest, GoldBlock) { TEST(CanvasTest, GoldBlock) {
...@@ -71,7 +71,7 @@ TEST(CanvasTest, GoldBlock) { ...@@ -71,7 +71,7 @@ TEST(CanvasTest, GoldBlock) {
}); });
Screen screen(30, 10); Screen screen(30, 10);
Render(screen, element); Render(screen, element);
EXPECT_EQ(Hash(screen.ToString()), 3826174883); EXPECT_EQ(Hash(screen.ToString()), 2625314979U) << screen.ToString();
} }
TEST(CanvasTest, GoldBlockColor) { TEST(CanvasTest, GoldBlockColor) {
...@@ -86,7 +86,7 @@ TEST(CanvasTest, GoldBlockColor) { ...@@ -86,7 +86,7 @@ TEST(CanvasTest, GoldBlockColor) {
}); });
Screen screen(30, 10); Screen screen(30, 10);
Render(screen, element); Render(screen, element);
EXPECT_EQ(Hash(screen.ToString()), 3048712696); EXPECT_EQ(Hash(screen.ToString()), 8392696U) << screen.ToString();
} }
TEST(CanvasTest, GoldText) { TEST(CanvasTest, GoldText) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment