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: Henner Zeller <h.zeller@acm.org>
This commit is contained in:
Henner Zeller 2023-05-17 02:59:41 -07:00 committed by ArthurSonzogni
parent a3f51ecf22
commit ac10603fdb
No known key found for this signature in database
GPG Key ID: 41D98248C074CD6C

View File

@ -14,7 +14,7 @@ namespace ftxui {
namespace {
uint32_t Hash(const std::string s) {
uint32_t hash = 0;
for (auto c : s) {
for (uint8_t c : s) {
hash += c;
hash *= 7;
}
@ -37,7 +37,7 @@ TEST(CanvasTest, GoldPoint) {
});
Screen screen(30, 10);
Render(screen, element);
EXPECT_EQ(Hash(screen.ToString()), 2143518726);
EXPECT_EQ(Hash(screen.ToString()), 2085952774U) << screen.ToString();
}
TEST(CanvasTest, GoldPointColor) {
@ -52,7 +52,7 @@ TEST(CanvasTest, GoldPointColor) {
});
Screen screen(30, 10);
Render(screen, element);
EXPECT_EQ(Hash(screen.ToString()), 1264423298);
EXPECT_EQ(Hash(screen.ToString()), 2295070594U) << screen.ToString();
}
TEST(CanvasTest, GoldBlock) {
@ -70,7 +70,7 @@ TEST(CanvasTest, GoldBlock) {
});
Screen screen(30, 10);
Render(screen, element);
EXPECT_EQ(Hash(screen.ToString()), 3826174883);
EXPECT_EQ(Hash(screen.ToString()), 2625314979U) << screen.ToString();
}
TEST(CanvasTest, GoldBlockColor) {
@ -85,7 +85,7 @@ TEST(CanvasTest, GoldBlockColor) {
});
Screen screen(30, 10);
Render(screen, element);
EXPECT_EQ(Hash(screen.ToString()), 3048712696);
EXPECT_EQ(Hash(screen.ToString()), 8392696U) << screen.ToString();
}
TEST(CanvasTest, GoldText) {